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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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 */
|