1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: iserver.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_tools.hxx"
33 #include <tools/iparser.hxx>
34 #include <tools/geninfo.hxx>
35 #include "bootstrp/appdef.hxx"
39 /*****************************************************************************/
41 int main( int argc
, char *argv
[] )
43 int _cdecl
main( int argc
, char *argv
[] )
45 /*****************************************************************************/
48 fprintf( stdout
, "\ni_server.exe v2.0 (c) 2000\n\n" );
49 fprintf( stdout
, "Syntax: i_server -i accesspath [-l] [-d database] \n" );
50 fprintf( stdout
, "Example: - i_server -i vcl364/settings/now\n" );
51 fprintf( stdout
, " returns value of settings \"now\" of version \"vcl364\"\n" );
52 fprintf( stdout
, " - i_server -i vcl364/settings -l\n" );
53 fprintf( stdout
, " returns a list of all settings of version \"vcl364\"\n" );
58 ByteString
sInfo( "" );
59 ByteString
sDataBase( GetDefStandList());
64 while (( nCount
< argc
) &&
67 if ( ByteString( argv
[nCount
] ).ToUpperAscii() == "-I" ) {
68 // requestet info path
71 sInfo
= ByteString( argv
[nCount
] );
76 else if ( ByteString( argv
[nCount
] ).ToUpperAscii() == "-D" ) {
77 // requestet info path
80 sDataBase
= ByteString( argv
[nCount
] );
85 else if ( ByteString( argv
[nCount
] ).ToUpperAscii() == "-L" ) {
86 // request list of childs
90 else if ( ByteString( argv
[nCount
] ).ToUpperAscii() == "-N" ) {
91 // request list of childs
101 InformationParser
aParser( REPLACE_VARIABLES
);
102 ByteString
sStandList( sDataBase
);
103 String s
= String( sStandList
, gsl_getSystemTextEncoding());
104 GenericInformationList
*pList
= aParser
.Execute( s
);
109 GenericInformation
*pInfo
= pList
->GetInfo( sInfo
, TRUE
);
112 ByteString
sValue( pInfo
->GetValue());
113 // show the info and its value
114 fprintf( stdout
, "%s %s\n", pInfo
->GetBuffer(), sValue
.GetBuffer());
116 GenericInformationList
*pList
= pInfo
->GetSubList();
118 // show whole list of childs and their values
119 for( ULONG i
= 0; i
< pList
->Count(); i
++ ) {
120 GenericInformation
*pInfo
= pList
->GetObject( i
);
121 ByteString
sValue( pInfo
->GetValue());
122 fprintf( stdout
, " %s %s\n", pInfo
->GetBuffer(), sValue
.GetBuffer());
131 // show whole list of childs and their values
132 for( ULONG i
= 0; i
< pList
->Count(); i
++ ) {
133 GenericInformation
*pInfo
= pList
->GetObject( i
);
135 ByteString
sPath( "settings/now" );
136 GenericInformation
*pSubInfo
= pInfo
->GetSubInfo( sPath
, TRUE
);
137 if ( pSubInfo
&& pSubInfo
->GetValue() == "_TRUE" )
138 fprintf( stdout
, "%s\n", pInfo
->GetBuffer());
141 ByteString
sValue( pInfo
->GetValue());
142 fprintf( stdout
, " %s %s\n", pInfo
->GetBuffer(), sValue
.GetBuffer());
149 fprintf( stderr
, "%s: Fehler in der Kommandozeile!", argv
[0] );
150 // command line arror !!!