MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mysqldev Date:March 25 2007 2:28am
Subject:Connector/ODBC 3.51 commit: r261 - in trunk: . dltest driver
View as plain text  
Modified:
   trunk/Makefile.am
   trunk/dltest/dltest.c
   trunk/driver/Makefile.am
Log:
Use "-module" when linking the driver, to instruct this is a module to load.
Don't give "dltest" directory to EXTRA_DIST when already in DIST_SUBDIRS.
Added alternative argument syntax to the "dltest" tool, you can give
multiple libraries and symbols on the comment line, prefixed with "lib:"
and "sym:".


Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2007-03-23 19:28:07 UTC (rev 260)
+++ trunk/Makefile.am	2007-03-25 02:28:16 UTC (rev 261)
@@ -131,7 +131,6 @@
 	PostBuildTest.bat \
 	Uninstall.bat \
 	Upgrade.bat \
-	dltest \
 	doc
 
 # Remove Subversion ".svn" subdirectories from source distribution

Modified: trunk/dltest/dltest.c
===================================================================
--- trunk/dltest/dltest.c	2007-03-23 19:28:07 UTC (rev 260)
+++ trunk/dltest/dltest.c	2007-03-25 02:28:16 UTC (rev 261)
@@ -15,6 +15,7 @@
 "* Syntax                                     *\n" \
 "*                                            *\n" \
 "*      dltest libName Symbol                 *\n" \
+"*      dltest lib:libName... sym:Symbol...   *\n" \
 "*                                            *\n" \
 "* libName                                    *\n" \
 "*                                            *\n" \
@@ -43,99 +44,153 @@
 "*                                            *\n" \
 "**********************************************\n\n";
 
-int main( int argc, char *argv[] )
-{
 #ifdef WIN32
-    HMODULE         hModule     = NULL;
+typedef HMODULE DLTestModule;
 #else
-    void *          hModule     = NULL;
+typedef void *  DLTestModule;
 #endif
-    void    (*pFunc)();
 
-    if ( argc < 2 )
+static void dltest_dlinit(void);
+static DLTestModule dltest_dlopen(const char *);
+static void dltest_dlsym(DLTestModule, const char *);
+static void dltest_dlclose(DLTestModule);
+
+
+int main( int argc, char *argv[] )
+{
+  DLTestModule hModule = NULL;
+
+  if ( argc < 2 )
+  {
+      printf( szSyntax );
+      exit( 1 );
+  }
+
+  /* At least one argument, a library path */
+
+  dltest_dlinit();
+
+  if ( strncmp(argv[1],"lib:",4) == 0 || strncmp(argv[1],"sym:",4) == 0 )
+  {
+    /* Alternative API, can handle multiple libs and symbols, in any mix */
+    int i;
+    for (i = 1; i < argc; i++)
     {
-        printf( szSyntax );
-        exit( 1 );
+      if (strncmp(argv[1],"lib:",4) == 0)
+      {
+        hModule = dltest_dlopen(argv[i]+4);     /* Open a new module */
+      }
+      else if (strncmp(argv[1],"sym:",4) == 0)
+      {
+        dltest_dlsym(hModule,argv[i]+4);
+      }
     }
 
     /*
-     * initialize libtool
-     */
+      Why close at all, and if we load libraries dependent on each
+      other, closing will prevent a later opened lib from accessing
+      symbols from the previous one, at least on AIX 5.2
+    */
+  }
+  else
+  {
+    /* Old API */
+    hModule = dltest_dlopen(argv[1]);
+    if ( argc > 2 )
+      dltest_dlsym(hModule,argv[2]);
+    dltest_dlclose(hModule);
+  }
 
+  return(0);
+}
+
+
+static void dltest_dlinit(void)
+{
 #ifndef WIN32
-    if ( lt_dlinit() )
-    {
-        printf( "[%s][%d] ERROR: Failed to lt_dlinit()\n", __FILE__, __LINE__ );
-        exit( 1 );
-    }
+  if ( lt_dlinit() )
+  {
+    printf( "[%s][%d] ERROR: Failed to lt_dlinit()\n", __FILE__, __LINE__ );
+    exit( 1 );
+  }
+#endif
+}
 
-    hModule = lt_dlopen( argv[1] );
-    if ( !hModule )
-    {
-        printf( "[%s][%d] ERROR dlopen(): %s\n", __FILE__, __LINE__, lt_dlerror() );
-        exit( 1 );
-    }
-    printf( "[%s][%d] SUCCESS: Loaded %s\n", __FILE__, __LINE__, argv[1] );
-    if ( argc > 2 )
-    {
-        pFunc = (void (*)()) lt_dlsym( hModule, argv[2] );
-/* PAH - lt_dlerror() is not a good indicator of success    */
-/*		if ( (pError = lt_dlerror()) != NULL )              */
-        if ( !pFunc )
-        {
-            const char *pError;
+static DLTestModule dltest_dlopen(const char *path)
+{
+#ifdef WIN32
+  DLTestModule hModule = LoadLibrary((LPCSTR)path)
+  if ( !hModule )
+  {
+    LPVOID pszMsg;
+    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+                  NULL,
+                  GetLastError(),
+                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                  (LPTSTR) &pszMsg,
+                  0, 
+                  NULL);
+    printf("[%s][%d] ERROR LoadLibrary(): %s\n", __FILE__, __LINE__, pszMsg);
+    LocalFree(pszMsg);
+    exit(1);
+  }
+#else
+  DLTestModule hModule = lt_dlopen(path);
+  if ( !hModule )
+  {
+    printf("[%s][%d] ERROR dlopen(): %s\n", __FILE__, __LINE__, lt_dlerror());
+    exit(1);
+  }
+#endif /* WIN32 */
 
-            if ( (pError = lt_dlerror()) != NULL )
-                printf( "[%s][%d] ERROR: %s\n Could not find %s\n", __FILE__, __LINE__,
pError, argv[2] );
-            else
-                printf( "[%s][%d] ERROR: Could not find %s\n", __FILE__, __LINE__,
argv[2] );
-            exit( 1 );
-        }
-        printf( "[%s][%d] SUCCESS: Found %s\n", __FILE__, __LINE__, argv[2] );
-    }
-    lt_dlclose( hModule );
+  printf("[%s][%d] SUCCESS: Loaded %s\n", __FILE__, __LINE__, path);
+  return hModule;
+}
+
+
+static void dltest_dlclose(DLTestModule hModule)
+{
+#ifdef WIN32
+  FreeLibrary(hModule);
 #else
-    if ( !(hModule = LoadLibrary( (LPCSTR)argv[1] )) )
-    {
-        LPVOID pszMsg;
+  lt_dlclose(hModule);
+#endif /* WIN32 */
+}
 
-        FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
-                       NULL,
-                       GetLastError(),
-                       MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
-                       (LPTSTR) &pszMsg,
-                       0, 
-                       NULL );
-        printf( "[%s][%d] ERROR LoadLibrary(): %s\n", __FILE__, __LINE__, pszMsg );
-        LocalFree( pszMsg );
-        exit( 1 );
-    }
 
