/***************************************************************************/ /***** portable Virtual Device Interface ***********************************/ /***************************************************************************/ #include #include typedef struct { /*int device; */ char *note; /* pVDI functions */ int (*init) (); int (*exit) (); int (*getch) (); int (*clear) (); int (*refresh) (); int (*move) (); int (*print) (); } pVDIdevice; static pVDIdevice *pVDI; /***** currently available pVDI devices ************************************/ #include "dev/null.dev" #include "dev/curses.dev" #include "dev/vt52.dev" #include "dev/glyphs.dev" static pVDIdevice pVDItable[] = { {NULLnote, NULLfunc, NULLfunc, NULLfunc, NULLfunc, NULLfunc, NULLfunc, NULLfunc}, {CURSnote, CURSinit, CURSexit, CURSgetch, CURSclear, CURSrefresh, CURSmove, CURSprint}, {VT52note, VT52init, VT52exit, VT52getch, VT52clear, VT52refresh, VT52move, VT52print}, {GLPHnote, GLPHinit, GLPHexit, GLPHgetch, GLPHclear, GLPHrefresh, GLPHmove, GLPHprint} }; #define pVDI_DEVICES (sizeof(pVDItable)/sizeof(pVDIdevice)) /***** initialization ******************************************************/ void InitpVDI (device) int device; { va_list args; va_start (args, device); if (device >= 0 && device < pVDI_DEVICES) { pVDI = (pVDIdevice *) & pVDItable[device]; fprintf (stderr, "%s. (#%d of %d devs available)\n", pVDI->note, device, pVDI_DEVICES); (*pVDI->init) (args); } else { fprintf (stderr, "No such pVDI device: %d. Abort.\n", device); exit (-1); } va_end (args); } void ExitpVDI () { (*pVDI->exit) (); } /***** input ***************************************************************/ int getchpVDI () { return ((*pVDI->getch) ()); } /***** output **************************************************************/ void printpVDI (fmt) char *fmt; { va_list args; va_start (args, fmt); (*pVDI->print) (fmt, args); va_end (args); } void clearpVDI () { (*pVDI->clear) (); } void refreshpVDI () { (*pVDI->refresh) (); } void movepVDI (y, x) int y, x; { (*pVDI->move) (y, x); }