merge the formfield patch from ooo-build
[ooovba.git] / tools / bootstrp / iserver.cxx
blob16fb80deb9ad29ff0e51943c17ddf271b4ac6e97
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: iserver.cxx,v $
10 * $Revision: 1.7 $
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"
36 #include <stdio.h>
39 /*****************************************************************************/
40 #ifdef UNX
41 int main( int argc, char *argv[] )
42 #else
43 int _cdecl main( int argc, char *argv[] )
44 #endif
45 /*****************************************************************************/
47 if ( argc == 1 ) {
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" );
55 else {
56 BOOL bError = FALSE;
57 BOOL bList = FALSE;
58 ByteString sInfo( "" );
59 ByteString sDataBase( GetDefStandList());
61 BOOL bGetNow = FALSE;
63 int nCount = 1;
64 while (( nCount < argc ) &&
65 ( !bError ))
67 if ( ByteString( argv[nCount] ).ToUpperAscii() == "-I" ) {
68 // requestet info path
69 nCount++;
70 if( nCount < argc ) {
71 sInfo = ByteString( argv[nCount] );
72 nCount++;
74 else bError = TRUE;
76 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-D" ) {
77 // requestet info path
78 nCount++;
79 if( nCount < argc ) {
80 sDataBase = ByteString( argv[nCount] );
81 nCount++;
83 else bError = TRUE;
85 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-L" ) {
86 // request list of childs
87 nCount++;
88 bList = TRUE;
90 else if ( ByteString( argv[nCount] ).ToUpperAscii() == "-N" ) {
91 // request list of childs
92 nCount++;
93 bGetNow = TRUE;
95 else {
96 bError = TRUE;
100 if ( !bError ) {
101 InformationParser aParser( REPLACE_VARIABLES );
102 ByteString sStandList( sDataBase );
103 String s = String( sStandList, gsl_getSystemTextEncoding());
104 GenericInformationList *pList = aParser.Execute( s );
105 if ( !pList )
106 return 1;
108 if ( sInfo.Len()) {
109 GenericInformation *pInfo = pList->GetInfo( sInfo, TRUE );
111 if ( pInfo ) {
112 ByteString sValue( pInfo->GetValue());
113 // show the info and its value
114 fprintf( stdout, "%s %s\n", pInfo->GetBuffer(), sValue.GetBuffer());
115 if ( bList ) {
116 GenericInformationList *pList = pInfo->GetSubList();
117 if ( pList ) {
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());
126 return 0;
128 return 1;
130 else {
131 // show whole list of childs and their values
132 for( ULONG i = 0; i < pList->Count(); i++ ) {
133 GenericInformation *pInfo = pList->GetObject( i );
134 if ( bGetNow ) {
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());
140 else {
141 ByteString sValue( pInfo->GetValue());
142 fprintf( stdout, " %s %s\n", pInfo->GetBuffer(), sValue.GetBuffer());
145 return 0;
148 else
149 fprintf( stderr, "%s: Fehler in der Kommandozeile!", argv[0] );
150 // command line arror !!!
153 return 1;