/* * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ #include #include #include #include #ifndef __USE_GNU // required for dladdr() & Dl_info #define __USE_GNU #endif #include #include #include #include #include #include #include #include "wrapper.h" int wrapper_debug = 0; int wrapper_loaded = 0; int wrapper_gtk_version = 0; int wrapper_gtk_versionDebug = 0; int wrapper_load_symbols(int version, int verbose) { if (wrapper_loaded) { return wrapper_gtk_version; } wrapper_gtk_versionDebug = verbose; wrapper_debug = verbose; //DAVE remove before commit int success = 1; if (version == 3) { wrapper_gtk_version = 3; } else if (version == 0 || version == 2) { wrapper_gtk_version = 2; } else { fprintf(stderr,"Unrecognized GTK version requested, falling back to v 2.0\n"); fflush(stderr); wrapper_gtk_version = 2; } if (wrapper_gtk_versionDebug) { fprintf(stderr,"Loading GTK libraries version %d\n",version); } if (wrapper_load_symbols_gtk(wrapper_gtk_version) != 0 ) { if (version == 0) { // specific version not set, try the other wrapper_gtk_version = wrapper_gtk_version == 2 ? 3 : 2; if (wrapper_gtk_versionDebug) { fprintf(stderr,"Warning: trying alternate GTK version %d\n", wrapper_gtk_version); fflush(stderr); } if (wrapper_load_symbols_gtk(wrapper_gtk_version) != 0 ) { success = 0; } } } if (success && wrapper_load_symbols_gdk(wrapper_gtk_version) != 0 ) { success = 0; } if (success && wrapper_load_symbols_pix(wrapper_gtk_version) != 0 ) { success = 0; } if (!success) { fprintf (stderr, "Fatal Error: Could not resolve symbols in GTK libraries %d \n",version); fflush(stderr); exit(-10); } wrapper_loaded = 1; return version; }