gml_Loader_LFGlib.private.h

00001 #define GML_USE_DYNAMIC_LOADER 1
00002 
00003 #include <stdio.h>
00004 #include <dlfcn.h>
00005 #include <string.h>
00006 #include <limits.h>
00007 
00008 #include <lfglib/lfg_api.h>
00009 #ifdef GML_USE_DYNAMIC_LOADER
00010 
00011 static void* handle_LFGlib = NULL;
00012 
00013 static typeof(LFG_AcquisitionStart)* LFG_AcquisitionStart_wrapper = NULL;
00014 static typeof(LFG_AcquisitionStop)* LFG_AcquisitionStop_wrapper = NULL;
00015 static typeof(LFG_Close)* LFG_Close_wrapper = NULL;
00016 static typeof(LFG_EventHandlerInstall)* LFG_EventHandlerInstall_wrapper = NULL;
00017 static typeof(LFG_GetPointer)* LFG_GetPointer_wrapper = NULL;
00018 static typeof(LFG_Open)* LFG_Open_wrapper = NULL;
00019 static typeof(LFG_SetAndGet)* LFG_SetAndGet_wrapper = NULL;
00020 static typeof(LFG_SetRegBrightnessControl)* LFG_SetRegBrightnessControl_wrapper = NULL;
00021 static typeof(LFG_SetRegColourControl)* LFG_SetRegColourControl_wrapper = NULL;
00022 static typeof(LFG_SetRegContrastControl)* LFG_SetRegContrastControl_wrapper = NULL;
00023 static typeof(LFG_SetRegGammaRemoval)* LFG_SetRegGammaRemoval_wrapper = NULL;
00024 
00025 static
00026 int gml_Loader_Load_LFGlib ()
00027 {
00028   char* directories[] = {
00029     "~/Library/Frameworks",
00030     "/Library/Frameworks",
00031     "/System/Library/Frameworks",
00032     (char*)NULL
00033   };
00034   char** currentdir = directories;
00035   char* filename = "lfglib.framework/lfglib";
00036   char path[PATH_MAX] = {0, };
00037   
00038   while (*currentdir != NULL) {
00039     snprintf (path, PATH_MAX, "%s/%s", *currentdir, filename);
00040     handle_LFGlib = dlopen (path, RTLD_NOW);
00041     if (handle_LFGlib != NULL) break;
00042     fprintf (stderr, "[gml_Loader] %s not loadable\n", path);
00043     ++currentdir;
00044   }
00045   if (handle_LFGlib == NULL) return 1;
00046   fprintf (stderr, "[gml_Loader] loaded %s\n", path);
00047   
00048   LFG_AcquisitionStart_wrapper = (typeof(LFG_AcquisitionStart)*) dlsym (handle_LFGlib, "LFG_AcquisitionStart");
00049   if (LFG_AcquisitionStart_wrapper == NULL) {
00050     fprintf (stderr, "[gml_Loader] symbol \"LFG_AcquisitionStart\" not found\n");
00051     return 1;
00052   }
00053   
00054   LFG_AcquisitionStop_wrapper = (typeof(LFG_AcquisitionStop)*) dlsym (handle_LFGlib, "LFG_AcquisitionStop");
00055   if (LFG_AcquisitionStop_wrapper == NULL) {
00056     fprintf (stderr, "[gml_Loader] symbol \"LFG_AcquisitionStop\" not found\n");
00057     return 1;
00058   }
00059   
00060   LFG_Close_wrapper = (typeof(LFG_Close)*) dlsym (handle_LFGlib, "LFG_Close");
00061   if (LFG_Close_wrapper == NULL) {
00062     fprintf (stderr, "[gml_Loader] symbol \"LFG_Close\" not found\n");
00063     return 1;
00064   }
00065   
00066   LFG_EventHandlerInstall_wrapper = (typeof(LFG_EventHandlerInstall)*) dlsym (handle_LFGlib, "LFG_EventHandlerInstall");
00067   if (LFG_EventHandlerInstall_wrapper == NULL) {
00068     fprintf (stderr, "[gml_Loader] symbol \"LFG_EventHandlerInstall\" not found\n");
00069     return 1;
00070   }
00071   
00072   LFG_GetPointer_wrapper = (typeof(LFG_GetPointer)*) dlsym (handle_LFGlib, "LFG_GetPointer");
00073   if (LFG_GetPointer_wrapper == NULL) {
00074     fprintf (stderr, "[gml_Loader] symbol \"LFG_GetPointer\" not found\n");
00075     return 1;
00076   }
00077   
00078   LFG_Open_wrapper = (typeof(LFG_Open)*) dlsym (handle_LFGlib, "LFG_Open");
00079   if (LFG_Open_wrapper == NULL) {
00080     fprintf (stderr, "[gml_Loader] symbol \"LFG_Open\" not found\n");
00081     return 1;
00082   }
00083   
00084   LFG_SetAndGet_wrapper = (typeof(LFG_SetAndGet)*) dlsym (handle_LFGlib, "LFG_SetAndGet");
00085   if (LFG_SetAndGet_wrapper == NULL) {
00086     fprintf (stderr, "[gml_Loader] symbol \"LFG_SetAndGet\" not found\n");
00087     return 1;
00088   }
00089   
00090   LFG_SetRegBrightnessControl_wrapper = (typeof(LFG_SetRegBrightnessControl)*) dlsym (handle_LFGlib, "LFG_SetRegBrightnessControl");
00091   if (LFG_SetRegBrightnessControl_wrapper == NULL) {
00092     fprintf (stderr, "[gml_Loader] symbol \"LFG_SetRegBrightnessControl\" not found\n");
00093     return 1;
00094   }
00095   
00096   LFG_SetRegColourControl_wrapper = (typeof(LFG_SetRegColourControl)*) dlsym (handle_LFGlib, "LFG_SetRegColourControl");
00097   if (LFG_SetRegColourControl_wrapper == NULL) {
00098     fprintf (stderr, "[gml_Loader] symbol \"LFG_SetRegColourControl\" not found\n");
00099     return 1;
00100   }
00101   
00102   LFG_SetRegContrastControl_wrapper = (typeof(LFG_SetRegContrastControl)*) dlsym (handle_LFGlib, "LFG_SetRegContrastControl");
00103   if (LFG_SetRegContrastControl_wrapper == NULL) {
00104     fprintf (stderr, "[gml_Loader] symbol \"LFG_SetRegContrastControl\" not found\n");
00105     return 1;
00106   }
00107   
00108   LFG_SetRegGammaRemoval_wrapper = (typeof(LFG_SetRegGammaRemoval)*) dlsym (handle_LFGlib, "LFG_SetRegGammaRemoval");
00109   if (LFG_SetRegGammaRemoval_wrapper == NULL) {
00110     fprintf (stderr, "[gml_Loader] symbol \"LFG_SetRegGammaRemoval\" not found\n");
00111     return 1;
00112   }
00113   
00114   
00115   fprintf (stderr, "[gml_Loader] all LFGlib symbols found\n");
00116   return 0;
00117 }
00118 
00119 #define LFG_AcquisitionStart LFG_AcquisitionStart_wrapper
00120 #define LFG_AcquisitionStop LFG_AcquisitionStop_wrapper
00121 #define LFG_Close LFG_Close_wrapper
00122 #define LFG_EventHandlerInstall LFG_EventHandlerInstall_wrapper
00123 #define LFG_GetPointer LFG_GetPointer_wrapper
00124 #define LFG_Open LFG_Open_wrapper
00125 #define LFG_SetAndGet LFG_SetAndGet_wrapper
00126 #define LFG_SetRegBrightnessControl LFG_SetRegBrightnessControl_wrapper
00127 #define LFG_SetRegColourControl LFG_SetRegColourControl_wrapper
00128 #define LFG_SetRegContrastControl LFG_SetRegContrastControl_wrapper
00129 #define LFG_SetRegGammaRemoval LFG_SetRegGammaRemoval_wrapper
00130 
00131 
00132 #else /* GML_USE_DYNAMIC_LOADER */
00133 
00134 static
00135 int gml_Loader_Load_LFGlib ()
00136 {
00137   return 0;
00138 }
00139 
00140 #endif /* GML_USE_DYNAMIC_LOADER */
00141 
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.