#include #include /* this is a way to communicate XPP with other stuff # complex right-hand sides # let xpp know about the names xp=0 yp=0 x'=xp y'=yp # tell xpp input info and output info export {x,y} {xp,yp} */ #include #include #define PAR 0 #define VAR 1 char dll_lib[256]; char dll_fun[256]; int dll_flag=0; typedef struct { char *lin,*lout; int *in,*intype; int *out,*outtype; int nin,nout; double *vin,*vout; } IN_OUT; IN_OUT in_out; extern double variables[], constants[]; extern char cur_dir[]; typedef struct { char libname[1024]; char libfile[256]; char fun[256]; int loaded; } DLFUN; DLFUN dlf; #ifdef HAVEDLL /* this loads a dynamically linked library of the users choice */ #include void *dlhandle; double (*fun)(); auto_load_dll() { if(dll_flag==3){ get_directory(cur_dir); printf("DLL lib %s/%s with function %s \n",cur_dir,dll_lib,dll_fun); sprintf(dlf.libfile,"%s",dll_lib); sprintf(dlf.libname,"%s/%s",cur_dir,dlf.libfile); sprintf(dlf.fun,"%s",dll_fun); dlf.loaded=0; } } load_new_dll() { int status; if(dlf.loaded!=0&&dlhandle!=NULL) dlclose(dlhandle); status=file_selector("Library:",dlf.libfile,"*.so"); if(status==0)return; sprintf(dlf.libname,"%s/%s",cur_dir,dlf.libfile); new_string("Function name:",dlf.fun); dlf.loaded=0; } my_fun(double *in, double *out, int nin,int nout,double *v,double *c) { char *error; if(dlf.loaded==-1)return; if(dlf.loaded==0){ dlhandle=dlopen (dlf.libname, RTLD_LAZY); if(!dlhandle){ printf(" Cant find the library \n"); dlf.loaded=-1; return 0; } fun=dlsym(dlhandle,dlf.fun); error=dlerror(); if(error!= NULL){ printf("Problem with function..\n"); dlf.loaded=-1; return 0; } dlf.loaded=1; } /* Ok we have a nice function */ fun(in,out,nin,nout,v,c); } #else load_new_dll() { } my_fun(double *in, double *out, int nin,int nout,double *v,double *c) { } auto_load_dll() { } #endif do_in_out() { int i; if(in_out.nin==0||in_out.nout==0)return; for(i=0;istrlen(l)) done=0; } }