Move QMMM source to C++
[gromacs.git] / cmake / TestVMD.c
blobd0618ff9274176b3ae3050d1e6ee4dd40d4e366f
1 #include "molfile_plugin.h"
2 #include "vmddlopen.c"
3 #include "stdio.h"
5 static int register_cb(void *v, vmdplugin_t *p) {
6 *(molfile_plugin_t**)v = (molfile_plugin_t *)p;
7 return VMDPLUGIN_SUCCESS;
10 typedef int (*initfunc)(void);
11 typedef int (*regfunc)(void *, vmdplugin_register_cb);
13 /*run: gcc TestVMD.c -DGMX_USE_PLUGINS -Wall -ldl src/gmxlib/vmddlopen.c -I src/gmxlib && ./a.out .../xyzplugin.so ; echo $?*/
14 int main(int argc, char** argv)
16 void *handle, *ifunc, *registerfunc;
17 molfile_plugin_t* api;
18 if (argc!=2) return -1;
19 handle = vmddlopen(argv[1]);
20 if (!handle)
22 fprintf(stderr,"%s\n",vmddlerror());
23 return 1;
25 ifunc = vmddlsym(handle, "vmdplugin_init");
26 if (!ifunc || ((initfunc)(ifunc))()) return 2;
27 registerfunc = vmddlsym(handle, "vmdplugin_register");
28 if (!registerfunc) return 3;
29 ((regfunc)registerfunc)(&api, register_cb);
30 if (!api) return 4;
31 if (api->abiversion<10) return 5;
32 return 0;