v16i004: Multi-user conference system, Part04/05
Rich Salz
rsalz at uunet.uu.net
Tue Sep 13 06:08:45 AEST 1988
Submitted-by: Keith Gabryelski <ucsd!elgar!ag>
Posting-number: Volume 16, Issue 4
Archive-name: conf/part04
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# confsig.c
# confstr.c
# extern.h
# structs.h
export PATH; PATH=/bin:$PATH
if test -f 'confsig.c'
then
echo shar: will not over-write existing file "'confsig.c'"
else
cat << \SHAR_EOF > 'confsig.c'
#include "conf.h"
int nsig = 16;
char *sig_list[] =
{
"Unkown Signal: 0",
"Hangup",
"Interrupt",
"Quit",
"Illegal Instruction",
"Trace Trap",
"IOT Instruction",
"EMT Instruction",
"Floating Point Exception",
"Kill",
"Bus Error",
"Segmentation Violation",
"Bad Argument To System Call",
"Write On A Pipe With No One To Read It",
"Alarm Clock",
"Software Termination Signal From Kill",
};
fatal(sig)
int sig;
{
int p;
(void) printf("\nFatal Signal %d (%s).\n", sig, putsig(sig));
make_nice(FALSE);
p = kill(cuser.cu_procid, sig);
if (p < 0)
(void) fprintf(stderr, "%s: Couldn't kill proccess %d (%s)\n",
progname, cuser.cu_procid, puterr(errno));
(void) exit(-1);
}
char *
putsig(sig)
int sig;
{
static char qwerty[42];
(void) sprintf(qwerty, "Unknown Signal: %d", sig);
return ((unsigned)sig >= nsig) ? qwerty : sig_list[sig];
}
SHAR_EOF
fi # end of overwriting check
if test -f 'confstr.c'
then
echo shar: will not over-write existing file "'confstr.c'"
else
cat << \SHAR_EOF > 'confstr.c'
#include "conf.h"
unsigned int wordlen;
char *
parsestr(string, length, flags)
char *string;
int length, flags;
{
static char *retbuf;
static int buflen = 0;
static char *prevs;
static int prevl;
char *p;
if (buflen == 0)
retbuf = mymalloc((unsigned)(buflen = PAGESIZ));
p = retbuf;
if (!length)
{
string = prevs;
length = prevl;
}
while (length && isspace(*string))
{
++string;
--length;
}
prevs = string;
prevl = length;
if (!length)
{
wordlen = linelen = 0;
return NULL;
}
while (length &&
((flags&THEREST) || (!isspace(*string) &&
(*string != ',') && (*string != '='))))
{
if (*string == '"')
{
++string; --length;
while (length && (*string != '"'))
{
if (*string == '\\')
{
++string; --length;
if (length && isdigit(*string))
{
int x, c;
x = (*string++ - '0'); --length;
if (length && isdigit(*string))
{
x = (x * 10) + (*string++ - '0'); --length;
if (length && isdigit(*string))
{
c = (x * 10) + (*string - '0');
if (c < 256)
{
x = c;
++string; --length;
}
}
}
*p++ = x;
}
else
if (length)
{
*p++ = *string++; --length;
}
}
else
{
*p++ = *string++; --length;
}
}
}
else
{
if (*string == '\\')
{
++string; --length;
if (length && isdigit(*string))
{
int x, c;
x = (*string++ - '0'); --length;
if (length && isdigit(*string))
{
x = (x * 10) + (*string++ - '0'); --length;
if (length && isdigit(*string))
{
c = (x * 10) + (*string - '0');
if (c < 256)
{
x = c;
++string; --length;
}
}
}
*p++ = x;
}
else
if (length)
{
*p++ = *string++; --length;
}
}
else
{
*p++ = *string++; --length;
}
}
}
*p = '\0';
while (length && isspace(*string))
{
++string; --length;
}
if (length && ((*string == ',') || (*string == '=')))
{
++string; --length;
}
prevs = string;
prevl = length;
linelen = length;
wordlen = p - retbuf;
return wordlen ? retbuf : NULL;
}
cpystr(to, from, length)
register char *to, *from;
register unsigned int length;
{
while(length--) *to++ = *from++;
}
char *
puterr(error)
int error;
{
static char qwerty[42];
(void) sprintf(qwerty, "Unknown error %d", error);
return ((unsigned)error >= sys_nerr) ? qwerty : sys_errlist[error];
}
SHAR_EOF
fi # end of overwriting check
if test -f 'extern.h'
then
echo shar: will not over-write existing file "'extern.h'"
else
cat << \SHAR_EOF > 'extern.h'
extern errno;
extern struct passwd *getpwuid();
extern FILE *fopen(), *popen();
extern char *getlogin(), *malloc(), *realloc(), *strchr(), *strrchr();
extern char *ttyname(), *getenv(), *strcpy(), *strncpy(), *strcat();
extern char *tgetstr();
extern void tputs();
extern char *sys_errlist[];
extern int sys_nerr;
extern long lseek();
extern void free(), longjmp();
extern unsigned alarm(), sleep();
extern char *progname;
extern int log_rfd, log_wfd, usr_fd;
extern long ourplace;
extern FILE *rec_fp;
extern int confing, columns, lines;
extern char ichar, qchar;
extern char *wrdata, replytty[], replyname[];
extern unsigned wdlen;
extern struct cusrfil cuser, tuser;
extern struct clogfil clog, tlog;
extern int banner, seeme, informe, lineinput, beep;
extern int expand8bit, expandctrl;
extern unsigned linelen, wordlen;
extern int nice_exit(), write_log();
extern int version(), do_to(), messptr(), colprnt(), fatal();
extern int getopts(), getrc(), setopts(), dispchar(), do_ring();
extern char *logname, *homedir;
extern char *pager, *shell, *normform, *lineform, *shoutform, *sendform;
extern char *informform, *recfile;
extern char *cls;
#ifdef SYSV
extern struct termio term, saveterm;
#endif SYSV
#ifdef BSD
extern struct tchars chrstr;
extern struct sgttyb ktty;
extern int ttyflags;
#endif BSD
extern char *getline(), *mymalloc(), *myrealloc(), *puterr();
extern char *getword(), *parsestr(), *putsig();
SHAR_EOF
fi # end of overwriting check
if test -f 'structs.h'
then
echo shar: will not over-write existing file "'structs.h'"
else
cat << \SHAR_EOF > 'structs.h'
/*
* logfile (CONFLOG) struct
*
*/
struct clogfil
{
int type;
int f_line;
unsigned int f_usrlen;
unsigned int f_ttylen;
unsigned int t_utlen;
unsigned int messlen;
};
/*
* message type
*
*/
#define NORMAL 0
#define SEND 1
#define SHOUT 2
#define INFORM 3
/*
* userfile (CONFUSERS) struct
*
*/
struct cusrfil
{
int cu_flags;
char cu_cname[MAXNAMELEN];
char cu_tty[MAXTTYLEN];
int cu_line;
short cu_procid;
};
/*
* cu_flags
*
*/
#define USER_OFF 0
#define USER_ON 1
#define USER_RECORD 2
/*
* Structure of valid options
*
*/
struct varopts
{
char *name;
int type;
int *var;
int extra;
int (*var_func)();
};
/*
* Some flags to go with varopt struct
*
*/
#define BOOLEAN 0
#define NUMBER 1
#define STRING 2
#define VARMASK 3
#define DISPLAY 0
#define NODISPLAY 4
#define DISPLAYMASK 4
#define POINTER 1
#define ROUTINE 2
/*
* Return values from setops
*
*/
#define NOOPT 0
#define FOUNDOPT 1
#define AMBIGUOUS 2
/*
* for the who routine
*
*/
struct whostr
{
char name[MAXNAMELEN+1];
char tty[MAXTTYLEN+1];
int line;
int flags;
};
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0
--
"If green is all there is to be, then green is good enough for me" - ktf
[ Keith ] UUCP: {ucsd, cbosgd!crash, sdcsvax!crash, nosc!crash}!elgar!ag
[Gabryelski] INET: ag at elgar.cts.com ARPA: elgar!ag at ucsd.edu
--
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.
More information about the Comp.sources.unix
mailing list