#pragma implementation #include #include #include #include "graph.h" #include "graph.m" #include "schema.h" static SCHEMA_REGISTER *first; PUBLIC SCHEMA_REGISTER::SCHEMA_REGISTER (const char *_title, void (*_f)(int rotate)) { title.setfrom (_title); f = _f; next = first; first = this; } PUBLIC const char *SCHEMA_REGISTER::gettitle () const { return title.get(); } PUBLIC SCHEMA_REGISTER *SCHEMA_REGISTER::getnext () const { return next; } PUBLIC void SCHEMA_REGISTER::exec (int rotate) const { f(rotate); } int main (int argc, char *argv[]) { glocal int rotate = 0; glocal bool list = false; glocal SSTRING povfile; glocal SSTRING tgafile; (argc, argv,"tlmpwork"); setproginfo ("schema","0.0",MSG_U(I_SCHEMA ,"schema object drawing\n" "\n" "object is a shared object (a .so file) containing multiple\n" "drawings.\n" "\n" "drawing is one of those.\n" )); setarg ('l',"list",MSG_U(I_LIST,"Lists the drawing in the object file"),glocal.list,false); setarg ('p',"povfile",MSG_U(I_POVFILE,"PovRay file to produce"),glocal.povfile,false); setarg ('r',"rotate",MSG_U(I_ROTATE,"Rotate camera around X"),glocal.rotate,false); setarg ('t',"tgafile",MSG_U(I_TGAFILE,"TGA file (produced by povray)"),glocal.tgafile,false); int ret = -1; if (argc == 0){ usage(); }else{ void *h = dlopen (argv[0],RTLD_LAZY); if (h == NULL){ tlmp_error (MSG_U(E_NOOBJECT,"No object file %s\n%s\n") ,argv[0],dlerror()); }else if (glocal.list){ SCHEMA_REGISTER *pt = first; while (pt != NULL){ printf ("%s\n",pt->gettitle()); pt = pt->getnext(); } }else{ ret = 0; for (int i=1; igettitle())==0){ pt->exec(glocal.rotate); break; } pt = pt->getnext(); } if (pt == NULL){ tlmp_error (MSG_U(E_NODRAWING,"No drawing %s in object %s\n") ,argv[i],argv[0]); } } } } return ret; }