diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2016-10-25 20:57:49 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2016-10-25 20:57:49 (GMT) |
commit | d1c4bf158203c4e8ec29fdeb83fd311e36320885 (patch) | |
tree | 15874534e282f67505ce4af5ba805a1ff70ec43e /funtools/util/mainlib.h | |
parent | e19a18e035dc4d0e8e215f9b452bb9ef6f58b9d7 (diff) | |
parent | 339420dd5dd874c41f6bab5808291fb4036dd022 (diff) | |
download | blt-d1c4bf158203c4e8ec29fdeb83fd311e36320885.zip blt-d1c4bf158203c4e8ec29fdeb83fd311e36320885.tar.gz blt-d1c4bf158203c4e8ec29fdeb83fd311e36320885.tar.bz2 |
Merge commit '339420dd5dd874c41f6bab5808291fb4036dd022' as 'funtools'
Diffstat (limited to 'funtools/util/mainlib.h')
-rw-r--r-- | funtools/util/mainlib.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/funtools/util/mainlib.h b/funtools/util/mainlib.h new file mode 100644 index 0000000..3e4534d --- /dev/null +++ b/funtools/util/mainlib.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory + */ + +/* + * + * mainlib.h + * + */ + +#ifndef __mainlib_h +#define __mainlib_h + +#if HAVE_CONFIG_H +#include "conf.h" +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#if HAVE_MALLOC_H +#include <malloc.h> +#endif +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif +#if HAVE_DLFCN_H +#include <dlfcn.h> +#endif +#include <stdio.h> +#include <errno.h> +#include <sys/types.h> +#include "prsetup.h" +#include "xalloc.h" +#include "word.h" +#include "find.h" +#include "gio.h" + +/* types of mainlibs we recognize */ +#define MAINLIB_ERROR 0 +#define MAINLIB_ARGV 1 +#define MAINLIB_EXTN 2 +#define MAINLIB_TCL 3 + +/* max values */ +#define MAINLIB_CMDS 32 +#define MAINLIB_ARGS 32 + +/* defines the types of callback procedure we use */ +typedef int (*MainLibProc)( +#ifdef ANSI_FUNC + int argc, + char **argv +#endif +); + +/* define init call */ +typedef void *(*MainLibInitCall)( +#ifdef ANSI_FUNC + void +#endif +); + +/* define proc call */ +typedef int (*MainLibProcessCall)( +#ifdef ANSI_FUNC + void *ml, char *cmd, char **buf, char *mode +#endif +); + +/* define Tcl lookup call */ +typedef int (*MainLibTclLookup)( +#ifdef ANSI_FUNC + void *interp, char *s +#endif +); + +/* define Tcl eval call */ +typedef int (*MainLibTclEval)( +#ifdef ANSI_FUNC + void *interp, char *s +#endif +); + +/* + * + * + * mainlib record structure for a single command + * + */ +typedef struct mainlibentryrec{ + struct mainlibentryrec *next; + char *xclass; + char *name; + MainLibProc proc; + int type; +} *MainLibEntry, MainLibEntryRec; + +/* + * + * + * mainlib record structure for a group of commands + * + */ +typedef struct mainlibrec{ + MainLibEntry head; + void *dl; + MainLibProcessCall mainlibprocess; + MainLibTclLookup tcllookup; + MainLibTclEval tcleval; + int npid; + pid_t pids[MAINLIB_CMDS+1]; +} *MainLib, MainLibRec; + +/* library declarations */ +_PRbeg + +/* public */ +int MainLibLoad _PRx((char *name, char *shlib, void **ml, char **ermsg)); +MainLib MainLibNew _PRx((void)); +MainLibEntry MainLibAdd _PRx((MainLib ml, char *xclass, char *name, + MainLibProc mainlibproc, int type)); +int MainLibProcess _PRx((MainLib ml, char *cmd, char **buf, char *mode)); +int MainLibProcessCleanup _PRx((MainLib ml)); +int MainLibDel _PRx((MainLib ml, MainLibEntry mle)); +int MainLibFree _PRx((MainLib ml)); + +_PRend + +#endif /* __mainlib.h */ + |