#pragma prototyped
#define LABELLEN 64
#define NAMELEN 64
#define TYPELEN 64
#define MISCLEN 256
#define _CO_JOB_PRIVATE_ \
char label[LABELLEN]; \
int pid; \
int rid; \
int sig; \
int fd; \
int ref; \
char* cmd; \
Coshell_t* shell; \
unsigned long busy; \
unsigned long lost; \
unsigned long start; \
#define _CO_SHELL_PRIVATE_ \
Coshell_t* next; \
char name[NAMELEN]; \
char type[TYPELEN]; \
char misc[MISCLEN]; \
char remote[MISCLEN]; \
char shell[MISCLEN]; \
char* access; \
char* bypass; \
unsigned long addr; \
unsigned long rank; \
unsigned long temp; \
int mode; \
int bias; \
int cpu; \
int errors; \
int fd; \
int home; \
int idle; \
int idle_override; \
int pid; \
int open; \
int rating; \
int scale; \
Cs_stat_t stat; \
unsigned long override; \
unsigned long start; \
unsigned long update; \
#include <ast.h>
#include <cs.h>
#include <coshell.h>
#include <ctype.h>
#include <debug.h>
#include <error.h>
#include <sig.h>
#include <tm.h>
#include <tok.h>
#include <wait.h>
#define match(p,a,o) ((!((a)->set&SETNAME)||strmatch((p)->name,(a)->name))&&((((a)->set|o)&(SETMISC|DEF|NEW|SET))==SETMISC?miscmatch(p,(a)->misc):((a)->set&SETNAME)?1:streq((p)->type,state.home->type)))
#define SHELL_CLOSE (1<<0)
#define SHELL_DENIED (1<<1)
#define SHELL_DISABLE (1<<2)
#define SHELL_OVERRIDE (1<<3)
#define ACCESS_SEARCH (60*60)
#define ACCESS_UPDATE (10*60)
#define BIAS 100
#define BUSY ((UPDATE)*2)
#define CHUNK 1024
#define ERRORS 8
#define FORGET (5*LOST)
#define GRACE BUSY
#define HOG (~0L)
#define HOME (3*OVERRIDE)
#define LOAD 100
#define LOST (1*60)
#define OVERRIDE (2*60)
#define POOL 8
#define RANK 30000
#define RATING 100
#define TEMPBASE 32
#define TOSS CSTOSS(state.toss,0)
#define UPDATE ((6*CS_STAT_FREQ)/5)
#define COMMAND 1
#define DEFER 2
#define SERVER 3
#define ANON 1
#define DEST 2
#define IDENT 3
#define INIT 4
#define MESG 5
#define PASS 6
#define POLL 7
#define PUMP 8
#define SCHED 9
#define SHELL 10
#define UCMD 11
#define UERR 12
#define UOUT 13
#define USER 14
#define USER_DUP (1<<0)
#define USER_IDENT (1<<1)
#define USER_INIT (1<<2)
#define DEF (1<<0)
#define GET (1<<1)
#define IGN (1<<2)
#define JOB (1<<3)
#define NEW (1<<4)
#define SET (1<<5)
#define SETACCESS (1<<6)
#define SETBIAS (1<<7)
#define SETBYPASS (1<<8)
#define SETCPU (1<<9)
#define SETIDLE (1<<10)
#define SETIGNORE (1<<11)
#define SETLABEL (1<<12)
#define SETMISC (1<<13)
#define SETNAME (1<<14)
#define SETRATING (1L<<15)
#define SETSCALE (1L<<16)
#define SETTYPE (1L<<17)
#define SETBUSY (1<<0)
#define SETDEBUG (1<<1)
#define SETDISABLE (1<<2)
#define SETFILE (1<<3)
#define SETGRACE (1<<4)
#define SETIDENTIFY (1<<5)
#define SETLOAD (1<<6)
#define SETMAXIDLE (1<<7)
#define SETMAXLOAD (1<<8)
#define SETMIGRATE (1<<9)
#define SETPERCPU (1<<10)
#define SETPERHOST (1<<11)
#define SETPERSERVER (1<<12)
#define SETPERUSER (1<<13)
#define SETPOOL (1<<14)
#define SETPROFILE (1L<<15)
#define SETSCHEDULE (1L<<16)
#define SETUPDATE (1L<<17)
#define SETUSERS (1L<<18)
#define SETREMOTE (1L<<29)
#define SETSHELL (1L<<30)
#define QUEUE (-1)
#define START (-2)
#define WARP (-3)
typedef struct
{
char name[NAMELEN];
char type[TYPELEN];
char misc[MISCLEN];
char label[LABELLEN];
char remote[MISCLEN];
char shell[MISCLEN];
char* access;
char* bypass;
int bias;
int cpu;
int idle;
int ignore;
int rating;
int scale;
unsigned long set;
struct
{
char* file;
char* identify;
char* migrate;
char* profile;
char* remote;
char* schedule;
char* shell;
int busy;
int debug;
unsigned long disable;
int grace;
int maxidle;
int maxload;
int percpu;
int perhost;
int perserver;
int peruser;
int pool;
unsigned long set;
} global;
Cs_stat_t stat;
} Coattr_t;
typedef struct
{
Coshell_t* shell;
int pid;
} Coident_t;
typedef struct
{
Cojob_t* job;
Sfio_t* serialize;
short fd;
} Copass_t;
typedef struct
{
Coshell_t* home;
char* pump;
char* expr;
Coattr_t attr;
short fds[3];
short flags;
short pid;
short running;
short total;
} Couser_t;
typedef struct
{
union
{
Coident_t ident;
Copass_t pass;
Coshell_t* shell;
Couser_t user;
} info;
short type;
short error;
short flags;
} Connection_t;
typedef struct
{
int con;
int cmd;
int err;
int msg;
int out;
char* pump;
} Indirect_t;
typedef struct
{
unsigned long access;
char** argv;
char* buf;
int buflen;
unsigned long busy;
Pathcheck_t check;
unsigned long clock;
int cmds;
Connection_t* con;
int connect;
unsigned long disable;
int fdtotal;
gid_t* gids;
unsigned long grace;
Coshell_t* home;
char* identify;
Indirect_t indirect;
Cojob_t* job;
Cojob_t* jobmax;
Cojob_t* jobnext;
int jobs;
int joblimit;
int jobwait;
int maxidle;
int maxload;
char* mesg;
char* migrate;
int open;
int override;
int percpu;
int perhost;
int perserver;
int peruser;
int pool;
char* profile;
char* pump;
unsigned long real;
char* remote;
int running;
struct
{
char* name;
int fd;
} scheduler;
char* service;
int set;
char* sh;
Coshell_t* shell;
Coshell_t* shellnext;
int shellc;
int shelln;
int shells;
Coshell_t** shellv;
int shellwait;
unsigned long start;
Sfio_t* string;
unsigned long sys;
unsigned long toss;
unsigned long user;
unsigned long wakeup;
Tm_t* tm;
uid_t uid;
int users;
char* version;
Coshell_t wait;
} State_t;
extern const char corinit[];
extern State_t state;
extern void attributes(char*, Coattr_t*, Coattr_t*);
extern int byname(const char*, const char*);
extern int byrank(const char*, const char*);
extern int bytemp(const char*, const char*);
extern int command(int, char**);
extern void drop(int);
extern char* fmtfloat(int);
extern Coshell_t* info(int, char*);
extern void jobcheck(Coshell_t*);
extern void jobdone(Cojob_t*);
extern void jobkill(Cojob_t*, int);
extern void miscadd(Coshell_t*, char*);
extern int miscmatch(Coshell_t*, char*);
extern Coshell_t* search(int, char*, Coattr_t*, Coattr_t*);
extern void server(int, int, int, int, char*);
extern void shellcheck(void);
extern void shellclose(Coshell_t*, int);
extern void shellexec(Cojob_t*, char*, int);
extern int shellopen(Coshell_t*, int);
extern char* stream(int, char*);
extern void update(Coshell_t*);