-    printf( "[%s][%d] SUCCESS: Loaded %s\n", __FILE__, __LINE__, argv[1] );
-    if ( argc > 2 )
-    {
-        pFunc = (void (*)()) GetProcAddress( hModule, argv[2] );
-        if ( !pFunc )
-        {
-            LPVOID pszMsg;
-    
-            FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
-                           NULL,
-                           GetLastError(),
-                           MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
-                           (LPTSTR) &pszMsg,
-                           0, 
-                           NULL );
-            printf( "[%s][%d] ERROR: Could not find %s. %s\n", __FILE__, __LINE__,
argv[2], pszMsg );
-            LocalFree( pszMsg );
-            FreeLibrary( hModule );
-            exit( 1 );
-        }
-        printf( "[%s][%d] SUCCESS: Found %s\n", __FILE__, __LINE__, argv[2] );
-    }
-    FreeLibrary( hModule );
+static void dltest_dlsym(DLTestModule hModule, const char *sym)
+{
+  void (*pFunc)();
+#ifdef WIN32
+  pFunc = (void (*)())GetProcAddress(hModule,sym);
+  if ( !pFunc )
+  {
+    LPVOID pszMsg;
+    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+                  NULL,
+                  GetLastError(),
+                  MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
+                  (LPTSTR) &pszMsg,
+                  0, 
+                  NULL);
+    printf("[%s][%d] ERROR: Could not find %s. %s\n",__FILE__,__LINE__,sym,pszMsg);
+    LocalFree(pszMsg);
+    FreeLibrary(hModule);
+    exit(1);
+  }
+#else
+  pFunc = (void (*)())lt_dlsym(hModule,sym);
+/* PAH - lt_dlerror() is not a good indicator of success    */
+/*		if ( (pError = lt_dlerror()) != NULL )              */
+  if ( !pFunc )
+  {
+    const char *pError;
+    if ( (pError = lt_dlerror()) != NULL )
+      printf("[%s][%d] ERROR: %s\n Could not find %s\n",__FILE__,__LINE__,pError,sym);
+    else
+      printf("[%s][%d] ERROR: Could not find %s\n",__FILE__,__LINE__,sym);
+    exit(1);
+  }
 #endif
-
-    return( 0 );
+  printf("[%s][%d] SUCCESS: Found %s\n",__FILE__,__LINE__,sym);
 }
-

Modified: trunk/driver/Makefile.am
===================================================================
--- trunk/driver/Makefile.am	2007-03-23 19:28:07 UTC (rev 260)
+++ trunk/driver/Makefile.am	2007-03-25 02:28:16 UTC (rev 261)
@@ -83,15 +83,9 @@
 endif
 libmyodbc3_debug_la_CPPFLAGS = -DMYODBC_DBG
 
-if ENABLE_BUNDLES
 libmyodbc3_la_LDFLAGS       = -release @myodbc_version@ -module 
 libmyodbc3_r_la_LDFLAGS     = -release @myodbc_version@ -module 
 libmyodbc3_debug_la_LDFLAGS = -release @myodbc_version@ -module 
-else
-libmyodbc3_la_LDFLAGS       = -release @myodbc_version@
-libmyodbc3_r_la_LDFLAGS     = -release @myodbc_version@
-libmyodbc3_debug_la_LDFLAGS = -release @myodbc_version@
-endif
 
 if WITH_DEBUG
 LTLIBS_DEPS = $(LTLIBS_DEBUG_DEPS)

Thread
Connector/ODBC 3.51 commit: r261 - in trunk: . dltest drivermysqldev25 Mar