/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1990-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*24* coshell library private definitions25*/2627#ifndef _COLIB_H28#define _COLIB_H2930#include <ast.h>31#include <dt.h>32#include <vmalloc.h>3334#define _CO_JOB_PRIVATE_ /* Cojob_t private additions */ \35Cojob_t* next; /* next in list */ \36Coservice_t* service; /* service */ \37int pid; /* pid */ \38char* out; /* serialized stdout file */ \39char* err; /* serialized stderr file */ \40/* end of private additions */4142#define _CO_SHELL_PRIVATE_ /* Coshell_t private additions */ \43Vmalloc_t* vm; /* Coshell_t vm */ \44Coshell_t* next; /* next in list */ \45Cojob_t* jobs; /* job list */ \46Coservice_t* service; /* service */ \47Dt_t* export; /* coexport() dictionary */ \48Dtdisc_t* exdisc; /* coexport() discipline */ \49struct Coinit_s /* initialization script state */ \50{ \51char* script; /* initialization script */ \52dev_t pwd_dev; /* previous pwd dev */ \53ino_t pwd_ino; /* previous pwd inode number */ \54int mask; /* previous umask */ \55int sync; /* sync script */ \56} init; \57int cmdfd; /* command pipe fd */ \58int gsmfd; /* msgfp child write side */ \59int mask; /* CO_* flags to clear */ \60int mode; /* connection modes */ \61int svc_outstanding;/* outstanding service intercepts */ \62int svc_running; /* running service intercepts */ \63int pid; /* pid */ \64int index; /* coshell index */ \65int slots; /* number of job slots */ \66/* end of private additions */6768typedef struct Coexport_s69{70Dtlink_t link;71char* value;72char name[1];73} Coexport_t;7475struct Coservice_s;76typedef struct Coservice_s Coservice_t;7778struct Coservice_s /* service info */79{80Coservice_t* next; /* next in list */81char* name; /* instance name */82char* path; /* coexec() command path */83char* db; /* state/db path */84int fd; /* command pipe */85int pid; /* pid */86char* argv[16]; /* coexec() command argv[] */87};8889#include <coshell.h>90#include <error.h>91#include <sig.h>92#include <wait.h>9394#define state _coshell_info_ /* hide external symbol */9596#define CO_MODE_ACK (1<<0) /* wait for coexec() ack */97#define CO_MODE_INDIRECT (1<<1) /* indirect CO_SERVER */98#define CO_MODE_SEPARATE (1<<2) /* 1 shell+wait per action */99100#define CO_INIT (CO_USER>>1) /* initial command */101102#define CO_PID_FREE (-3) /* free job slot */103#define CO_PID_WARPED (-2) /* exit before start message */104#define CO_PID_ZOMBIE (-1) /* ready for wait */105106#define CO_BUFSIZ (PATH_MAX/2) /* temporary buffer size */107#define CO_MAXEVAL (PATH_MAX*8) /* max eval'd action size */108109typedef struct Costate_s /* global coshell state */110{111const char* lib; /* library id */112Coshell_t* coshells; /* list of all coshells */113Coshell_t* current; /* current coshell */114Coshell_t* generic; /* generic coshell for coinit() */115char* pwd; /* pwd */116char* sh; /* sh from first coopen() */117char* type; /* CO_ENV_TYPE value */118int init; /* 0 if first coopen() */119int index; /* last coshell index */120} Costate_t;121122extern char coident[]; /* coshell ident script */123extern char cobinit[]; /* bsh initialition script */124extern char cokinit[]; /* ksh initialition script */125extern char* co_export[]; /* default export var list */126127extern Costate_t state; /* global coshell info */128129#ifndef errno130extern int errno;131#endif132133extern char* costash(Sfio_t*);134extern char* coinitialize(Coshell_t*, int);135136#endif137138139