File: TestVMD.cpp

package info (click to toggle)
gromacs 2026.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 274,304 kB
  • sloc: xml: 3,831,921; cpp: 686,728; ansic: 75,300; python: 21,171; sh: 3,553; perl: 2,246; yacc: 644; fortran: 397; lisp: 265; makefile: 179; lex: 125; awk: 68; csh: 39
file content (33 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "molfile_plugin.h"
#include "vmddlopen.cpp"
#include "stdio.h"

static int register_cb(void *v, vmdplugin_t *p) {
    *(molfile_plugin_t**)v = (molfile_plugin_t *)p;
    return VMDPLUGIN_SUCCESS;
}

typedef int (*initfunc)(void);
typedef int (*regfunc)(void *, vmdplugin_register_cb);

/*run: gcc TestVMD.cpp -DGMX_USE_PLUGINS -Wall -ldl -I../src/external/vmd_molfile  -lm && ./a.out .../xyzplugin.so ; echo $?*/
int main(int argc, char** argv)
{
    void *handle, *ifunc, *registerfunc;
    molfile_plugin_t* api;
    if (argc!=2) return -1;
    handle = vmddlopen(argv[1]);
    if (!handle)
    {
        fprintf(stderr,"%s\n",vmddlerror());
        return 1;
    }
    ifunc = vmddlsym(handle, "vmdplugin_init");
    if (!ifunc || ((initfunc)(ifunc))()) return 2;
    registerfunc = vmddlsym(handle, "vmdplugin_register");
    if (!registerfunc) return 3;
    ((regfunc)registerfunc)(&api, register_cb);
    if (!api) return 4;
    if (api->abiversion<10) return 5;
    return 0;
}