Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libcoshell/colib.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1990-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Research
24
*
25
* coshell library private definitions
26
*/
27
28
#ifndef _COLIB_H
29
#define _COLIB_H
30
31
#include <ast.h>
32
#include <dt.h>
33
#include <vmalloc.h>
34
35
#define _CO_JOB_PRIVATE_ /* Cojob_t private additions */ \
36
Cojob_t* next; /* next in list */ \
37
Coservice_t* service; /* service */ \
38
int pid; /* pid */ \
39
char* out; /* serialized stdout file */ \
40
char* err; /* serialized stderr file */ \
41
/* end of private additions */
42
43
#define _CO_SHELL_PRIVATE_ /* Coshell_t private additions */ \
44
Vmalloc_t* vm; /* Coshell_t vm */ \
45
Coshell_t* next; /* next in list */ \
46
Cojob_t* jobs; /* job list */ \
47
Coservice_t* service; /* service */ \
48
Dt_t* export; /* coexport() dictionary */ \
49
Dtdisc_t* exdisc; /* coexport() discipline */ \
50
struct Coinit_s /* initialization script state */ \
51
{ \
52
char* script; /* initialization script */ \
53
dev_t pwd_dev; /* previous pwd dev */ \
54
ino_t pwd_ino; /* previous pwd inode number */ \
55
int mask; /* previous umask */ \
56
int sync; /* sync script */ \
57
} init; \
58
int cmdfd; /* command pipe fd */ \
59
int gsmfd; /* msgfp child write side */ \
60
int mask; /* CO_* flags to clear */ \
61
int mode; /* connection modes */ \
62
int svc_outstanding;/* outstanding service intercepts */ \
63
int svc_running; /* running service intercepts */ \
64
int pid; /* pid */ \
65
int index; /* coshell index */ \
66
int slots; /* number of job slots */ \
67
/* end of private additions */
68
69
typedef struct Coexport_s
70
{
71
Dtlink_t link;
72
char* value;
73
char name[1];
74
} Coexport_t;
75
76
struct Coservice_s;
77
typedef struct Coservice_s Coservice_t;
78
79
struct Coservice_s /* service info */
80
{
81
Coservice_t* next; /* next in list */
82
char* name; /* instance name */
83
char* path; /* coexec() command path */
84
char* db; /* state/db path */
85
int fd; /* command pipe */
86
int pid; /* pid */
87
char* argv[16]; /* coexec() command argv[] */
88
};
89
90
#include <coshell.h>
91
#include <error.h>
92
#include <sig.h>
93
#include <wait.h>
94
95
#define state _coshell_info_ /* hide external symbol */
96
97
#define CO_MODE_ACK (1<<0) /* wait for coexec() ack */
98
#define CO_MODE_INDIRECT (1<<1) /* indirect CO_SERVER */
99
#define CO_MODE_SEPARATE (1<<2) /* 1 shell+wait per action */
100
101
#define CO_INIT (CO_USER>>1) /* initial command */
102
103
#define CO_PID_FREE (-3) /* free job slot */
104
#define CO_PID_WARPED (-2) /* exit before start message */
105
#define CO_PID_ZOMBIE (-1) /* ready for wait */
106
107
#define CO_BUFSIZ (PATH_MAX/2) /* temporary buffer size */
108
#define CO_MAXEVAL (PATH_MAX*8) /* max eval'd action size */
109
110
typedef struct Costate_s /* global coshell state */
111
{
112
const char* lib; /* library id */
113
Coshell_t* coshells; /* list of all coshells */
114
Coshell_t* current; /* current coshell */
115
Coshell_t* generic; /* generic coshell for coinit() */
116
char* pwd; /* pwd */
117
char* sh; /* sh from first coopen() */
118
char* type; /* CO_ENV_TYPE value */
119
int init; /* 0 if first coopen() */
120
int index; /* last coshell index */
121
} Costate_t;
122
123
extern char coident[]; /* coshell ident script */
124
extern char cobinit[]; /* bsh initialition script */
125
extern char cokinit[]; /* ksh initialition script */
126
extern char* co_export[]; /* default export var list */
127
128
extern Costate_t state; /* global coshell info */
129
130
#ifndef errno
131
extern int errno;
132
#endif
133
134
extern char* costash(Sfio_t*);
135
extern char* coinitialize(Coshell_t*, int);
136
137
#endif
138
139