1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_tools.hxx" 26 #include <tools/iparser.hxx> 27 #include <tools/geninfo.hxx> 28 #include "bootstrp/appdef.hxx" 29 #include <stdio.h> 30 31 32 /*****************************************************************************/ 33 #ifdef UNX 34 int main( int argc, char *argv[] ) 35 #else 36 int _cdecl main( int argc, char *argv[] ) 37 #endif 38 /*****************************************************************************/ 39 { 40 if ( argc == 1 ) { 41 fprintf( stdout, "\ni_server.exe v2.0 (c) 2000\n\n" ); 42 fprintf( stdout, "Syntax: i_server -i accesspath [-l] [-d database] \n" ); 43 fprintf( stdout, "Example: - i_server -i vcl364/settings/now\n" ); 44 fprintf( stdout, " returns value of settings \"now\" of version \"vcl364\"\n" ); 45 fprintf( stdout, " - i_server -i vcl364/settings -l\n" ); 46 fprintf( stdout, " returns a list of all settings of version \"vcl364\"\n" ); 47 } 48 else { 49 sal_Bool bError = sal_False; 50 sal_Bool bList = sal_False; 51 ByteString sInfo( "" ); 52 ByteString sDataBase( GetDefStandList()); 53 54 sal_Bool bGetNow = sal_False; 55 56 int nCount = 1; 57 while (( nCount < argc ) && 58 ( !bError )) 59 { 60 if ( ByteString( argv[nCount] ).ToUpperAscii() == "-I" ) { 61 // requestet info path 62 nCount++; 63 if( nCount < argc ) { 64 sInfo = ByteString( argv[nCount] ); 65 nCount++; 66 } 67 else bError = sal_True; 68 } 69 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-D" ) { 70 // requestet info path 71 nCount++; 72 if( nCount < argc ) { 73 sDataBase = ByteString( argv[nCount] ); 74 nCount++; 75 } 76 else bError = sal_True; 77 } 78 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-L" ) { 79 // request list of childs 80 nCount++; 81 bList = sal_True; 82 } 83 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-N" ) { 84 // request list of childs 85 nCount++; 86 bGetNow = sal_True; 87 } 88 else { 89 bError = sal_True; 90 } 91 } 92 93 if ( !bError ) { 94 InformationParser aParser( REPLACE_VARIABLES ); 95 ByteString sStandList( sDataBase ); 96 String s = String( sStandList, gsl_getSystemTextEncoding()); 97 GenericInformationList *pList = aParser.Execute( s ); 98 if ( !pList ) 99 return 1; 100 101 if ( sInfo.Len()) { 102 GenericInformation *pInfo = pList->GetInfo( sInfo, sal_True ); 103 104 if ( pInfo ) { 105 ByteString sValue( pInfo->GetValue()); 106 // show the info and its value 107 fprintf( stdout, "%s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); 108 if ( bList ) { 109 GenericInformationList *pList = pInfo->GetSubList(); 110 if ( pList ) { 111 // show whole list of childs and their values 112 for( sal_uIntPtr i = 0; i < pList->Count(); i++ ) { 113 GenericInformation *pInfo = pList->GetObject( i ); 114 ByteString sValue( pInfo->GetValue()); 115 fprintf( stdout, " %s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); 116 } 117 } 118 } 119 return 0; 120 } 121 return 1; 122 } 123 else { 124 // show whole list of childs and their values 125 for( sal_uIntPtr i = 0; i < pList->Count(); i++ ) { 126 GenericInformation *pInfo = pList->GetObject( i ); 127 if ( bGetNow ) { 128 ByteString sPath( "settings/now" ); 129 GenericInformation *pSubInfo = pInfo->GetSubInfo( sPath, sal_True ); 130 if ( pSubInfo && pSubInfo->GetValue() == "_TRUE" ) 131 fprintf( stdout, "%s\n", pInfo->GetBuffer()); 132 } 133 else { 134 ByteString sValue( pInfo->GetValue()); 135 fprintf( stdout, " %s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); 136 } 137 } 138 return 0; 139 } 140 } 141 else 142 fprintf( stderr, "%s: Fehler in der Kommandozeile!", argv[0] ); 143 // command line arror !!! 144 } 145 146 return 1; 147 } 148 149