plugins/check-xor.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <dlfcn.h>
00005 
00006 #include "mysqlfs-plugin.h"
00007 #ifdef HAVE_CONFIG_H
00008 #include <config.h>
00009 #endif
00010 #include <mysqlfs.h>
00011 
00016 int main(int argc, char **argv)
00017 {
00018     void *handle;
00019     void *(*bufferfilter)(unsigned char, unsigned char, unsigned char);
00020     mysqlfs_plugin *filterentries;
00021     char *error;
00022     unsigned char ver[] = {0, 0, 0};
00023 
00024     handle = dlopen ("dummy-xor.so", RTLD_LAZY);
00025     if (!handle)
00026     {
00027         fprintf (stderr, "%s\n", dlerror());
00028         exit(1);
00029     }
00030 
00031     dlerror();    /* Clear any existing error */
00032 
00033     bufferfilter = dlsym(handle, "mysqlfs_init");
00034     if (NULL != (error = dlerror()))
00035     {
00036         fprintf (stderr, "%s\n", error);
00037         exit(1);
00038     }
00039 
00040     if (NULL == bufferfilter)
00041     {
00042         fprintf (stderr, "NULL bufferfilter\n");
00043         exit(1);
00044     }
00045 
00046     /* grab the version data */
00047     {
00048         int i;
00049         char *a = strdup (VERSION);
00050         char *v;
00051         if (NULL != a)
00052         {
00053             v = strtok (a, ".");
00054 
00055             for (i = 0; NULL != v && i < (sizeof(ver)/sizeof(ver[0])); i++)
00056             {
00057                 ver[i] = atoi(v);
00058                 v = strtok (NULL, ".");
00059             }
00060             free (a);
00061         }
00062     }
00063         
00064     if (NULL == (filterentries = bufferfilter(ver[0], ver[1], ver[2])))
00065     {
00066         fprintf (stderr, "NULL jump points\n");
00067         exit(1);
00068     }
00069 
00070     if (NULL == filterentries->identity)
00071     {
00072         fprintf (stderr, "NULL identity function\n");
00073         exit(1);
00074     }
00075 
00076     if (NULL != filterentries->setblocksize)
00077         filterentries->setblocksize(DATA_BLOCK_SIZE);
00078     printf ("OK (%s) %s\n", VERSION, filterentries->identity());
00079     dlclose(handle);
00080     return 0;
00081 }
00082 

Generated on Sun Jul 12 20:25:26 2009 for mysqlfs by  doxygen 1.4.7