xref: /trunk/main/svtools/workben/cui/loadlib.cxx (revision 0495d53e)
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*     pUpd;
41         const char*     pMinor;
42         const char*     pBuild;
43 };
44 
45 typedef VersionInfo*(__LOADONCALLAPI *GetVersionInfo)(void);
46 }
47 
main(int argc,char ** argv)48 int __LOADONCALLAPI main( int argc, char **argv )
49 {
50 	VersionInfo *pInfo = NULL;
51 
52 	if ( argc != 2 )
53 	{
54 		fprintf( stderr, "USAGE: %s DllName \n", argv[0] );
55 		exit(0);
56 	}
57     OUString aLib = OUString::createFromAscii(argv[1]);
58     oslModule aLibrary = osl_loadModule( aLib.pData, SAL_LOADMODULE_DEFAULT );
59     if ( aLibrary )
60     {
61         void* pFunc = osl_getSymbol( aLibrary, OUString::createFromAscii( "GetVersionInfo" ).pData );
62         if ( pFunc )
63             pInfo = (*(GetVersionInfo)pFunc)();
64     }
65 	if ( pInfo )
66 	{
67 		fprintf( stdout, "UPD : %s\n", pInfo->pUpd );
68 		fprintf( stdout, "Minor : %s\n", pInfo->pMinor );
69 		fprintf( stdout, "Build : %s\n", pInfo->pBuild );
70 	}
71 	else
72 		fprintf( stderr, "VersionInfo not Found !\n" );
73 
74     if ( aLibrary )
75         osl_unloadModule( aLibrary );
76 
77     return 0;
78 }
79 
80