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     fprintf(stderr, "gnome_load\n");
  31     void *vfs_handle;
  32     void *gnome_handle;
  33     const char *errmsg;
  34 
  35     vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
  36     if (vfs_handle == NULL) {
  37 #ifdef INTERNAL_BUILD
  38        fprintf(stderr, "can not load libgnomevfs-2.so\n");
  39 #endif
  40        return FALSE;
  41     }
  42     dlerror(); /* Clear errors */
  43     gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
  44     if (gnome_vfs_init == NULL){
  45 #ifdef INTERNAL_BUILD
  46         fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
  47 #endif
  48         return 0;
  49     }
  50     if ((errmsg = dlerror()) != NULL) {
  51 #ifdef INTERNAL_BUILD
  52         fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
  53 #endif
  54         return 0;
  55     }
  56     // call gonme_vfs_init()
  57     (*gnome_vfs_init)();
  58 
  59     gnome_handle = dlopen("libgnome-2.so.0", RTLD_LAZY);
  60     if (gnome_handle == NULL) {
  61 #ifdef INTERNAL_BUILD
  62         fprintf(stderr, "can not load libgnome-2.so\n");
  63 #endif
  64         return FALSE;
  65     }
  66     dlerror(); /* Clear errors */
  67     gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
  68     if ((errmsg = dlerror()) != NULL) {
  69 #ifdef INTERNAL_BUILD
  70         fprintf(stderr, "can not find symble gnome_url_show\n");
  71 #endif
  72         return FALSE;
  73     }
  74     return TRUE;
  75 }
  76