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 <dllname>\n", pprog_name
);
54 int main(int argc
, char *argv
[])
60 if ( argc
< 2 || argc
> 3) {
65 if ( (rc
= access( argv
[1], R_OK
)) == -1 ) {
66 fprintf(stderr
, "%s: ERROR: %s: %s\n",
67 pprog_name
, argv
[1], strerror(errno
));
71 printf("Checking DLL %s ...", argv
[1]);
74 if ( (phandle
= dlopen(argv
[1], RTLD_NOW
)) != NULL
) {
75 if ( (pfun
= (char *(*)(void))dlsym(phandle
, psymbol
)) != NULL
) {
80 printf(": WARNING: %s\n", dlerror());
82 #ifdef NO_UNLOAD_CHECK
90 printf(": ERROR: %s\n", dlerror());