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: checkdll.c,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 ************************************************************************/
39 * NOTE: Since no one is really interested in correct unload behavior I've
40 * disabled the shared library unload check. If you want to reenable it comment
41 * the following line out
43 #define NO_UNLOAD_CHECK
45 static const char *pprog_name
= "checkdll";
46 static const char *psymbol
= "GetVersionInfo";
50 fprintf(stderr
, "usage: %s [-s] <dllname>\n", pprog_name
);
54 int main(int argc
, char *argv
[])
61 if ( argc
< 2 || argc
> 4) {
66 if ( !strcmp(argv
[1],"-s") ) {
71 if ( (rc
= access( argv
[1], R_OK
)) == -1 ) {
72 fprintf(stderr
, "%s: ERROR: %s: %s\n",
73 pprog_name
, argv
[1], strerror(errno
));
77 if (!silent
) printf("Checking DLL %s ...", argv
[1]);
80 if ( (phandle
= dlopen(argv
[1], RTLD_NOW
)) != NULL
) {
81 if ( (pfun
= (char *(*)(void))dlsym(phandle
, psymbol
)) != NULL
) {
82 if (!silent
) printf(": ok\n");
86 printf(": WARNING: %s\n", dlerror());
88 #ifdef NO_UNLOAD_CHECK
96 printf(": ERROR: %s\n", dlerror());