home *** CD-ROM | disk | FTP | other *** search
- /* DRIVER.C */
- static char sccsid[] = "@(#)driver.c 1.2 94/01/20 (c)1993 thalerd";
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #ifndef NeXT
- #include <unistd.h>
- #endif
- #include <sys/types.h>
- #include <sys/file.h>
- #include <sys/stat.h>
- #include <signal.h>
- #include <pwd.h>
- #include "config.h"
- #include "struct.h"
- #include "driver.h"
- #include "xalloc.h"
- #include "lib.h"
- #include "macro.h"
- #include "joq.h"
- #include "rfp.h"
- #include "change.h"
- #include "item.h" /* needed by sep.h */
- #include "sep.h"
- #include "help.h"
- #include "conf.h"
- #include "system.h"
- #include "files.h"
- #include "sum.h" /* for refresh_list */
- #include "edbuf.h" /* for text_cmd_dispatch */
- #include "misc.h" /* for misc_cmd_dispatch */
-
- /* GLOBAL VARS */
-
- /* Status info */
- flag_t flags =0; /* user settable parameter flags */
- unsigned char mode =M_OK; /* input mode (which prompt) */
- flag_t status=0; /* system status flags */
-
- /* Conference info */
- short current = -1; /* current index to cflist */
- short confidx = -1; /* current index to conflist */
- short defidx = -1;
- short joinidx = -1; /* current index to conflist */
- char confname[MAX_LINE_LENGTH]; /* name of current conference */
- char **cflist = (char **)0; /* User's conflist */
- char **fw; /* List of FW's for current conf */
- partentry_t part[MAX_ITEMS]; /* User participation info */
-
- /* System info */
- char bbsdir[MAX_LINE_LENGTH]; /* Directory for bbs files */
- char helpdir[MAX_LINE_LENGTH]; /* Directory for help files */
- assoc_t conflist[MAX_LIST_LENGTH]; /* System table of conferences */
- short maxconf=0; /* maximum index to conflist */
- char hostname[MAX_LINE_LENGTH]; /* System host name */
-
- /* Info on the user */
- uid_t uid; /* User's UID */
- char login[L_cuserid]; /* User's login */
- char home[MAX_LINE_LENGTH]; /* User's home directory */
- char work[MAX_LINE_LENGTH]; /* User's work directory */
-
- /* Item statistics */
- status_t st_glob; /* statistics on current conference */
- status_t st_new; /* statistics on new conference to join */
- sumentry_t sum[MAX_ITEMS]; /* items in current conference */
- response_t re[MAX_RESPONSES]; /* responses to current item */
-
- /* Variables global to this module only */
- static char cmdbuf[MAX_LINE_LENGTH];
- char pipebuf[MAX_LINE_LENGTH];
- char evalbuf[MAX_LINE_LENGTH];
- static char *options="dulosnj:"; /* Command-line options */
- option_t option[]={ /* User-definable flags */
- /* name, mask, default, */
- "debug", O_DEBUG, DEFAULT_OFF,
- "buffer", O_BUFFER, DEFAULT_ON,
- "default", O_DEFAULT, DEFAULT_ON,
- "observe", O_OBSERVE, DEFAULT_OFF,
- "st_rip", O_STRIP, DEFAULT_OFF,
- "so_urce", O_SOURCE, DEFAULT_ON,
- "f_orget", O_FORGET, DEFAULT_ON,
- "sta_y", O_STAY, DEFAULT_OFF,
- "dot", O_DOT, DEFAULT_ON,
- "ed_always", O_EDALWAYS, DEFAULT_OFF,
- "me_too", O_METOO, DEFAULT_ON,
- "nu_mbered", O_NUMBERED, DEFAULT_OFF,
- "d_ate", O_DATE, DEFAULT_OFF,
- "u_id", O_UID, DEFAULT_OFF,
- "ma_iltext", O_MAILTEXT, DEFAULT_OFF,
- "autosave", O_AUTOSAVE, DEFAULT_OFF,
- "verbose", O_VERBOSE, DEFAULT_OFF,
- "scr_ibbler",O_SCRIBBLER, DEFAULT_OFF,
- "sig_niture",O_SIGNITURE, DEFAULT_OFF,
- "readonly", O_READONLY, DEFAULT_OFF
- };
-
- void
- open_pipe()
- {
- char *pager,*p;
-
- /* Need to check if pager exists */
- if (!(status & S_REDIRECT)) {
- if (!pipebuf[0]) strcpy(pipebuf,expand("pager",DM_VAR));
-
- /* Compress it a bit */
- pager=pipebuf;
- while (*pager && *pager==' ') pager++; /* skip leading/trailing spaces */
- for (p=pager+strlen(pager)-1; *p==' ' && p>=pager; p--) *p='\0';
- if (*pager=='"') {
- pager++;
- if (p>=pager && *p=='"') { *p='\0'; p--; }
- }
- if (*pager=='\'') {
- pager++;
- if (p>=pager && *p=='\'') { *p='\0'; p--; }
- }
-
- if (!(flags & O_BUFFER)
- || (pager[0] && (st_glob.outp =spopen(pager))==NULL))
- pager[0]='\0';
- if (!pager[0])
- st_glob.outp =stdout;
- }
- }
-
- /******************************************************************************/
- /* PRINT PROMPT FOR AN INPUT MODE */
- /******************************************************************************/
- void /* RETURNS: (nothing) */
- print_prompt(mod) /* ARGUMENTS: */
- unsigned char mod; /* Input mode */
- {
- char *str;
-
- switch(mod & M_MASK) {
- case M_OK : /* In a conference or not? */
- str = (confidx<0) ? "noconfp" : "prompt";
- break;
- case M_RFP: str = (st_glob.c_status & (CS_OBSERVER|CS_NORESPONSE))?
- "obvprompt":"rfpprompt";
- break;
- case M_TEXT: str="text"; break;
- case M_JOQ: str="joqprompt"; break;
- case M_EDB: str="edbprompt"; break;
- }
- if (flags & O_DEBUG) printf("!%s!\n",str);
- confsep(str,confidx,&st_glob,part,1); /* expand seps & print */
- }
-
- /******************************************************************************/
- /* COMMAND LOOP: PRINT PROMPT & GET RESPONSE */
- /******************************************************************************/
- char /* RETURNS: 0 on eof, 1 else */
- get_command(def) /* ARGUMENTS: */
- char *def; /* Default command (if any) */
- {
- char ok=1,inbuff[MAX_LINE_LENGTH],*inb;
-
- if (status & S_INT) status &= ~S_INT; /* Clear interrupt */
- if (status & S_REDIRECT) spclose(st_glob.outp );
- if (cmdbuf[0]) strcpy(inbuff,cmdbuf);
- else {
- print_prompt(mode);
- if (mode==M_OK) status &= ~S_STOP;
- }
- if (cmdbuf[0] || (ok = (ngets(inbuff,st_glob.inp)!=NULL))) {
-
- /* Strip leading & trailing spaces */
- for (inb=inbuff+strlen(inbuff)-1; inb>=inbuff && *inb==' '; inb--) *inb=0;
- for (inb=inbuff; *inb==' '; inb++);
-
- if (!*inb) ok = command(def,0);
- else ok = command(inb,0);
- }
- return ok;
- }
-
- /******************************************************************************/
- /* CLEAN UP MEMORY AND EXIT */
- /******************************************************************************/
- void /* RETURNS: (nothing) */
- endbbs(ret) /* ARGUMENTS: */
- int ret; /* Exit status */
- {
- int i;
-
- if (flags & O_DEBUG) printf("endbbs:\n");
- if (confidx>=0) leave(0,(char**)0); /* leave current conference */
-
- /* Free up space, etc */
- for (i=0; i<maxconf; i++) {
- xfree(conflist[i].name);
- xfree(conflist[i].location);
- }
- for (i=0; i<MAX_RESPONSES; i++) {
- if (re[i].login) { xfree(re[i].login); re[i].login =0; }
- if (re[i].fullname) { xfree(re[i].fullname); re[i].fullname=0; }
- #ifdef NEWS
- if (re[i].mid) { xfree(re[i].mid); re[i].mid =0; }
- #endif
- }
- clear_cache(); /* throw out stat cache */
- undefine(~0); /* undefine all macros */
- xfree(cflist);
- mcheck(); /* verify that files are closed */
- xcheck(); /* verify that memory is clean */
- (void)exit(ret);
- }
-
- void
- open_cluster(bdir,hdir)
- char *bdir, /* BBSDIR */
- *hdir; /* HELPDIR */
- {
- short i;
-
- /* Free up space, etc */
- for (i=0; i<maxconf; i++) {
- xfree(conflist[i].name);
- xfree(conflist[i].location);
- }
-
- /* Read in /usr/bbs/conflist */
- strcpy(bbsdir,bdir);
- strcpy(helpdir,hdir);
- if (!grab_list(bbsdir,"conflist",conflist,&maxconf))
- endbbs(2);
- for (i=1; i<maxconf; i++)
- if (!strcmp(conflist[0].location,conflist[i].location)
- || match(conflist[0].location,conflist[i].name)) defidx=i;
- if (defidx<0) printf("Warning: bad default conference\n");
-
- /* Source system rc file */
- mode = M_SUPERSANE;
- source(bbsdir,"rc");
- mode = M_OK;
- }
-
- /******************************************************************************/
- /* PROCESS COMMAND LINE ARGUMENTS */
- /******************************************************************************
- Function: init
- Called by: main
- Arguments:
- Returns:
- Calls: source for .cfonce and system rc
- grab_file to get .cflist and conflist
- Description: Sets up global variables, i.e. uid, login, envars,
- workdir, processes rc file for system and for user
- ******************************************************************************/
- void /* RETURNS: (nothing) */
- init(argc,argv) /* ARGUMENTS: */
- int argc; /* Number of command-line arguments */
- char **argv; /* Command-line argument list */
- {
- short c,o,i;
- struct passwd *pwd;
- extern char *optarg;
- extern int optind,opterr;
- char **namestr,buff[MAX_LINE_LENGTH];
- char mbox[MAX_LINE_LENGTH],*mail;
- struct sigvec vec;
-
- /* Print identification */
-
- /* Start up interrupt handling *
- for (c=1; c<=32; c++)
- signal(c, handle_other);
- * */
- signal(SIGINT, handle_int);
- signal(SIGPIPE, handle_pipe);
- /* *
- signal(SIGINT, handle_other);
- signal(SIGPIPE, handle_other);
- * */
- sigvec(SIGINT, NULL, &vec);
- vec.sv_flags &= ~SV_INTERRUPT;
- sigvec(SIGINT, &vec, NULL);
-
- /* Initialize options */
- for (o=0; o<sizeof(option)/sizeof(option_t); o++)
- flags |= option[o].deflt * option[o].mask;
-
- /* Set up user variables */
- cmdbuf[0] = pipebuf[0] = evalbuf[0] = '\0';
- st_glob.c_status = 0;
- #ifdef NEWS
- st_glob.c_article = 0;
- #endif
- st_glob.inp = stdin;
- uid = getuid();
- if (!(pwd = getpwuid(uid))) {
- error("reading ","user entry");
- endbbs(2);
- }
- strcpy(login, pwd->pw_name);
- strcpy(st_glob.fullname,pwd->pw_gecos);
- strcpy(home, pwd->pw_dir);
- if (access(home,X_OK)) {
- error("accessing ",home);
- endbbs(2);
- }
- sprintf(work,"%s/.cfdir",home);
- if (access(work,X_OK)) strcpy(work,home);
- strcpy(buff,work);
- if (gethostname(hostname,MAX_LINE_LENGTH))
- error("getting host name",NULL);
-
- /* Process command line options here */
- if (!uid || uid==geteuid()) {
- printf("login %s -- invoking bbs -%s\n",login,(uid)?"n":"no");
- flags &= ~(O_SOURCE); /* for security */
- if (!uid)
- flags |= O_OBSERVE|O_READONLY;
- }
- confname[0]=0;
- while ((c = getopt(argc, argv, options)) != -1) {
- o = strchr(options,c)-options;
- if (o>=0 && o<6) flags ^= (1<<o);
- else if (c=='j') strcpy(confname,optarg);
- if (c=='o')
- flags ^= O_READONLY; /* -o does observer AND readonly */
- }
- if (optind < argc) strcpy(confname,argv[argc-1]);
-
- /* Read in WORK/.cflist */
- st_glob.listtime = 0;
- refresh_list();
-
- for (i=0; i<MAX_RESPONSES; i++) {
- re[i].fullname = re[i].login = NULL;
- #ifdef NEWS
- re[i].mid = NULL;
- re[i].article = 0;
- #endif
- }
-
- /* Set up user customizations */
- def_macro("today",DM_PARAM,"+0");
- mail = getenv("MAIL");
- if (!mail) {
- sprintf(mbox,"%s/%s",MAILDIR,login);
- mail = mbox;
- }
- def_macro("mailbox",DM_VAR,mail);
- mail = getenv("SHELL");
- if (mail) def_macro("shell",DM_VAR|DM_ENVAR,mail);
- mail = getenv("EDITOR");
- if (mail) def_macro("editor",DM_VAR|DM_ENVAR,mail);
- mail = getenv("MESG");
- if (mail) def_macro("mesg",DM_VAR|DM_ENVAR,mail);
-
- /* Read in /usr/bbs/conflist */
- for (i=0; i<MAX_LIST_LENGTH; i++)
- conflist[i].name = conflist[i].location = 0;
- open_cluster(BBSDIR,HELPDIR);
-
- if (strcmp(work,buff)) { /* for cfdir command */
- strcpy(buff,work);
- refresh_list();
- }
-
- /* Execute user's cfonce file */
- source(work,".cfonce");
- if (strcmp(work,buff))
- source(work,".cfonce");
-
- /* Reset name */
- namestr=explode(pwd->pw_gecos,expand("gecos",DM_VAR));
- strcpy(st_glob.fullname,(xsizeof(namestr)>0)? namestr[0] : "Unknown");
- xfree(namestr);
-
- /* Join initial conference */
- if (flags & O_DEBUG)
- printf("Default: %hd %s\n",defidx,conflist[defidx].name);
- if (!(flags & O_DEFAULT) || defidx<0) {
- current = -1;
- st_glob.i_current = 0; /* No current item */
- } else if (confname[0])
- join(confname, 0);
- else if (cflist && xsizeof(cflist))
- join(cflist[current=0], 2); /* force join */
- else {
- join(compress(conflist[defidx].name), 2); /* force join */
- }
- }
-
- /******************************************************************************/
- /* PROCESS COMMAND LINE ARGUMENTS */
- /******************************************************************************
- Function: char source(char *dir, char *filename)
- Called by: init
- Arguments: File to source
- Returns:
- Calls: command for each statement
- Description: Executes commands in a file, does NOT grab_file since it
- only needs 1-time sequential access.
- *******************************************************************************/
- char /* RETURNS: 0 on error, 1 else */
- source(dir,filename) /* ARGUMENTS: */
- char *dir; /* Directory containing file */
- char *filename; /* Filename of commands to execute */
- {
- FILE *fp;
- char buff[MAX_LINE_LENGTH];
-
- if (filename)
- sprintf(buff,"%s/%s",dir,filename);
- else
- strcpy(buff,dir);
- if (flags & O_DEBUG) printf("source: %s\n",buff);
- if ((fp=mopen(buff,O_R|O_SILENT))==NULL) return 0;
- if (st_glob.inp != stdin)
- mclose(st_glob.inp);
- st_glob.inp = stdin;
- while (ngets(buff, fp)) {
- if ((flags & O_VERBOSE) && mode==M_SANE)
- printf("command: %s\n",buff);
- st_glob.inp = fp;
- command(buff,0);
- st_glob.inp = stdin;
- }
- mclose(fp);
- return 1;
- }
-
- /******************************************************************************/
- /* PROCESS COMMAND LINE ARGUMENTS */
- /******************************************************************************
- Function: char command(char *command)
- Called by: main
- Arguments: command to process
- Returns: 0 if done, 1 else
- Calls: join() for "join", "next" commands
- leave() for "next", "quit" commands
- Description: For all command modes, this processes a user command.
- Interrupts go back to here, without changing command mode.
- *******************************************************************************/
- char /* RETURNS: Done flag */
- command(str,lvl) /* ARGUMENTS: */
- char *str; /* Command to execute */
- int lvl; /* Recursion depth */
- {
- int argc=0; /* Number of arguments */
- unsigned short i;
- char *argv[MAX_ARGS],cmddel,bufdel;
- char *Sptr,*Eptr,state=1,ok;
- char cmd[MAX_LINE_LENGTH],*cmd2;
-
- if (!str || !*str) return 1;
- if (flags & O_DEBUG) printf("command: %s\n",str);
- if (lvl > CMD_DEPTH) {
- printf("UNK Too many expansions.\n");
- return 0;
- }
-
- /* Process shell escape */
- if (str[0]=='!') {
- /* Undone at request of sno and jep
- if (mode==M_SANE)
- printf("Conference rc cannot exec: %s\n",str);
- else {
- */
- unix_cmd(str+1);
- printf("!\n");
- /* } */
- return 1;
-
- /* And comments */
- } else if (str[0]=='#') return 1;
-
- cmddel = expand("cmddel",DM_VAR)[0];
- bufdel = expand("bufdel",DM_VAR)[0];
-
- /* Get arguments using a state machine for lexical analysis */
- Sptr=str;
- pipebuf[0]=cmdbuf[0]='\0';
- while (state && argc<MAX_ARGS) {
- switch(state) {
- case 1: /* between words */
- while (isspace(*Sptr)) Sptr++;
- if (*Sptr==cmddel) { Sptr++; state=0; }
- else if (*Sptr==bufdel) { Eptr= ++Sptr; state=6; }
- else if (*Sptr=='|') { Eptr= ++Sptr; state=7; }
- else if (*Sptr=='>') { Eptr=Sptr; state=9; }
- else if (*Sptr=='\'') { Eptr= ++Sptr; state=4; }
- else if (*Sptr=='`') { Eptr= ++Sptr; state=8; }
- /* else if (*Sptr=='\"') { Eptr= ++Sptr; state=3; } */
- else if (*Sptr=='\"') { Eptr=Sptr; state=3; }
- else if (*Sptr=='\\') { Eptr=Sptr; state=5; }
- else if (*Sptr) { Eptr=Sptr; state=2; }
- else state=0;
- break;
-
- case 2: /* normal word */
- while (*Eptr && !isspace(*Eptr)
- && *Eptr!=cmddel && *Eptr!=bufdel
- && !strchr("|`'>\\\"",*Eptr)
- && !(Eptr>Sptr && *(Eptr-1)=='=') /* '=' terminates word */
- && (argc || *Sptr=='-' || isdigit(*Sptr) || !isdigit(*Eptr)))
- Eptr++;
-
- argv[argc]=(char*)xalloc(0,Eptr-Sptr+1);
- strncpy(argv[argc],Sptr,Eptr-Sptr);
- argv[argc++][Eptr-Sptr]=0;
- Sptr = Eptr;
-
- if (argc==1) {
- cmd2=(char *)expand(argv[0],((mode & M_MASK)==M_RFP)? DM_RFP : DM_OK);
- if (cmd2) {
- sprintf(cmd,"%s%s",cmd2,Eptr);
- xfree(argv[argc=0]);
- Sptr = cmd;
- }
- }
-
- state=1;
- break;
-
- case 3: /* "stuff" */
- do {
- Eptr++;
- } while (*Eptr && (*Eptr!='\"' || *(Eptr-1)=='\\'));
- /* argv[argc]=xalloc(0,Eptr-Sptr+1); */
- argv[argc]=(char*)xalloc(0,Eptr-Sptr+2);
- /* strncpy(argv[argc],Sptr,Eptr-Sptr); */
- strncpy(argv[argc],Sptr,Eptr-Sptr+1);
- /* argv[argc++][Eptr-Sptr]=0; */
- argv[argc++][Eptr-Sptr+1]=0;
-
- if (*Eptr) Eptr++;
- Sptr = Eptr;
- state=1;
- break;
-
- case 4: /* 'stuff' */
- do { Eptr++; } while (*Eptr && *Eptr!='\'');
- argv[argc]=(char*)xalloc(0,Eptr-Sptr+1);
- strncpy(argv[argc],Sptr,Eptr-Sptr);
- argv[argc++][Eptr-Sptr]=0;
-
- if (*Eptr) Eptr++;
- Sptr = Eptr;
- state=1;
- break;
-
- case 5: /* \\ */
- argv[argc]=(char*)xalloc(0,2);
- strcpy(argv[argc++],"\\");
- Sptr = Eptr+1;
- state=1;
- break;
-
- case 6: /* ,stuff */
- do { Eptr++; } while (*Eptr && *Eptr!=cmddel);
- strncpy(cmdbuf,Sptr,Eptr-Sptr);
- cmdbuf[Eptr-Sptr]=0;
- Sptr = Eptr;
- state=1;
- break;
-
- case 7: /* | stuff */
- do { Eptr++; } while (*Eptr && *Eptr!=cmddel && *Eptr!=bufdel);
- strncpy(pipebuf,Sptr,Eptr-Sptr);
- pipebuf[Eptr-Sptr]=0;
- Sptr = Eptr;
- state=1;
- break;
-
- case 8: /* `command` */
- do { Eptr++; } while (*Eptr && *Eptr!='`');
- strncpy(cmd,Sptr,Eptr-Sptr);
- cmd[Eptr-Sptr]=0;
-
- status |= S_EXECUTE;
- evalbuf[0] = '\0';
- command(cmd,lvl+1);
- status &= ~S_EXECUTE;
- argv[argc]=(char*)xalloc(0,strlen(evalbuf)+1);
- strcpy(argv[argc++],evalbuf);
-
- if (*Eptr) Eptr++;
- Sptr = Eptr;
- state=1;
- break;
-
- case 9: /* > file */
- do { Eptr++; } while (*Eptr=='>');
- do { Eptr++; } while (isspace(*Eptr));
- do {
- Eptr++;
- } while (*Eptr && *Eptr!=cmddel && *Eptr!=bufdel && *Eptr!=' ');
- strcpy(pipebuf,"cat ");
- strncat(pipebuf,Sptr,Eptr-Sptr);
- pipebuf[4+Eptr-Sptr]=0;
- Sptr = Eptr;
- state=1;
- break;
- }
- }
- /*
- if (*Sptr) strcpy(cmdbuf,Sptr);
- else cmdbuf[0]='\0';
- */
- if (argc) {
-
- /* Expand macros */
- #if 0
- /*
- cmd2=(char *)expand(argv[0],((mode & M_MASK)==M_RFP)? DM_RFP : DM_OK);
- */
- cmd2=0;
- if (cmd2) {
- xfree(argv[0]);
- strcpy(cmd,cmd2);
- /* implode(cmd+strlen(cmd),argv," ",1); argv isn't malloc'ed */
- for (i=1; i<argc; i++) {
- strcat(cmd," ");
- strcat(cmd,argv[i]);
- xfree(argv[i]);
- }
- ok = command(cmd,lvl+1);
- } else
- #endif
- {
-
- /* Execute command */
- switch(mode & M_MASK) {
- case M_OK: ok= ok_cmd_dispatch(argc,argv); break;
- case M_JOQ: ok= joq_cmd_dispatch(argc,argv); break;
- case M_TEXT: ok=text_cmd_dispatch(argc,argv); break;
- case M_RFP: ok= rfp_cmd_dispatch(argc,argv); break;
- case M_EDB: ok= edb_cmd_dispatch(argc,argv); break;
- default: printf("Unknown mode %d\n",mode); break;
- }
-
- /* Free args */
- for (i=0; i<argc; i++) xfree(argv[i]);
- }
- } else
- ok=1; /* don't abort on null command */
-
- /* Do next ; cmd unless EOF or command says to halt (ok==2) */
- if (ok==1 && *Sptr && !(status & S_STOP)) {
- ok=command(Sptr,lvl+1);
- }
- /* else if (*Sptr) status &= ~S_STOP; */
- return ok;
- }
-
- /* Commands available at the Ok: prompt only */
- static dispatch_t ok_cmd[]={
- "i_tem", do_read,
- "r_ead", do_read,
- "pr_int", do_read,
- "e_nter", enter,
- "s_can", do_read,
- "b_rowse", do_read,
- /* j_oin */
- "le_ave", leave,
- "n_ext", do_next,
- "che_ck", check,
- "rem_ember", remember,
- "forget", forget,
- "unfor_get", remember,
- "k_ill", do_kill,
- "freeze", freeze,
- "thaw", freeze,
- /* sync_hronous */
- /* async_hronous */
- "retire", freeze,
- "unretire", freeze,
- "f_ind", do_find,
- "l_ocate", do_find,
- "seen", fixseen,
- "fix_seen", fixseen,
- "re_spond", respond,
- /* lpr_int */
- "li_nkfrom", linkfrom,
- "abort", leave,
- /* ex_it q_uit st_op good_bye log_off log_out h_elp exp_lain sy_stem unix al_ias
- * def_ine una_lias und_efine ec_ho echoe echon echoen echone so_urce m_ail
- * t_ransmit sen_dmail chat write d_isplay que_ry */
- "p_articipants", participants,
- /* w_hoison am_superuser */
- "resign", resign,
- /* chd_ir uma_sk sh_ell f_iles dir_ectory ty_pe e_dit cdate da_te t_est
- * clu_ster
- */
- "ps_eudonym",respond,
- "list", check,
- 0, 0
- };
-
- /******************************************************************************/
- /* DISPATCH CONTROL TO APPROPRIATE MISC. COMMAND FUNCTION */
- /******************************************************************************/
- char /* RETURNS: 0 to quit, 1 else */
- ok_cmd_dispatch(argc,argv) /* ARGUMENTS: */
- int argc; /* Number of arguments */
- char **argv; /* Argument list */
- {
- int i;
-
- for (i=0; ok_cmd[i].name; i++)
- if (match(argv[0],ok_cmd[i].name))
- return ok_cmd[i].func(argc,argv);
-
- /* Command dispatch */
- if (match(argv[0],"j_oin")) {
- if (argc==2) join(argv[1],0);
- else if (confidx>=0) {
- confsep("joinmsg",confidx,&st_glob,part,0);
- } else
- printf("Not in a conference!\n");
- } else return misc_cmd_dispatch(argc,argv);
- return 1;
- }
-
- /******************************************************************************/
- /* PROCESS A GENERIC SIGNAL (if enabled) */
- /******************************************************************************/
- void
- handle_other(sig, code, scp, addr)
- int sig, code;
- /* struct sigcontext */ void *scp;
- char *addr;
- {
- if (status & S_PIPE) printf("%d Pipe interrupt %d!\n",getpid(),sig);
- else printf("%d Interrupt %d!\n",getpid(),sig);
- status |= S_INT;
- }
-
- /******************************************************************************/
- /* PROCESS A USER INTERRUPT SIGNAL */
- /******************************************************************************/
- void /* RETURNS: (nothing) */
- handle_int() /* ARGUMENTS: (none) */
- {
- struct sigvec vec;
-
- if (!(status & S_PIPE)) {
- printf("Interrupt!\n");
- status |= S_INT;
- }
- signal(SIGINT, handle_int);
- sigvec(SIGINT, NULL, &vec);
- vec.sv_flags |= SV_INTERRUPT;
- sigvec(SIGINT, &vec, NULL);
- }
-
- /******************************************************************************/
- /* PROCESS AN INTERRUPT CAUSED BY A PIPE ABORTING */
- /******************************************************************************/
- void /* RETURNS: (nothing) */
- handle_pipe() /* ARGUMENTS: (none) */
- {
- printf("Pipe interrupt?\n");
- /* spclose(st_glob.outp );*/
- signal(SIGPIPE, handle_pipe);
- status |= S_INT;
- }
-