xref: /aoo4110/main/svtools/workben/cui/loadlib.cxx (revision b1cdbd2c)
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_svtools.hxx"
26 
27 #include <stdio.h>
28 #include <string.h>
29 #include <stdlib.h>
30 
31 #include <tools/string.hxx>
32 #include <osl/module.h>
33 #include <rtl/ustring.hxx>
34 
35 using namespace rtl;
36 
37 extern "C" {
38 struct VersionInfo
39 {
40         const char*     pTime;
41         const char*     pDate;
42         const char*     pUpd;
43         const char*     pMinor;
44         const char*     pBuild;
45         const char*     pInpath;
46 };
47 
48 typedef VersionInfo*(__LOADONCALLAPI *GetVersionInfo)(void);
49 }
50 
main(int argc,char ** argv)51 int __LOADONCALLAPI main( int argc, char **argv )
52 {
53 	VersionInfo *pInfo = NULL;
54 
55 	if ( argc != 2 )
56 	{
57 		fprintf( stderr, "USAGE: %s DllName \n", argv[0] );
58 		exit(0);
59 	}
60     OUString aLib = OUString::createFromAscii(argv[1]);
61     oslModule aLibrary = osl_loadModule( aLib.pData, SAL_LOADMODULE_DEFAULT );
62     if ( aLibrary )
63     {
64         void* pFunc = osl_getSymbol( aLibrary, OUString::createFromAscii( "GetVersionInfo" ).pData );
65         if ( pFunc )
66             pInfo = (*(GetVersionInfo)pFunc)();
67     }
68 	if ( pInfo )
69 	{
70 		fprintf( stdout, "Date : %s\n", pInfo->pDate );
71 		fprintf( stdout, "Time : %s\n", pInfo->pTime );
72 		fprintf( stdout, "UPD : %s\n", pInfo->pUpd );
73 		fprintf( stdout, "Minor : %s\n", pInfo->pMinor );
74 		fprintf( stdout, "Build : %s\n", pInfo->pBuild );
75 		fprintf( stdout, "Inpath : %s\n", pInfo->pInpath );
76 	}
77 	else
78 		fprintf( stderr, "VersionInfo not Found !\n" );
79 
80     if ( aLibrary )
81         osl_unloadModule( aLibrary );
82 
83     return 0;
84 }
85 
86