1 #include "molfile_plugin.h"
2 #include "vmddlopen.cpp"
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.cpp -DGMX_USE_PLUGINS -Wall -ldl -I../src/external/vmd_molfile -lm && ./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]);
22 fprintf(stderr
,"%s\n",vmddlerror());
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
);
31 if (api
->abiversion
<10) return 5;