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