Index: src/licq.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/licq.cpp,v
retrieving revision 1.74
diff -u -d -p -r1.74 licq.cpp
--- src/licq.cpp	2 Jul 2003 04:41:01 -0000	1.74
+++ src/licq.cpp	27 Jul 2003 20:20:21 -0000
@@ -423,16 +423,34 @@ const char *CLicq::Version()
 }
 
 
-/*-----------------------------------------------------------------------------
- * LoadPlugin
- *
+/**
  * Loads the given plugin using the given command line arguments.
- *---------------------------------------------------------------------------*/
+ */
 CPlugin *CLicq::LoadPlugin(const char *_szName, int argc, char **argv)
-{
+{ CPlugin *p = new CPlugin(_szName);
+  struct 
+  {  
+     const char *symbol;
+     const char *symbol1;
+     void **location;
+  } table[]=
+  {  
+     {  "LP_Name",       "_LP_Name",        (void **) &(p->fName)        },
+     {  "LP_Version",    "_LP_Version",     (void **) &(p->fVersion)     },
+     {  "LP_Status",     "_LP_Status",      (void **) &(p->fStatus)      },
+     {  "LP_Description","_LP_Description", (void **) &(p->fDescription) },
+     {  "LP_BuildDate",  "_LP_BuildDate",   (void **) &(p->fBuildDate)   },
+     {  "LP_BuildTime",  "_LP_BuildTime",   (void **) &(p->fBuildTime)   },
+     {  "LP_Init",       "_LP_Init",        (void **) &(p->fInit)        },
+     {  "LP_Usage",      "_LP_Usage",       (void **) &(p->fUsage)       },
+     {  "LP_Main",       "_LP_Main",        (void **) &(p->fMain)        },
+     {  "LP_Main_tep",   "_LP_Main_tep",    (void **) &(p->fMain_tep)    },
+     {  "LP_ConfigFile", "_LP_ConfigFile",  (void **) &(p->fConfigFile)  },
+     {  "LP_Id",         "_LP_Id",          (void **) &(p->nId)          }
+  };
+  unsigned i, failed;
   void *handle;
   const char *error;
-  CPlugin *p = new CPlugin(_szName);
   char szPlugin[MAX_FILENAME_LEN];
 
   // First check if the plugin is in the shared location
@@ -468,158 +486,31 @@ CPlugin *CLicq::LoadPlugin(const char *_
     return NULL;
   }
 
-  // LP_Name
-  p->fName = (const char * (*)())dlsym(handle, "LP_Name");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fName = (const char * (*)())dlsym(handle, "_LP_Name");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Name() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, _szName, error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_Version
-  p->fVersion = (const char * (*)())dlsym(handle, "LP_Version");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fVersion = (const char * (*)())dlsym(handle, "_LP_Version");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Version() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_Status
-  p->fStatus = (const char * (*)())dlsym(handle, "LP_Status");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fStatus = (const char * (*)())dlsym(handle, "_LP_Status");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Status() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_Description
-  p->fDescription = (const char * (*)())dlsym(handle, "LP_Description");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fDescription = (const char * (*)())dlsym(handle, "_LP_Description");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Description() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_BuildDate
-  p->fBuildDate = (const char * (*)())dlsym(handle, "LP_BuildDate");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fBuildDate = (const char * (*)())dlsym(handle, "_LP_BuildDate");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_BuildDate() function in plugin (%s): %s.\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_BuildTime
-  p->fBuildTime = (const char * (*)())dlsym(handle, "LP_BuildTime");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fBuildTime = (const char * (*)())dlsym(handle, "_LP_BuildTime");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_BuildTime() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_Init
-  p->fInit = (bool (*)(int, char **))dlsym(handle, "LP_Init");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fInit = (bool (*)(int, char **))dlsym(handle, "_LP_Init");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Init() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_Usage
-  p->fUsage = (const char * (*)())dlsym(handle, "LP_Usage");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fUsage = (const char * (*)())dlsym(handle, "_LP_Usage");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Usage() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_Main
-  p->fMain = (int (*)(CICQDaemon *))dlsym(handle, "LP_Main");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fMain = (int (*)(CICQDaemon *))dlsym(handle, "_LP_Main");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Main() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_Main_tep
-  p->fMain_tep = (void * (*)(void *))dlsym(handle, "LP_Main_tep");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fMain_tep = (void * (*)(void *))dlsym(handle, "_LP_Main_tep");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Main_tep() function in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
-  }
-  // LP_ConfigFile
-  p->fConfigFile = (const char * (*)())dlsym(handle, "LP_ConfigFile");
-  if ((error = dlerror()) != NULL)
-  {
-    p->fConfigFile = (const char * (*)())dlsym(handle, "_LP_ConfigFile");
-    if ((error = dlerror()) != NULL)
-      p->fConfigFile = NULL;
-  }
-  // LP_Id
-  p->nId = (unsigned short *)dlsym(handle, "LP_Id");
-  if ((error = dlerror()) != NULL)
+  p->fName = 0;
+  for(failed=i=0; !failed && i < sizeof(table)/sizeof(*table) ; i++ )
   {
-    p->nId = (unsigned short *)dlsym(handle, "_LP_Id");
-    if ((error = dlerror()) != NULL)
-    {
-      gLog.Error("%sFailed to find LP_Id variable in plugin (%s): %s\n",
-                 L_ERRORxSTR, p->Name(), error);
-      delete p;
-      return NULL;
-    }
+     *(table[i].location) = dlsym(handle,  table[i].symbol);
+     error = dlerror();
+     if( error != NULL )
+     {
+        *(table[i].location) = dlsym(handle,  table[i].symbol1);
+        error = dlerror();
+        if( error != NULL )
+        {
+            failed = 1;
+            gLog.Error("%sFailed to find %s() function in plugin (%s): %s\n",
+                       L_ERRORxSTR, table[i].symbol, 
+                       p->fName ?  p->Name():_szName, error );
+            
+        }
+     }
   }
 
+  if( failed  )
+  {	delete p;
+  	return NULL;
+  }
+  
   // Set up the argument vector
   static int argcndx = 0;
   int argccnt = 0;
