1 /* 2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #include <dlfcn.h> 27 #include "gnome_interface.h" 28 29 int gnome_load() { 30 void *vfs_handle; 31 void *gnome_handle; 32 const char *errmsg; 33 34 vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY); 35 if (vfs_handle == NULL) { 36 #ifdef INTERNAL_BUILD 37 fprintf(stderr, "cannot load libgnomevfs-2.so\n"); 38 #endif 39 return FALSE; 40 } 41 dlerror(); /* Clear errors */ 42 gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init"); 43 if (gnome_vfs_init == NULL){ 44 #ifdef INTERNAL_BUILD 45 fprintf(stderr, "dlsym(gnome_vfs_init) returned NULL\n"); 46 #endif 47 return FALSE; 48 } 49 if ((errmsg = dlerror()) != NULL) { 50 #ifdef INTERNAL_BUILD 51 fprintf(stderr, "cannot find symbol gnome_vfs_init %s \n", errmsg); 52 #endif 53 return FALSE; 54 } 55 // call gonme_vfs_init() 56 (*gnome_vfs_init)(); 57 58 gnome_handle = dlopen("libgnome-2.so.0", RTLD_LAZY); 59 if (gnome_handle == NULL) { 60 #ifdef INTERNAL_BUILD 61 fprintf(stderr, "cannot load libgnome-2.so\n"); 62 #endif 63 return FALSE; 64 } 65 dlerror(); /* Clear errors */ 66 gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show"); 67 if (gnome_url_show == NULL) { 68 #ifdef INTERNAL_BUILD 69 fprintf (stderr, "The gnome_url_show pointer is NULL.\n"); 70 #endif /* INTERNAL_BUILD */ 71 return FALSE; 72 } 73 74 if ((errmsg = dlerror()) != NULL) { 75 #ifdef INTERNAL_BUILD 76 fprintf(stderr, "cannot find symbol gnome_url_show: %s\n", errmsg); 77 #endif 78 return FALSE; 79 } 80 return TRUE; 81 } 82