1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_tools.hxx" 30 #include <tools/iparser.hxx> 31 #include <tools/geninfo.hxx> 32 #include "bootstrp/appdef.hxx" 33 #include <stdio.h> 34 35 36 /*****************************************************************************/ 37 #ifdef UNX 38 int main( int argc, char *argv[] ) 39 #else 40 int _cdecl main( int argc, char *argv[] ) 41 #endif 42 /*****************************************************************************/ 43 { 44 if ( argc == 1 ) { 45 fprintf( stdout, "\ni_server.exe v2.0 (c) 2000\n\n" ); 46 fprintf( stdout, "Syntax: i_server -i accesspath [-l] [-d database] \n" ); 47 fprintf( stdout, "Example: - i_server -i vcl364/settings/now\n" ); 48 fprintf( stdout, " returns value of settings \"now\" of version \"vcl364\"\n" ); 49 fprintf( stdout, " - i_server -i vcl364/settings -l\n" ); 50 fprintf( stdout, " returns a list of all settings of version \"vcl364\"\n" ); 51 } 52 else { 53 sal_Bool bError = sal_False; 54 sal_Bool bList = sal_False; 55 ByteString sInfo( "" ); 56 ByteString sDataBase( GetDefStandList()); 57 58 sal_Bool bGetNow = sal_False; 59 60 int nCount = 1; 61 while (( nCount < argc ) && 62 ( !bError )) 63 { 64 if ( ByteString( argv[nCount] ).ToUpperAscii() == "-I" ) { 65 // requestet info path 66 nCount++; 67 if( nCount < argc ) { 68 sInfo = ByteString( argv[nCount] ); 69 nCount++; 70 } 71 else bError = sal_True; 72 } 73 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-D" ) { 74 // requestet info path 75 nCount++; 76 if( nCount < argc ) { 77 sDataBase = ByteString( argv[nCount] ); 78 nCount++; 79 } 80 else bError = sal_True; 81 } 82 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-L" ) { 83 // request list of childs 84 nCount++; 85 bList = sal_True; 86 } 87 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-N" ) { 88 // request list of childs 89 nCount++; 90 bGetNow = sal_True; 91 } 92 else { 93 bError = sal_True; 94 } 95 } 96 97 if ( !bError ) { 98 InformationParser aParser( REPLACE_VARIABLES ); 99 ByteString sStandList( sDataBase ); 100 String s = String( sStandList, gsl_getSystemTextEncoding()); 101 GenericInformationList *pList = aParser.Execute( s ); 102 if ( !pList ) 103 return 1; 104 105 if ( sInfo.Len()) { 106 GenericInformation *pInfo = pList->GetInfo( sInfo, sal_True ); 107 108 if ( pInfo ) { 109 ByteString sValue( pInfo->GetValue()); 110 // show the info and its value 111 fprintf( stdout, "%s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); 112 if ( bList ) { 113 GenericInformationList *pList = pInfo->GetSubList(); 114 if ( pList ) { 115 // show whole list of childs and their values 116 for( sal_uIntPtr i = 0; i < pList->Count(); i++ ) { 117 GenericInformation *pInfo = pList->GetObject( i ); 118 ByteString sValue( pInfo->GetValue()); 119 fprintf( stdout, " %s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); 120 } 121 } 122 } 123 return 0; 124 } 125 return 1; 126 } 127 else { 128 // show whole list of childs and their values 129 for( sal_uIntPtr i = 0; i < pList->Count(); i++ ) { 130 GenericInformation *pInfo = pList->GetObject( i ); 131 if ( bGetNow ) { 132 ByteString sPath( "settings/now" ); 133 GenericInformation *pSubInfo = pInfo->GetSubInfo( sPath, sal_True ); 134 if ( pSubInfo && pSubInfo->GetValue() == "_TRUE" ) 135 fprintf( stdout, "%s\n", pInfo->GetBuffer()); 136 } 137 else { 138 ByteString sValue( pInfo->GetValue()); 139 fprintf( stdout, " %s %s\n", pInfo->GetBuffer(), sValue.GetBuffer()); 140 } 141 } 142 return 0; 143 } 144 } 145 else 146 fprintf( stderr, "%s: Fehler in der Kommandozeile!", argv[0] ); 147 // command line arror !!! 148 } 149 150 return 1; 151 } 152 153