summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sup/lib
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-03-11 10:52:21 +0000
committerpeter <peter@FreeBSD.org>1997-03-11 10:52:21 +0000
commitf1a22bd4be055388029e3427ffd7262905915724 (patch)
tree3ce2e71c060e50986b90c5bff84482c8504457f6 /usr.sbin/sup/lib
parent266d7fba02761d8720cb17d2c28b06e8c5df5204 (diff)
downloadFreeBSD-src-f1a22bd4be055388029e3427ffd7262905915724.zip
FreeBSD-src-f1a22bd4be055388029e3427ffd7262905915724.tar.gz
Kill sup from the main sources now that the ports version is updated.
This puts it on the same footing as cvsup. It's been suggested on numerous occasions that I shouldn't have imported it in the first place, and now that sup has outlived it's usefulness..... Boom!
Diffstat (limited to 'usr.sbin/sup/lib')
-rw-r--r--usr.sbin/sup/lib/Makefile17
-rw-r--r--usr.sbin/sup/lib/atoo.c54
-rw-r--r--usr.sbin/sup/lib/c.h79
-rw-r--r--usr.sbin/sup/lib/ci.c847
-rw-r--r--usr.sbin/sup/lib/errmsg.c63
-rw-r--r--usr.sbin/sup/lib/expand.c366
-rw-r--r--usr.sbin/sup/lib/ffilecopy.c85
-rw-r--r--usr.sbin/sup/lib/filecopy.c65
-rw-r--r--usr.sbin/sup/lib/libc.h322
-rw-r--r--usr.sbin/sup/lib/log.c179
-rw-r--r--usr.sbin/sup/lib/netcryptvoid.c95
-rw-r--r--usr.sbin/sup/lib/nxtarg.c77
-rw-r--r--usr.sbin/sup/lib/path.c96
-rw-r--r--usr.sbin/sup/lib/quit.c67
-rw-r--r--usr.sbin/sup/lib/run.c191
-rw-r--r--usr.sbin/sup/lib/salloc.c48
-rw-r--r--usr.sbin/sup/lib/scan.c1045
-rw-r--r--usr.sbin/sup/lib/scm.c609
-rw-r--r--usr.sbin/sup/lib/scmio.c758
-rw-r--r--usr.sbin/sup/lib/skipto.c78
-rw-r--r--usr.sbin/sup/lib/stree.c364
-rw-r--r--usr.sbin/sup/lib/sup.h264
-rw-r--r--usr.sbin/sup/lib/supmsg.c640
-rw-r--r--usr.sbin/sup/lib/supmsg.h197
24 files changed, 0 insertions, 6606 deletions
diff --git a/usr.sbin/sup/lib/Makefile b/usr.sbin/sup/lib/Makefile
deleted file mode 100644
index 62f3577..0000000
--- a/usr.sbin/sup/lib/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id$
-
-LIB= sup
-SRCS= scm.c scmio.c stree.c log.c supmsg.c netcrypt.c atoo.c errmsg.c \
- expand.c ffilecopy.c filecopy.c nxtarg.c path.c quit.c run.c \
- salloc.c skipto.c scan.c
-
-CFLAGS+= -DVAR_TMP -DHAS_DAEMON -I${.CURDIR}
-NOPROFILE=
-CLEANFILES+= netcrypt.c
-
-netcrypt.c: netcryptvoid.c
- ln -s ${.CURDIR}/netcryptvoid.c netcrypt.c
-
-install:
-
-.include <bsd.lib.mk>
diff --git a/usr.sbin/sup/lib/atoo.c b/usr.sbin/sup/lib/atoo.c
deleted file mode 100644
index eac0764..0000000
--- a/usr.sbin/sup/lib/atoo.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* atoo -- convert ascii to octal
- *
- * Usge: i = atoo (string);
- * unsigned int i;
- * char *string;
- *
- * Atoo converts the value contained in "string" into an
- * unsigned integer, assuming that the value represents
- * an octal number.
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Rewritten for VAX.
- *
- */
-
-unsigned int atoo(ap)
-char *ap;
-{
- register unsigned int n;
- register char *p;
-
- p = ap;
- n = 0;
- while(*p == ' ' || *p == ' ')
- p++;
- while(*p >= '0' && *p <= '7')
- n = n * 8 + *p++ - '0';
- return(n);
-}
diff --git a/usr.sbin/sup/lib/c.h b/usr.sbin/sup/lib/c.h
deleted file mode 100644
index 801331d..0000000
--- a/usr.sbin/sup/lib/c.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * Standard C macros
- *
- **********************************************************************
- * HISTORY
- * 02-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check to allow multiple or recursive inclusion of this
- * file. Added bool enum from machine/types.h for regular users
- * that want a real boolean type.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Also change spacing of MAX and MIN to coincide with that of
- * sys/param.h.
- *
- * 19-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed the number of tabs between TRUE, FALSE and their
- * respective values to match those in sys/types.h.
- *
- * 17-Dec-84 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Only define TRUE and FALSE if not defined. Added caseE macro
- * for using enumerated types in switch statements.
- *
- * 23-Apr-81 Mike Accetta (mja) at Carnegie-Mellon University
- * Added "sizeofS" and "sizeofA" macros which expand to the size
- * of a string constant and array respectively.
- *
- **********************************************************************
- */
-
-#ifndef _C_INCLUDE_
-#define _C_INCLUDE_
-
-#define ABS(x) ((x)>=0?(x):-(x))
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#define MAX(a,b) (((a)>(b))?(a):(b))
-
-#ifndef FALSE
-#define FALSE 0
-#endif FALSE
-#ifndef TRUE
-#define TRUE 1
-#endif TRUE
-
-#define CERROR (-1)
-
-#ifndef bool
-typedef enum { false = 0, true = 1 } bool;
-#endif bool
-
-#define sizeofS(string) (sizeof(string) - 1)
-#define sizeofA(array) (sizeof(array)/sizeof(array[0]))
-
-#define caseE(enum_type) case (int)(enum_type)
-
-#endif _C_INCLUDE_
diff --git a/usr.sbin/sup/lib/ci.c b/usr.sbin/sup/lib/ci.c
deleted file mode 100644
index 8960eb5..0000000
--- a/usr.sbin/sup/lib/ci.c
+++ /dev/null
@@ -1,847 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* ci -- command interpreter
- *
- * Usage (etc.)
- *
- * HISTORY
- * 22-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed checks for VIRTUE window manager. If they don't like
- * it then they can fix the more program.
- *
- * 08-May-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Increased MAXENTRIES and MAXHELPS from 200 to 400.
- *
- * 30-Apr-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Adapted for 4.2 UNIX. Added calls to check for
- * using window manager of VIRTUE.
- *
- * 29-Apr-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Added two small bug fixes (courtesy of Richard Cohn).
- *
- * 14-Aug-84 Steven Shafer (sas) at Carnegie-Mellon University
- * Added fflush(stdout) after printing prompt, before asking for input line.
- *
- * 01-Jul-83 Steven Shafer (sas) at Carnegie-Mellon University
- * Bug fix: whitespace now required before ">filename" and not permitted
- * within or after filename.
- *
- * 06-Jun-83 Steven Shafer (sas) at Carnegie-Mellon University
- * Bug fix: added line to initialize "redirected" to 0.
- *
- * 20-May-83 Steven Shafer (sas) at Carnegie-Mellon University
- * Added quiet bits CINOSEM, CINOFILE, CIFIRSTEQUAL to allow user to
- * have special characters ; > = treated as normal data (except =
- * after first argument, which still means "variable assignment").
- * Also added output redirection via >filename on input line.
- *
- * 07-Mar-83 Dave McKeown (dmm) at Carnegie-Mellon University
- * (Slight alterations by Steve Shafer.)
- * Made cidepth a global, used for recursive and nested calls to
- * ci(), and accessable to the user. Added '@x' command, similar
- * to '^x' except that the previous command interpreter name is
- * remembered and after 'x' is executed, the previous command
- * interpreter is reinvoked. Users who plan to use this feature
- * must save the name of the previous ci in global variable
- * 'ciprev' after exit from the ci(). ie.
- * ci(.........);
- * strcpy(ciprev,"ci-name");
- * Added ci state CICMDNOINDENT to allow for no indentation of the
- * command line prompt based on cidepth.
- * Reduced amount of indentation on source code.
- * Bug: the "depth" argument is now a no-op, retained for backward
- * compatibility. Cidepth is initialized to zero, and incremented
- * upon invocation of a ci(). If cidepth is <1 then you are not
- * in a ci() instantiation.
- *
- * 21-Feb-83 Steven Shafer (sas) at Carnegie-Mellon University
- * Added up-arrow (^) command (and variable cinext). ^x is used when
- * you have a ci program in which one command invokes ci with a
- * new set of commands (i.e. a subsystem of the program). Inside the
- * subsystem, ^x will exit the subsystem, and cause the main level
- * to execute the command line "x" before reading more input lines.
- * The cinext variable is used to implement this. Cinext can also be
- * used by any user code which desires to force ci to execute a
- * specific command before reading more input from the current file.
- *
- * 16-Jul-82 Steven Shafer (sas) at Carnegie-Mellon University
- * Added extra code in _ci_help to eliminate duplicate help file
- * names. This way, if several directories are specified and there
- * is are files with the same name in more than one directory, only
- * the first of each file will be included in the help list.
- *
- * It would have been nice to do this after the qsort instead of
- * before (in ci_help). However, qsort does not ensure that
- * "equivalent" entries are kept in the same relative
- * order; thus there would be no way to ensure that the
- * file being used was the first such file found.
- *
- * 07-Jul-82 William Chiles (wpc) at Carnegie-Mellon University
- * Modified so that "!" invokes shell commands from the type of
- * shell specified by the environment variable SHELL. If SHELL
- * is not defined the standard shell is used.
- *
- * 21-Sep-81 Steven Shafer (sas) at Carnegie-Mellon University
- * Increased LINELENGTH (input buffer length) to 1100 to satisfy
- * voracious requirements of a certain user whose name I won't mention
- * but whose initials are "faa".
- *
- * 08-Oct-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Added class variables: ci_tclass cases in ci_show and ci_set.
- * Also added CICMDFPEEK in addition to existing CISETPEEK.
- *
- * 22-May-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Ci now sorts help topics into alphabetical order. Some interrupt
- * handling has been added, but there are bugs, for example, when
- * you interrupt "*" (the listing of command names). The right thing
- * happens, but bogus messages are printed.
- *
- * 16-Apr-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Ci now prints lists of names with prstab(). This uses multiple
- * columns when appropriate.
- *
- * 12-Mar-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Added code to skip over leading blanks and tabs in the argument list
- * when executing commands, and setting and displaying variables.
- * Also fixed meta-help, which mysteriously disappeared.
- *
- * 19-Feb-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Added "if (0) del();" to force del() routine to be loaded. This is
- * the safest way I know of to define the external int "_del_". If you
- * don't believe it, think again about separately compiled files.
- *
- * 28-Jan-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Created. Patterned (somewhat) after ci() on PDP-11.
- *
- */
-
-
-#include <strings.h>
-#include <libc.h>
-#include <ci.h>
-#include <del.h>
-
-char *index(),*getenv(),*rindex();
-extern char _argbreak;
-long atol();
-double atof();
-static int ci_help(), ci_show();
-static int _ci_sho(), _ci_set(), ci_set();
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-#define LINELENGTH 1100 /* max length of input line */
-#define MAXENTRIES 400 /* max entries in entry list */
-#define MAXHELPS 400 /* max help files available */
-#define METAHELP "/usr/lib/ci.help" /* standard help file */
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-int ciquiet = 0; /* init globals */
-int ciexit = 0;
-int cidepth = 0;
-int ciback = 0; /* for use in '@' command */
-FILE *ciinput;
-
-char cinext[LINELENGTH] = "";
-char ciprev[LINELENGTH] = "";
-
-static char *delchoice[] = { /* breakpoint choices */
- "abort abort command file",
- "breakpoint break to tty, then resume command file",
- 0};
-
-/*************************************
- *** M A I N R O U T I N E ***
- *************************************/
-
-ci (prompt,fil,depth,list,helppath,cmdfpath)
-char *prompt; /* prompt message */
-FILE *fil; /* input file */
-int depth; /* recursion depth */
-CIENTRY *list; /* entry list */
-char *helppath; /* search list for help files */
-char *cmdfpath; /* search list for command files */
-
-{
-
- FILE *savfile; /* input file for calling instance of ci */
- int savquiet, savexit; /* globals for calling instance of ci */
- char *p,*q,*cmd,*arg; /* temps for parsing input */
- int i; /* temp */
- char line[LINELENGTH]; /* input line buffer */
- int firststmt; /* temp */
- char *equals,*star; /* index of = and * in input line */
- char cfnam[200]; /* name of command file */
- char *name[MAXENTRIES]; /* name list for entries */
- char *vname[MAXENTRIES]; /* name list for just variables */
- int vnum[MAXENTRIES]; /* correspondence list for variables */
- int nv; /* number of variables */
- int helpcmd; /* "help" command index */
- FILE *newfile; /* command file just opened */
- char bprompt[100]; /* breakpoint prompt */
- char *tname[MAXENTRIES]; /* temp name list */
- int tnum; /* # entries in tname */
- char *Shell; /* holds SHELL value from .login */
- int redirected; /* 1 iff currently redirected output */
- FILE savestdout; /* place to save normal std. output */
- FILE *outfile; /* current output file */
- char *outname; /* output file name */
-
-
- /* force del() routine to be declared */
- if (0) del();
- /* save globals on stack */
- cidepth++; /* bump the global depth, first CI() is 1 */
- savquiet = ciquiet;
- savexit = ciexit;
- savfile = ciinput;
- ciexit = 0; /* don't exit until this is set */
- ciinput = (fil ? fil : stdin); /* new input file */
-
- /* construct name lists for stablk */
-
- nv = 0;
- for (i=0; list[i].ci_etyp != ci_tend; i++) {
- name[i] = list[i].ci_enam;
- if (list[i].ci_etyp != ci_tcmd) { /* is variable */
- vname[nv] = name[i];
- vnum[nv] = i;
- nv++;
- }
- }
- helpcmd = i++; /* force-feed "help" onto list */
- name[helpcmd] = "help";
- name[i] = 0;
- vname[nv] = 0;
-
- /* loop for input lines */
-
- redirected = 0;
- while (!ciexit) {
-
- if (*cinext) { /* get line from ^ command */
- if (ciback) {
- sprintf(line,"%s;%s",cinext,ciprev);
- ciback = 0;
- }
- else {
- strcpy (line,cinext);
- }
- strcpy (cinext,"");
- p = line;
- }
- else { /* else read file */
- if ((ciinput == stderr) || (ciinput == stdin) || (!(ciquiet&CICMDFPROMPT))) {
- if (!(ciquiet &CICMDNOINDENT)) {
- for (i=1; i<cidepth; i++) {
- printf (" ");
- }
- }
- printf ("%s ",prompt);
- if ((ciinput == stderr) || (ciinput == stdin)) fflush (stdout);
- }
- p = fgets (line,LINELENGTH,ciinput); /* read input line */
- if (p == 0) { /* EOF */
- if (_del_) {
- DELCLEAR;
- strcpy (line,"");
- p = line;
- }
- else {
- ciexit = 1;
- if ((ciinput==stdin) || (ciinput==stderr) ||
- (!(ciquiet&CICMDFECHO))) printf ("\n");
- }
- }
- else {
- if ((ciinput != stderr) && (ciinput != stdin) &&
- (!(ciquiet&CICMDFECHO))) printf ("%s",line);
-
- for (p=line; (*p) && (*p != '\n'); p++) ;
- *p = 0; /* kill trailing newline */
- p = line; /* points to start of line */
- }
- }
-
- /* check for redirection of output */
-
- if (!ciexit) {
- outname = rindex (p,'>');
- if (outname) {
- if (outname == p || *(outname+1) == 0
- || ((*(outname-1) != ' ') && (*(outname-1) != '\t'))) {
- outname = 0;
- }
- else {
- for (q=outname+1; *q && (*q != ' ') && (*q != '\t'); q++) ;
- if (*q) outname = 0;
- }
- }
- if (outname && !(ciquiet&CINOFILE)) {
- *outname++ = 0;
- outfile = fopen (outname,"w");
- if (outfile == 0) {
- printf ("ci: Can't create output file %s\n",outname);
- p = "";
- }
- else {
- fflush (stdout);
- savestdout = *stdout;
- *stdout = *outfile;
- redirected = 1;
- }
- }
- }
-
- /* loop for each command */
-
- firststmt = 1; /* first time through loop */
- while ((!ciexit) && (((ciquiet&CINOSEM) && firststmt) || *(cmd=nxtarg(&p,";")) || _argbreak)) {
-
- if (ciquiet & CINOSEM) {
- cmd = p;
- firststmt = 0;
- }
-
- switch (*cmd) { /* what kind of line? */
-
- case ':': /* : comment */
- case 0: /* null line */
- break;
-
- case '!': /* ! shell command */
- cmd = skipover (cmd+1," ");
- if ((Shell = getenv("SHELL")) == 0) Shell = "sh";
- if (*cmd) runp (Shell, Shell, "-c", cmd, 0);
- else runp (Shell, Shell, 0);
- if (!(ciquiet&CISHEXIT)) printf ("Back to %s\n",prompt);
- break;
-
- case '?': /* ? help */
- cmd = skipover (cmd+1," ");
- ci_help (cmd,helppath);
- break;
-
- case '<': /* < command file */
- arg = cmd + 1;
- cmd = nxtarg (&arg,0); /* parse name */
- if (*cmd == 0) printf ("ci: missing filename\n");
- else {
- if (cmdfpath) newfile = fopenp (cmdfpath,cmd,cfnam,"r");
- else newfile = fopen (cmd,"r");
-
- if (newfile == 0)
- printf ("ci: can't open command file %s\n",cmd);
- else {
- if (!(ciquiet&CICMDFECHO)) printf ("\n");
- ci (prompt,newfile,cidepth,list,helppath,cmdfpath);
- fclose (newfile);
- if (!(ciquiet&CICMDFEXIT)) printf ("End of file\n\n");
- }
- }
- break;
-
- case '^': /* exit and do command */
- case '@':
- if (cidepth > 1) {
- if (*cmd == '@') ciback = 1;
- if (_argbreak == ';') *(cmd+strlen(cmd)) = ';';
- ciexit = 1;
- cmd = skipover(cmd+1," ");
- strcpy (cinext,cmd);
- }
- else printf ("ci: ^ not allowed at top level of ci\n");
- break;
-
- default: /* list cmds, etc. */
- equals = index (cmd,'=');
- if (equals == cmd) cmd++;
-
- if (equals) {
- if (*(equals+1) == 0) *equals = 0;
- else *equals = ' ';
- }
-
- arg = cmd; /* parse first word */
- cmd = nxtarg (&arg,0);
- if ((ciquiet&CIFIRSTEQUAL) && equals && equals>arg) {
- *equals = '='; /* if user doesn't want extra =, kill */
- equals = 0;
- }
- star = index (cmd,'*');
- if (star) *star = 0;
- if (star && equals) { /* list vars */
- printf ("\n");
- for (i=0; vname[i]; i++) {
- if (stlmatch (vname[i],cmd)) {
- ci_show (list[vnum[i]],arg,CIPEEK);
- }
- DELBREAK;
- }
- printf ("\n");
- }
- else if (star) { /* list cmds */
- printf ("\n");
- tnum = 0;
- for (i=0;name[i]; i++) {
- if ((i==helpcmd || list[i].ci_etyp == ci_tcmd) &&
- stlmatch (name[i],cmd)) {
- tname[tnum++] = name[i];
- }
- }
- tname[tnum] = 0;
- prstab (tname);
- if (_del_) {_DELNOTE_}
- printf ("\n");
- }
- else if (equals) { /* set var */
- i = stablk (cmd,vname,0);
- if (i >= 0) ci_set (list[vnum[i]],skipover(arg," \t"));
- }
- else {
- i = stablk (cmd,name,0);
-
- if (i == helpcmd) ci_help (arg,helppath);
- else if (i >= 0) {
- if (list[i].ci_etyp == ci_tcmd) {
- (* (int(*)()) (list[i].ci_eptr)) (skipover(arg," \t"));
- }
- else ci_show (list[i],skipover(arg," \t"),CISHOW);
- }
- }
- }
-
- /* end of command */
-
- /* DEL trapping */
-
- if (_del_) {
- if (ciinput == stdin) {
- DELCLEAR; /* already at tty level */
- }
- else {
- _del_ = 0;
- i = getstab ("INTERRUPT: abort or breakpoint?",delchoice,"abort");
- if (i == 0) ciexit = 1; /* abort */
- else { /* breakpoint */
- sprintf (bprompt,"Breakpoint for %s",prompt);
- ci (bprompt,0,cidepth,list,helppath,cmdfpath);
- }
- }
- }
-
- /* end of loop for commands */
-
- }
-
- /* end of loop for lines of input file */
-
- if (redirected) {
- fflush (stdout);
- fclose (stdout);
- *stdout = savestdout;
- redirected = 0;
- }
-
- }
-
- /* restore globals */
- cidepth --; /* update current depth */
- ciinput = savfile;
- ciquiet = savquiet;
- ciexit = savexit;
-}
-
-/********************************************
- *** P R I N T H E L P F I L E ***
- ********************************************/
-
-static int _h_found; /* how many matching names? */
-static char **_h_list; /* list of matching names */
-static char (*_h_nlist)[20]; /* list of filename part of names */
-
-static int _ci_help (filspec)
-/* called by searchp to expand filspec, adding names to _h_list */
-char *filspec;
-{
- register int i,j,result;
- char dir[200];
-
- result = expand (filspec, _h_list + _h_found, MAXHELPS - _h_found);
- if (result > 0) {
- for (i=0; i<result; ) { /* elim duplicates */
- path (_h_list[i+_h_found],dir,_h_nlist[i+_h_found]);
- for (j=0;
- j<_h_found && strcmp(_h_nlist[j],_h_nlist[i+_h_found]) != 0;
- j++) ;
- if (j < _h_found) { /* is duplicate */
- --result;
- strcpy (_h_list[i+_h_found],_h_list[result+_h_found]);
- }
- else i++; /* isn't duplicate */
- }
-
- _h_found += result;
- }
-
- return (1); /* keep searching */
-}
-
-/* for use in sorting help file names */
-static ci_hcomp (p,q)
-char **p,**q;
-{
- char dir[200],file1[20],file2[20];
- path ((*p),dir,file1);
- path ((*q),dir,file2);
- return (strcmp(file1,file2));
-}
-
-static ci_help (topic,helppath)
-char *topic,*helppath;
-{
- char *fnames[MAXHELPS]; /* names of matching files */
- char names[MAXHELPS][20]; /* stripped filenames */
- char *nptr[MAXHELPS+1]; /* list of ptrs for stablk */
- char dir[200]; /* temp */
- char shstr[300]; /* shell string for system */
- int i;
- char *star;
- FILE *f;
-
- if (*topic == 0) { /* wants meta-help */
- f = fopen (METAHELP,"r");
- if (f == 0) {
- printf ("Yikes!! Can't open standard help file!\n");
- }
- else {
- printf ("\n");
- runp("more","more",METAHELP,0);
- if (_del_) {_DELNOTE_}
- printf ("\n");
- fclose (f);
- }
- if (helppath && (*helppath) && (!getbool("Do you want a list of help topics?",1))) {
- return;
- }
- }
- else { /* chop at * */
- star = index (topic,'*');
- if (star) *star = 0;
- }
-
- if (helppath == 0) { /* no help at all */
- printf ("Sorry, no specific help is available for this program.\n");
- }
- else {
- _h_found = 0;
- _h_list = fnames;
- _h_nlist = names;
- searchp (helppath,"*",dir,_ci_help); /* find file names */
- qsort (fnames,_h_found,sizeof(char *),ci_hcomp);
-
- for (i=0; i<_h_found; i++) { /* strip pathnames */
- path (fnames[i],dir,names[i]);
- nptr[i] = names[i];
- }
- nptr[i] = 0;
-
- if (*topic) { /* request some topic */
- if (_h_found == 0) {
- printf ("No help for %s. Type '?*' for list of help messages.\n",topic);
- }
- else {
- i = stablk (topic,nptr,1);
- if (i < 0) i = stabsearch (topic,nptr,0);
- if (i >= 0) {
- f = fopen (fnames[i],"r");
- if (f == 0)
- printf ("Yikes! Can't open help file %s\n",fnames[i]);
- else {
- printf ("\n");
- runp("more","more",fnames[i],0);
- if (_del_) {_DELNOTE_}
- printf ("\n");
- fclose (f);
- }
- }
- }
- }
- else { /* request topic list */
- printf ("\nHelp is available for these topics:\n");
- prstab (nptr);
- if (_del_) {_DELNOTE_}
- printf ("\n");
- }
-
- for (i=0; i<_h_found; i++) free (fnames[i]);
-
- }
-}
-
-/*********************************************************
- *** S H O W V A L U E O F V A R I A B L E ***
- *********************************************************/
-
-static ci_show (entry,arg,mode)
-CIENTRY entry; /* entry to display */
-char *arg; /* arg for variable procedures */
-CIMODE mode; /* mode (CIPEEK or CISHOW) */
-{
- if (entry.ci_etyp == ci_tproc) { /* procedure */
- (* (int(*)()) (entry.ci_eptr)) (mode,arg);
- }
- else if (entry.ci_etyp == ci_tclass) { /* class variable */
- (* (int(*)()) (entry.ci_eptr)) (mode,arg,entry.ci_evar,entry.ci_enam);
- }
- else {
- printf ("%-14s \t",entry.ci_enam);
- _ci_sho (entry.ci_etyp, entry.ci_eptr);
- printf ("\n");
- }
-}
-
-static _ci_sho (etype,eptr)
-ci_type etype;
-ci_union *eptr;
-{
- int i;
- unsigned int u;
-
- switch (etype) {
-
- case ci_tint:
- printf ("%d",eptr->ci_uint);
- break;
- case ci_tshort:
- printf ("%d",eptr->ci_ushort);
- break;
- case ci_tlong:
- printf ("%D",eptr->ci_ulong);
- break;
- case ci_toct:
- if (eptr->ci_uoct) printf ("0");
- printf ("%o",eptr->ci_uoct);
- break;
- case ci_thex:
- if (eptr->ci_uhex) printf ("0x");
- printf ("%x",eptr->ci_uhex);
- break;
- case ci_tdouble:
- printf ("%g",eptr->ci_udouble);
- break;
- case ci_tfloat:
- printf ("%g",eptr->ci_ufloat);
- break;
- case ci_tbool:
- if (eptr->ci_ubool) printf ("yes");
- else printf ("no");
- break;
- case ci_tstring:
- printf ("%s",(char *)eptr);
- break;
- case ci_tcint:
- printf ("%d",*(eptr->ci_ucint.ci_ival));
- break;
- case ci_tcshort:
- printf ("%d",*(eptr->ci_ucshort.ci_sval));
- break;
- case ci_tclong:
- printf ("%D",*(eptr->ci_uclong.ci_lval));
- break;
- case ci_tcoct:
- u = *(eptr->ci_ucoct.ci_uval);
- if (u) printf ("0");
- printf ("%o",u);
- break;
- case ci_tchex:
- u = *(eptr->ci_uchex.ci_uval);
- if (u) printf ("0x");
- printf ("%x",u);
- break;
- case ci_tcdouble:
- printf ("%g",*(eptr->ci_ucdouble.ci_dval));
- break;
- case ci_tcfloat:
- printf ("%g",*(eptr->ci_ucfloat.ci_fval));
- break;
- case ci_tcbool:
- i = *(eptr->ci_ucbool.ci_bval);
- if (i) printf ("yes");
- else printf ("no");
- break;
- case ci_tcchr:
- i = *(eptr->ci_ucchr.ci_cval);
- printf ("%c",eptr->ci_ucchr.ci_cleg[i]);
- break;
- case ci_tcstring:
- printf ("%s",eptr->ci_ucstring.ci_pval);
- break;
- case ci_tctab:
- i = *(eptr->ci_ucstab.ci_tval);
- printf ("%s",eptr->ci_ucstab.ci_ttab[i]);
- break;
- case ci_tcsearch:
- i = *(eptr->ci_ucsearch.ci_tval);
- printf ("%s",eptr->ci_ucsearch.ci_ttab[i]);
- break;
- default:
- printf ("Yeek! Illegal cientry type %d!\n",(int) etype);
- }
-}
-
-/*************************************************************
- *** A S S I G N V A L U E T O V A R I A B L E ***
- *************************************************************/
-
-static ci_set (entry,arg)
-CIENTRY entry;
-char *arg;
-{
- if (entry.ci_etyp == ci_tproc) { /* variable procedure */
- (* (int(*)()) (entry.ci_eptr)) (CISET,arg);
- }
- else if (entry.ci_etyp == ci_tclass) { /* class variable */
- (* (int(*)()) (entry.ci_eptr)) (CISET,arg,entry.ci_evar,entry.ci_enam);
- }
- else {
- _ci_set (entry.ci_etyp, entry.ci_eptr, arg);
- if (!(ciquiet & (((ciinput==stdin)||(ciinput==stderr)) ? CISETPEEK : CICMDFPEEK)))
- ci_show (entry,arg,CIPEEK);
- }
-}
-
-static _ci_set (etype,eptr,arg)
-ci_type etype;
-ci_union *eptr;
-char *arg;
-{
- int i;
- unsigned int u;
- char *p;
-
- if (etype == ci_tstring) {
- strcpy ((char *)eptr,arg);
- return;
- }
- if (etype == ci_tcstring) {
- strarg (&arg, ";", eptr->ci_ucstring.ci_pmsg,
- eptr->ci_ucstring.ci_pval,eptr->ci_ucstring.ci_pval);
- return;
- }
-
- p = arg; /* parse first word */
- arg = nxtarg (&p,0);
-
- switch (etype) {
-
- case ci_tint:
- eptr->ci_uint = atoi (arg);
- break;
- case ci_tshort:
- eptr->ci_ushort = atoi (arg);
- break;
- case ci_tlong:
- eptr->ci_ulong = atol (arg);
- break;
- case ci_toct:
- eptr->ci_uoct = atoo (arg);
- break;
- case ci_thex:
- if (stlmatch(arg,"0x") || stlmatch(arg,"0X")) arg += 2;
- eptr->ci_uhex = atoh (arg);
- break;
- case ci_tdouble:
- eptr->ci_udouble = atof (arg);
- break;
- case ci_tfloat:
- eptr->ci_ufloat = atof (arg);
- break;
- case ci_tbool:
- eptr->ci_ubool = (index("yYtT",*arg) != 0);
- break;
- case ci_tcint:
- *(eptr->ci_ucint.ci_ival) =
- intarg (&arg,0,eptr->ci_ucint.ci_imsg,eptr->ci_ucint.ci_imin,
- eptr->ci_ucint.ci_imax,*(eptr->ci_ucint.ci_ival));
- break;
- case ci_tcshort:
- *(eptr->ci_ucshort.ci_sval) =
- shortarg (&arg,0,eptr->ci_ucshort.ci_smsg,eptr->ci_ucshort.ci_smin,
- eptr->ci_ucshort.ci_smax,*(eptr->ci_ucshort.ci_sval));
- break;
- case ci_tclong:
- *(eptr->ci_uclong.ci_lval) =
- longarg (&arg,0,eptr->ci_uclong.ci_lmsg,eptr->ci_uclong.ci_lmin,
- eptr->ci_uclong.ci_lmax,*(eptr->ci_uclong.ci_lval));
- break;
- case ci_tcoct:
- *(eptr->ci_ucoct.ci_uval) =
- octarg (&arg,0,eptr->ci_ucoct.ci_umsg,eptr->ci_ucoct.ci_umin,
- eptr->ci_ucoct.ci_umax,*(eptr->ci_ucoct.ci_uval));
- break;
- case ci_tchex:
- *(eptr->ci_uchex.ci_uval) =
- hexarg (&arg,0,eptr->ci_uchex.ci_umsg,eptr->ci_uchex.ci_umin,
- eptr->ci_uchex.ci_umax,*(eptr->ci_uchex.ci_uval));
- break;
- case ci_tcdouble:
- *(eptr->ci_ucdouble.ci_dval) =
- doublearg (&arg,0,eptr->ci_ucdouble.ci_dmsg,eptr->ci_ucdouble.ci_dmin,
- eptr->ci_ucdouble.ci_dmax,*(eptr->ci_ucdouble.ci_dval));
- break;
- case ci_tcfloat:
- *(eptr->ci_ucfloat.ci_fval) =
- floatarg (&arg,0,eptr->ci_ucfloat.ci_fmsg,eptr->ci_ucfloat.ci_fmin,
- eptr->ci_ucfloat.ci_fmax,*(eptr->ci_ucfloat.ci_fval));
- break;
- case ci_tcbool:
- *(eptr->ci_ucbool.ci_bval) =
- boolarg (&arg,0,eptr->ci_ucbool.ci_bmsg,*(eptr->ci_ucbool.ci_bval));
- break;
- case ci_tcchr:
- *(eptr->ci_ucchr.ci_cval) =
- chrarg (&arg,0,eptr->ci_ucchr.ci_cmsg,eptr->ci_ucchr.ci_cleg,
- eptr->ci_ucchr.ci_cleg[*(eptr->ci_ucchr.ci_cval)]);
- break;
- case ci_tctab:
- *(eptr->ci_ucstab.ci_tval) =
- stabarg (&arg,0,eptr->ci_ucstab.ci_tmsg,eptr->ci_ucstab.ci_ttab,
- eptr->ci_ucstab.ci_ttab[*(eptr->ci_ucstab.ci_tval)]);
- break;
- case ci_tcsearch:
- *(eptr->ci_ucsearch.ci_tval) =
- searcharg (&arg,0,eptr->ci_ucsearch.ci_tmsg,
- eptr->ci_ucsearch.ci_ttab,
- eptr->ci_ucsearch.ci_ttab[*(eptr->ci_ucsearch.ci_tval)]);
- break;
- default:;
- }
-}
diff --git a/usr.sbin/sup/lib/errmsg.c b/usr.sbin/sup/lib/errmsg.c
deleted file mode 100644
index 0ca7c9d..0000000
--- a/usr.sbin/sup/lib/errmsg.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*****************************************************************
- * HISTORY
- * 04-Mar-85 Rudy Nedved (ern) at Carnegie-Mellon University
- * Create a CMU version of the BBN errmsg routine from scratch. It
- * differs from the BBN errmsg routine in the fact that it uses a
- * negative value to indicate using the current errno value...the
- * BBN uses a negative OR zero value.
- */
-
-extern int errno;
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-static char *itoa(p,n)
-char *p;
-unsigned n;
-{
- if (n >= 10)
- p =itoa(p,n/10);
- *p++ = (n%10)+'0';
- return(p);
-}
-
-char *errmsg(cod)
-int cod;
-{
- static char unkmsg[] = "Unknown error ";
- static char unk[sizeof(unkmsg)+11]; /* trust us */
-
- if (cod < 0) cod = errno;
-
- if((cod >= 0) && (cod < sys_nerr))
- return(sys_errlist[cod]);
-
- strcpy(unk,unkmsg);
- *itoa(&unk[sizeof(unkmsg)-1],cod) = '\0';
-
- return(unk);
-}
diff --git a/usr.sbin/sup/lib/expand.c b/usr.sbin/sup/lib/expand.c
deleted file mode 100644
index b909efc..0000000
--- a/usr.sbin/sup/lib/expand.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * expand - expand wildcard filename specifications
- *
- * Usage:
- * int expand(spec, buffer, bufsize);
- * char *spec, **buffer;
- * int bufsize;
- *
- * Expand takes a file specification, and expands it into filenames
- * by resolving the characters '*', '?', '[', ']', '{', '}' and '~'
- * in the same manner as the shell. You provide "buffer", which is
- * an array of char *'s, and you tell how big it is in bufsize.
- * Expand will compute the corresponding filenames, and will fill up
- * the entries of buffer with pointers to malloc'd strings.
- *
- * The value returned by expand is the number of filenames found. If
- * this value is -1, then malloc failed to allocate a string. If the
- * value is bufsize + 1, then too many names were found and you can try
- * again with a bigger buffer.
- *
- * This routine was basically created from the csh sh.glob.c file with
- * the following intended differences:
- *
- * Filenames are not sorted.
- * All expanded filenames returned exist.
- *
- **********************************************************************
- * HISTORY
- * 13-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Replaced a stat() with lstat() and changed glob() to only call
- * matchdir() for directories.
- *
- * 20-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created from csh glob() function and 4.1 expand() function.
- *
- **********************************************************************
- */
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <pwd.h>
-#include <ctype.h>
-#include <libc.h>
-#include <setjmp.h>
-
-static jmp_buf sjbuf;
-
-static char pathbuf[MAXPATHLEN];
-static char *path, *pathp, *lastpathp;
-
-static char *globchars = "{[*?"; /* meta characters */
-static char *entp; /* current dir entry pointer */
-
-static char **BUFFER; /* pointer to the buffer */
-static int BUFSIZE; /* maximum number in buffer */
-static int bufcnt; /* current number in buffer */
-
-#if __STDC__
-static addone __P((register char *, register char *));
-static addpath __P((char));
-static amatch __P((char *, char *));
-static execbrc __P((char *, char *));
-static gethdir __P((char *));
-static glob __P((char *));
-static matchdir __P((char *));
-static match __P((char *, char *));
-#endif
-
-int expand(spec, buffer, bufsize)
- register char *spec;
- char **buffer;
- int bufsize;
-{
- pathp = path = pathbuf;
- *pathp = 0;
- lastpathp = &path[MAXPATHLEN - 2];
- BUFFER = buffer;
- BUFSIZE = bufsize;
- bufcnt = 0;
- if (setjmp(sjbuf) == 0)
- glob(spec);
- return(bufcnt);
-}
-
-static glob(as)
- char *as;
-{
- register char *cs;
- register char *spathp, *oldcs;
- struct stat stb;
-
- spathp = pathp;
- cs = as;
- if (*cs == '~' && pathp == path) {
- if (addpath('~')) goto endit;
- for (cs++; isalnum(*cs) || *cs == '_' || *cs == '-';)
- if (addpath(*cs++)) goto endit;
- if (!*cs || *cs == '/') {
- if (pathp != path + 1) {
- *pathp = 0;
- if (gethdir(path + 1)) goto endit;
- strcpy(path, path + 1);
- } else
- strcpy(path, (char *)getenv("HOME"));
- pathp = path;
- while (*pathp) pathp++;
- }
- }
- while (*cs == 0 || index(globchars, *cs) == 0) {
- if (*cs == 0) {
- if (lstat(path, &stb) >= 0) addone(path, "");
- goto endit;
- }
- if (addpath(*cs++)) goto endit;
- }
- oldcs = cs;
- while (cs > as && *cs != '/')
- cs--, pathp--;
- if (*cs == '/')
- cs++, pathp++;
- *pathp = 0;
- if (*oldcs == '{') {
- execbrc(cs, NULL);
- return;
- }
- /* this should not be an lstat */
- if (stat(path, &stb) >= 0 && (stb.st_mode&S_IFMT) == S_IFDIR)
- matchdir(cs);
-endit:
- pathp = spathp;
- *pathp = 0;
- return;
-}
-
-static matchdir(pattern)
- char *pattern;
-{
- register struct dirent *dp;
- DIR *dirp;
-
- dirp = opendir(path);
- if (dirp == NULL)
- return;
- while ((dp = readdir(dirp)) != NULL) {
- if (dp->d_ino == 0) continue;
- if (match(dp->d_name, pattern))
- addone(path, dp->d_name);
- }
- closedir(dirp);
- return;
-}
-
-static execbrc(p, s)
- char *p, *s;
-{
- char restbuf[MAXPATHLEN + 1];
- register char *pe, *pm, *pl;
- int brclev = 0;
- char *lm, savec, *spathp;
-
- for (lm = restbuf; *p != '{'; *lm++ = *p++)
- continue;
- for (pe = ++p; *pe; pe++)
- switch (*pe) {
- case '{':
- brclev++;
- continue;
- case '}':
- if (brclev == 0) goto pend;
- brclev--;
- continue;
- case '[':
- for (pe++; *pe && *pe != ']'; pe++)
- continue;
- if (!*pe) break;
- continue;
- }
-pend:
- if (brclev || !*pe) return (0);
- for (pl = pm = p; pm <= pe; pm++)
- switch (*pm & 0177) {
- case '{':
- brclev++;
- continue;
- case '}':
- if (brclev) {
- brclev--;
- continue;
- }
- goto doit;
- case ',':
- if (brclev) continue;
-doit:
- savec = *pm;
- *pm = 0;
- strcpy(lm, pl);
- strcat(restbuf, pe + 1);
- *pm = savec;
- if (s == 0) {
- spathp = pathp;
- glob(restbuf);
- pathp = spathp;
- *pathp = 0;
- } else if (amatch(s, restbuf))
- return (1);
- pl = pm + 1;
- continue;
-
- case '[':
- for (pm++; *pm && *pm != ']'; pm++)
- continue;
- if (!*pm) break;
- continue;
- }
- return (0);
-}
-
-static match(s, p)
- char *s, *p;
-{
- register int c;
- register char *sentp;
-
- if (*s == '.' && *p != '.') return(0);
- sentp = entp;
- entp = s;
- c = amatch(s, p);
- entp = sentp;
- return (c);
-}
-
-static amatch(s, p)
- register char *s, *p;
-{
- register int scc;
- int ok, lc;
- char *spathp;
- struct stat stb;
- int c, cc;
-
- for (;;) {
- scc = *s++ & 0177;
- switch (c = *p++) {
- case '{':
- return (execbrc(p - 1, s - 1));
- case '[':
- ok = 0;
- lc = 077777;
- while (cc = *p++) {
- if (cc == ']') {
- if (ok) break;
- return (0);
- }
- if (cc == '-') {
- if (lc <= scc && scc <= *p++)
- ok++;
- } else
- if (scc == (lc = cc))
- ok++;
- }
- if (cc == 0) return (0);
- continue;
- case '*':
- if (!*p) return (1);
- if (*p == '/') {
- p++;
- goto slash;
- }
- for (s--; *s; s++)
- if (amatch(s, p))
- return (1);
- return (0);
- case 0:
- return (scc == 0);
- default:
- if (c != scc) return (0);
- continue;
- case '?':
- if (scc == 0) return (0);
- continue;
- case '/':
- if (scc) return (0);
-slash:
- s = entp;
- spathp = pathp;
- while (*s)
- if (addpath(*s++)) goto pathovfl;
- if (addpath('/')) goto pathovfl;
- if (stat(path, &stb) >= 0 &&
- (stb.st_mode&S_IFMT) == S_IFDIR)
- if (*p == 0)
- addone(path, "");
- else
- glob(p);
-pathovfl:
- pathp = spathp;
- *pathp = 0;
- return (0);
- }
- }
-}
-
-static addone(s1, s2)
- register char *s1, *s2;
-{
- register char *ep;
-
- if (bufcnt >= BUFSIZE) {
- bufcnt = BUFSIZE + 1;
- longjmp(sjbuf, 1);
- }
- ep = (char *)malloc(strlen(s1) + strlen(s2) + 1);
- if (ep == 0) {
- bufcnt = -1;
- longjmp(sjbuf, 1);
- }
- BUFFER[bufcnt++] = ep;
- while (*s1) *ep++ = *s1++;
- while (*ep++ = *s2++);
-}
-
-static addpath(c)
- char c;
-{
- if (pathp >= lastpathp)
- return(1);
- *pathp++ = c;
- *pathp = 0;
- return(0);
-}
-
-static gethdir(home)
- char *home;
-{
- struct passwd *getpwnam();
- register struct passwd *pp = getpwnam(home);
-
- if (pp == 0)
- return(1);
- strcpy(home, pp->pw_dir);
- return(0);
-}
diff --git a/usr.sbin/sup/lib/ffilecopy.c b/usr.sbin/sup/lib/ffilecopy.c
deleted file mode 100644
index edef883..0000000
--- a/usr.sbin/sup/lib/ffilecopy.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* ffilecopy -- very fast buffered file copy
- *
- * Usage: i = ffilecopy (here,there)
- * int i;
- * FILE *here, *there;
- *
- * Ffilecopy is a very fast routine to copy the rest of a buffered
- * input file to a buffered output file. Here and there are open
- * buffers for reading and writing (respectively); ffilecopy
- * performs a file-copy faster than you should expect to do it
- * yourself. Ffilecopy returns 0 if everything was OK; EOF if
- * there was any error. Normally, the input file will be left in
- * EOF state (feof(here) will return TRUE), and the output file will be
- * flushed (i.e. all data on the file rather in the core buffer).
- * It is not necessary to flush the output file before ffilecopy.
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for VAX.
- *
- */
-
-#include <stdio.h>
-int filecopy();
-
-int ffilecopy (here,there)
-FILE *here, *there;
-{
- register int i, herefile, therefile;
-
- herefile = fileno(here);
- therefile = fileno(there);
-
- if (fflush (there) == EOF) /* flush pending output */
- return (EOF);
-
-#ifdef __FreeBSD__
- if ((here->_r) > 0) { /* flush buffered input */
- i = write (therefile, here->_p, here->_r);
- if (i != here->_r) return (EOF);
- here->_p = here->_bf._base;
- here->_r = 0;
- }
-#else
- if ((here->_cnt) > 0) { /* flush buffered input */
- i = write (therefile, here->_ptr, here->_cnt);
- if (i != here->_cnt) return (EOF);
- here->_ptr = here->_base;
- here->_cnt = 0;
- }
-#endif
- i = filecopy (herefile, therefile); /* fast file copy */
- if (i < 0) return (EOF);
-
-#ifdef __FreeBSD__
- (here->_flags) |= __SEOF; /* indicate EOF */
-#else
- (here->_flag) |= _IOEOF; /* indicate EOF */
-#endif
- return (0);
-}
diff --git a/usr.sbin/sup/lib/filecopy.c b/usr.sbin/sup/lib/filecopy.c
deleted file mode 100644
index 553becb..0000000
--- a/usr.sbin/sup/lib/filecopy.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* filecopy -- copy a file from here to there
- *
- * Usage: i = filecopy (here,there);
- * int i, here, there;
- *
- * Filecopy performs a fast copy of the file "here" to the
- * file "there". Here and there are both file descriptors of
- * open files; here is open for input, and there for output.
- * Filecopy returns 0 if all is OK; -1 on error.
- *
- * I have performed some tests for possible improvements to filecopy.
- * Using a buffer size of 10240 provides about a 1.5 times speedup
- * over 512 for a file of about 200,000 bytes. Of course, other
- * buffer sized should also work; this is a rather arbitrary choice.
- * I have also tried inserting special startup code to attempt
- * to align either the input or the output file to lie on a
- * physical (512-byte) block boundary prior to the big loop,
- * but this presents only a small (about 5% speedup, so I've
- * canned that code. The simple thing seems to be good enough.
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Rewritten for VAX; same as "filcopy" on PDP-11. Bigger buffer
- * size (20 physical blocks) seems to be a big win; aligning things
- * on block boundaries seems to be a negligible improvement at
- * considerable cost in complexity.
- *
- */
-
-#define BUFFERSIZE 10240
-
-int filecopy (here,there)
-int here,there;
-{
- register int kount;
- char buffer[BUFFERSIZE];
- kount = 0;
- while (kount == 0 && (kount=read(here,buffer,BUFFERSIZE)) > 0)
- kount -= write (there,buffer,kount);
- return (kount ? -1 : 0);
-}
diff --git a/usr.sbin/sup/lib/libc.h b/usr.sbin/sup/lib/libc.h
deleted file mode 100644
index 0e59542..0000000
--- a/usr.sbin/sup/lib/libc.h
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- **********************************************************************
- * HISTORY
- * $Log: libc.h,v $
- * Revision 1.2 1995/12/26 05:02:45 peter
- * Apply ports/net/sup/patches/patch-aa...
- *
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.7 89/04/03 11:10:45 vanryzin
- * Changed definition of qsort for c++ to indicate the procedure
- * passed to qsort has parameters. Since we were unsure if ANSI C
- * could handle the syntax I placed the new definition within #if
- * defined(c_plusplus) conditionals. This may not be necessary
- * and perhaps should be fixed at a later time.
- * [89/04/03 vanryzin]
- *
- * Revision 1.6 89/02/05 15:55:57 gm0w
- * Added extern char *errmsg().
- * [89/02/04 gm0w]
- *
- * Revision 1.5 89/01/20 15:34:40 gm0w
- * Moved all of the STDC changes to other existing include files
- * back into this one. Added non-STDC extern declarations for
- * all functions without int return values to match those defined
- * by STDC. Added include of sysent.h. Removed obsolete cdate
- * extern declaration.
- * [88/12/17 gm0w]
- *
- * Revision 1.4 88/12/22 16:58:56 mja
- * Correct __STDC__ parameter type for getenv().
- * [88/12/20 dld]
- *
- * Revision 1.3 88/12/14 23:31:42 mja
- * Made file reentrant. Added declarations for __STDC__.
- * [88/01/06 jjk]
- *
- * 30-Apr-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added pathof() extern.
- *
- * 01-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added getname() extern.
- *
- * 29-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added lseek() extern.
- *
- * 02-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added salloc() extern.
- *
- * 14-Aug-81 Mike Accetta (mja) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#ifndef _LIBC_H_
-#define _LIBC_H_ 1
-
-#if defined(__hpux)
-#define __P(x) x
-#endif
-
-#ifndef _TYPES_
-#include <sys/types.h>
-#endif /* _TYPES_ */
-
-#ifndef FILE
-#include <stdio.h>
-#endif /* FILE */
-
-#ifndef _STRINGS_H_
-#include <strings.h>
-#endif /* _STRINGS_H_ */
-
-#ifndef _TIME_H_
-#include <time.h>
-#endif /* _TIME_H_ */
-
-/* CMU stdio additions */
-#if defined(__STDC__)
-extern FILE *fopenp(const char*, const char*, char*, char*);
-extern FILE *fwantread(const char*, const char*, const char*, const char*);
-extern FILE *fwantwrite(const char*, const char*, const char*, const char*,
- int);
-#else /* __STDC__ */
-extern FILE *fopenp();
-extern FILE *fwantread();
-extern FILE *fwantwrite();
-#endif /* __STDC__ */
-
-/* CMU string routines */
-#if defined(__STDC__)
-extern char* foldup(char*, const char*);
-extern char* folddown(char*, const char*);
-extern char* sindex(const char*, const char*);
-extern char* skipto(const char*, const char*);
-extern char* skipover(const char*, const char*);
-extern char* nxtarg(char**, const char*);
-extern char _argbreak;
-extern char* getstr(const char*, char*, char*);
-extern int getstab(const char*, const char**, const char*);
-extern int getsearch(const char*, const char**, const char*);
-extern char* strarg(const char**, const char*, const char*, char*, char*);
-extern int stabarg(const char**, const char*, const char*, const char**,
- const char*);
-extern int searcharg(const char**, const char*, const char*, const char**,
- const char*);
-extern int getint(const char*, int, int, int);
-extern int intarg(const char**, const char*, const char*, int, int, int);
-extern long getlong(const char*, long, long, long);
-extern long longarg(const char**, const char*, const char*, long, long, long);
-extern short getshort(const char*, short, short, short);
-extern short shortarg(const char**, const char*, const char*,
- short, short, short);
-extern float getfloat(const char*, float, float, float);
-extern float floatarg(const char**, const char*, const char*,
- float, float, float);
-extern double getdouble(const char*, double, double, double);
-extern double doublearg(const char**, const char*, const char*,
- double, double, double);
-extern unsigned int getoct(const char*, unsigned int, unsigned int,
- unsigned int);
-extern unsigned int octarg(const char**, const char*, const char*,
- unsigned int, unsigned int, unsigned int);
-extern unsigned int gethex(const char*, unsigned int, unsigned int,
- unsigned int);
-extern unsigned int hexarg(const char**, const char*, const char*,
- unsigned int, unsigned int, unsigned int);
-extern unsigned int atoo(const char*);
-extern unsigned int atoh(const char*);
-extern char *salloc(const char*);
-extern char *concat(const char*, int, ...);
-#else /* __STDC__ */
-extern char *foldup(), *folddown();
-extern char *sindex(), *skipto(), *skipover(), *nxtarg();
-extern char *getstr(), *strarg();
-extern long getlong(), longarg();
-extern short getshort(), shortarg();
-extern float getfloat(), floatarg();
-extern double getdouble(), doublearg();
-extern unsigned int getoct(), octarg(), gethex(), hexarg();
-extern unsigned int atoo(), atoh();
-extern char *salloc();
-extern char *concat();
-#endif /* __STDC__ */
-
-/* CMU library routines */
-#if defined(__STDC__)
-extern char *getname(int);
-extern char *pathof(char *);
-extern char *errmsg(int);
-#else /* __STDC__ */
-extern char *getname();
-extern char *pathof();
-extern char *errmsg();
-#endif /* __STDC__ */
-
-/* CMU time additions */
-#if defined(__STDC__)
-extern long gtime(const struct tm*);
-extern long atot(const char*);
-#else /* __STDC__ */
-extern long gtime();
-extern long atot();
-#endif /* __STDC__ */
-
-/* 4.3 BSD standard library routines; taken from man(3) */
-#if defined(__STDC__)
-typedef int (*PFI)();
-#if defined(c_plusplus)
-typedef int (*PFI2)(...);
-#endif /* c_plusplus */
-
-#if defined(__hpux)
-extern int utimes(char *, struct timeval *);
-
-#ifndef LOCK_SH
-#define LOCK_SH 1
-#endif
-#ifndef LOCK_EX
-#define LOCK_EX 2
-#endif
-#ifndef LOCK_NB
-#define LOCK_NB 4
-#endif
-#ifndef LOCK_UN
-#define LOCK_UN 8
-#endif
-
-extern int flock(int, int);
-#endif /* __hpux */
-
-#if 0
-extern void abort(void);
-extern int abs(int);
-extern double atof(const char *);
-extern int atoi(const char *);
-extern long atol(const char *);
-extern void bcopy(const void *, void *, int);
-extern int bcmp(const void *, const void *, int);
-extern void bzero(void *, int);
-extern int ffs(int);
-extern char *crypt(const char *, const char *);
-extern void setkey(char *);
-extern void encrypt(char *, int);
-extern char *ecvt(double, int, int *, int *);
-extern char *fcvt(double, int, int *, int *);
-extern char *gcvt(double, int, char *);
-extern int execl(const char *, ...);
-extern int execv(const char *, const char **);
-extern int execle(const char *, ...);
-extern int exect(const char *, const char **, const char **);
-extern void exit(int);
-extern char *getenv(const char *);
-extern char *getlogin(void);
-extern int getopt(int, const char **, const char *);
-extern char *getpass(const char *);
-extern char *getusershell(void);
-extern void setusershell(void);
-extern void endusershell(void);
-extern char *getwd(char *);
-extern int initgroups(const char *, gid_t);
-extern void *malloc(unsigned);
-extern void free(void *);
-extern void *realloc(void *, unsigned);
-extern void *calloc(unsigned, unsigned);
-extern void *alloca(int);
-extern char *mktemp(char *);
-extern int mkstemp(char *);
-extern void monitor(PFI, PFI, short *, int, int);
-extern void monstartup(PFI, PFI);
-extern void moncontrol(int);
-extern int pause(void);
-#if defined(c_plusplus)
-extern void qsort(void *, int, int, PFI2);
-#else /* c_plusplus */
-extern void qsort(void *, int, int, PFI);
-#endif /* c_plusplus */
-extern long random(void);
-extern int srandom(int);
-extern void *initstate(unsigned, void *, int);
-extern void *setstate(void *);
-extern int rcmd(char **, int, const char *, const char *, const char *, int);
-extern int rresvport(int *);
-extern int ruserok(char *, int, const char *, const char *);
-extern char *re_comp(char *);
-extern int re_exec(char *);
-extern int rexec(char **, int, const char *, const char *, const char *,
- int *);
-extern int setuid(uid_t);
-extern int seteuid(uid_t);
-extern int setruid(uid_t);
-extern int setgid(gid_t);
-extern int setegid(gid_t);
-extern int setrgid(gid_t);
-extern void sleep(unsigned);
-extern void swab(void *, void *, int);
-extern int system(const char *);
-extern char *ttyname(int);
-extern int isatty(int);
-extern int ttyslot(void);
-extern unsigned ualarm(unsigned, unsigned);
-extern void usleep(unsigned);
-#endif
-#else /* __STDC__ */
-extern double atof();
-extern long atol();
-extern char *crypt();
-extern char *ecvt();
-extern char *fcvt();
-extern char *gcvt();
-extern char *getenv();
-extern char *getlogin();
-extern char *getpass();
-extern char *getusershell();
-extern char *getwd();
-extern char *malloc();
-extern char *realloc();
-extern char *calloc();
-extern char *alloca();
-extern char *mktemp();
-extern long random();
-extern char *initstate();
-extern char *setstate();
-extern char *re_comp();
-extern char *ttyname();
-extern unsigned ualarm();
-#endif /* __STDC__ */
-#endif /* not _LIBC_H_ */
diff --git a/usr.sbin/sup/lib/log.c b/usr.sbin/sup/lib/log.c
deleted file mode 100644
index 2974b4a..0000000
--- a/usr.sbin/sup/lib/log.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Logging support for SUP
- **********************************************************************
- * HISTORY
- * $Log: log.c,v $
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.5 92/08/11 12:03:43 mrt
- * Brad's delinting and variable argument list usage
- * changes. Added copyright.
- *
- * Revision 1.3 89/08/15 15:30:37 bww
- * Updated to use v*printf() in place of _doprnt().
- * From "[89/04/19 mja]" at CMU.
- * [89/08/15 bww]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check to allow logopen() to be called multiple times.
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#include <stdio.h>
-#ifdef __hpux
-#include <syslog.h>
-#include <stdlib.h>
-#else
-#include <sys/syslog.h>
-#include <c.h>
-#endif
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "sup.h"
-
-#ifdef lint
-/*VARARGS1*//*ARGSUSED*/
-static void quit(status) {};
-#endif /* lint */
-
-static int opened = 0;
-
-logopen(program)
-char *program;
-{
- if (opened) return;
- openlog(program,LOG_PID,LOG_LOCAL1);
- opened++;
-}
-
-#if __STDC__
-logquit(int retval,char *fmt,...)
-#else
-/*VARARGS*//*ARGSUSED*/
-logquit(va_alist)
-va_dcl
-#endif
-{
-#if !__STDC__
- int retval;
- char *fmt;
-#endif
- char buf[STRINGLENGTH];
- va_list ap;
-
-#if __STDC__
- va_start(ap,fmt);
-#else
- va_start(ap);
- retval = va_arg(ap,int);
- fmt = va_arg(ap,char *);
-#endif
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog (LOG_ERR,buf);
- closelog ();
- exit (retval);
- }
- quit (retval,"SUP: %s\n",buf);
-}
-
-#if __STDC__
-logerr(char *fmt,...)
-#else
-/*VARARGS*//*ARGSUSED*/
-logerr(va_alist)
-va_dcl
-#endif
-{
-#if !__STDC__
- char *fmt;
-#endif
- char buf[STRINGLENGTH];
- va_list ap;
-
-#if __STDC__
- va_start(ap,fmt);
-#else
- va_start(ap);
- fmt = va_arg(ap,char *);
-#endif
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog (LOG_ERR,buf);
- return;
- }
- fprintf (stderr,"SUP: %s\n",buf);
- (void) fflush (stderr);
-}
-
-#if __STDC__
-loginfo(char *fmt,...)
-#else
-/*VARARGS*//*ARGSUSED*/
-loginfo(va_alist)
-va_dcl
-#endif
-{
-#if !__STDC__
- char *fmt;
-#endif
- char buf[STRINGLENGTH];
- va_list ap;
-
-#if __STDC__
- va_start(ap,fmt);
-#else
- va_start(ap);
- fmt = va_arg(ap,char *);
-#endif
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog (LOG_INFO,buf);
- return;
- }
- printf ("%s\n",buf);
- (void) fflush (stdout);
-}
diff --git a/usr.sbin/sup/lib/netcryptvoid.c b/usr.sbin/sup/lib/netcryptvoid.c
deleted file mode 100644
index 9dd3c78..0000000
--- a/usr.sbin/sup/lib/netcryptvoid.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/**********************************************************************
- * HISTORY
- * $Log: netcryptvoid.c,v $
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 2.2 92/09/09 22:04:34 mrt
- * Created.
- * [92/09/09 mrt]
- *
- */
-/*
- * DATA ENCRYPTION
- * netcrypt (key) turn on/off encryption of strings and files
- * char *key; encryption key
- *
- */
-
-/*
- * Replacement for subroutine version of "crypt" program
- * for foreign and non-BSD-licensed sites. With this code
- * you can only run unencrypted sups
- */
-
-#include <libc.h>
-#include "sup.h"
-#include "supmsg.h"
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-int cryptflag = 0; /* whether to encrypt/decrypt data */
-char *cryptbuf; /* buffer for data encryption/decryption */
-
-int netcrypt (pword)
-char *pword;
-{
- if (pword == NULL || (strcmp(pword,PSWDCRYPT) == 0)) {
- cryptflag = 0;
- (void) getcryptbuf (0);
- return (SCMOK);
- }
- return (SCMERR);
-}
-int getcryptbuf (x)
-int x;
-{
- static int cryptsize = 0; /* size of current cryptbuf */
-
- if (cryptflag == 0) {
- return(SCMOK);
- } else
- return (SCMERR);
-}
-
-void decode (in,out,count)
-char *in,*out;
-int count;
-{
-}
-
-
-void encode (in,out,count)
-char *in,*out;
-int count;
-{
-}
diff --git a/usr.sbin/sup/lib/nxtarg.c b/usr.sbin/sup/lib/nxtarg.c
deleted file mode 100644
index 9e93c28..0000000
--- a/usr.sbin/sup/lib/nxtarg.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * nxtarg -- strip off arguments from a string
- *
- * Usage: p = nxtarg (&q,brk);
- * char *p,*q,*brk;
- * extern char _argbreak;
- *
- * q is pointer to next argument in string
- * after call, p points to string containing argument,
- * q points to remainder of string
- *
- * Leading blanks and tabs are skipped; the argument ends at the
- * first occurence of one of the characters in the string "brk".
- * When such a character is found, it is put into the external
- * variable "_argbreak", and replaced by a null character; if the
- * arg string ends before that, then the null character is
- * placed into _argbreak;
- * If "brk" is 0, then " " is substituted.
- *
- * HISTORY
- * 01-Jul-83 Steven Shafer (sas) at Carnegie-Mellon University
- * Bug fix: added check for "back >= front" in loop to chop trailing
- * white space.
- *
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Rewritten for VAX. By popular demand, a table of break characters
- * has been added (implemented as a string passed into nxtarg).
- *
- * Originally from klg (Ken Greer); IUS/SUS UNIX.
- */
-
-char _argbreak;
-char *skipto();
-
-char *nxtarg (q,brk)
-char **q,*brk;
-{
- register char *front,*back;
- front = *q; /* start of string */
- /* leading blanks and tabs */
- while (*front && (*front == ' ' || *front == '\t')) front++;
- /* find break character at end */
- if (brk == 0) brk = " ";
- back = skipto (front,brk);
- _argbreak = *back;
- *q = (*back ? back+1 : back); /* next arg start loc */
- /* elim trailing blanks and tabs */
- back -= 1;
- while ((back >= front) && (*back == ' ' || *back == '\t')) back--;
- back++;
- if (*back) *back = '\0';
- return (front);
-}
diff --git a/usr.sbin/sup/lib/path.c b/usr.sbin/sup/lib/path.c
deleted file mode 100644
index f982268..0000000
--- a/usr.sbin/sup/lib/path.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* path -- break filename into directory and file
- *
- * path (filename,direc,file);
- * char *filename,*direc,*file;
- * filename is input; direc and file are output (user-supplied).
- * file will not have any trailing /; direc might.
- *
- * Note these rules:
- * 1. trailing / are ignored (except as first character)
- * 2. x/y is x;y where y contains no / (x may contain /)
- * 3. /y is /;y where y contains no /
- * 4. y is .;y where y contains no /
- * 5. is .;. (null filename)
- * 6. / is /;. (the root directory)
- *
- * Algorithm is this:
- * 1. delete trailing / except in first position
- * 2. if any /, find last one; change to null; y++
- * else y = x; (x is direc; y is file)
- * 3. if y is null, y = .
- * 4. if x equals y, x = .
- * else if x is null, x = /
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Copied verbatim from PDP-11. Still as messy as ever.
- * Some people have asked for a modification (I think that's a better
- * idea than a new routine) which will change the directory name
- * into an absolute pathname if it isn't one already. The change
- * involves doing a getwd() and prepending that if appropriate, with
- * a "/" in between that and the directory part of the path.
- * If you want to be cute, you can also resolve ".."s at that time.
- *
- */
-
-path (original,direc,file)
-char *original,*direc,*file;
-{
- register char *y;
- /* x is direc */
- register char *p;
-
- /* copy and note the end */
- p = original;
- y = direc;
- while (*y++ = *p++) ; /* copy string */
- /* y now points to first char after null */
- --y; /* y now points to null */
- --y; /* y now points to last char of string before null */
-
- /* chop off trailing / except as first character */
- while (y>direc && *y == '/') --y; /* backpedal past / */
- /* y now points to char before first trailing / or null */
- *(++y) = 0; /* chop off end of string */
- /* y now points to null */
-
- /* find last /, if any. If found, change to null and bump y */
- while (y>direc && *y != '/') --y;
- /* y now points to / or direc. Note *direc may be / */
- if (*y == '/') {
- *y++ = 0;
- }
-
- /* find file name part */
- if (*y) strcpy (file,y);
- else strcpy (file,".");
-
- /* find directory part */
- if (direc == y) strcpy (direc,".");
- else if (*direc == 0) strcpy (direc,"/");
- /* else direc already has proper value */
-}
diff --git a/usr.sbin/sup/lib/quit.c b/usr.sbin/sup/lib/quit.c
deleted file mode 100644
index 23b4cb7..0000000
--- a/usr.sbin/sup/lib/quit.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * quit -- print message and exit
- *
- * Usage: quit (status,format [,arg]...);
- * int status;
- * (... format and arg[s] make up a printf-arglist)
- *
- * Quit is a way to easily print an arbitrary message and exit.
- * It is most useful for error exits from a program:
- * if (open (...) < 0) then quit (1,"Can't open...",file);
- *
- **********************************************************************
- * HISTORY
- * $Log: quit.c,v $
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.2 88/12/13 13:52:41 gm0w
- * Rewritten to use varargs.
- * [88/12/13 gm0w]
- *
- **********************************************************************
- */
-
-#include <stdio.h>
-#include <varargs.h>
-
-quit (status, fmt, va_alist)
-int status;
-char *fmt;
-va_dcl
-{
- va_list args;
-
- fflush(stdout);
- va_start(args);
- (void) vfprintf(stderr, fmt, args);
- va_end(args);
- exit(status);
-}
diff --git a/usr.sbin/sup/lib/run.c b/usr.sbin/sup/lib/run.c
deleted file mode 100644
index 0e9a581..0000000
--- a/usr.sbin/sup/lib/run.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* run, runv, runp, runvp -- execute process and wait for it to exit
- *
- * Usage:
- * i = run (file, arg1, arg2, ..., argn, 0);
- * i = runv (file, arglist);
- * i = runp (file, arg1, arg2, ..., argn, 0);
- * i = runvp (file, arglist);
- *
- * Run, runv, runp and runvp have argument lists exactly like the
- * corresponding routines, execl, execv, execlp, execvp. The run
- * routines perform a fork, then:
- * IN THE NEW PROCESS, an execl[p] or execv[p] is performed with the
- * specified arguments. The process returns with a -1 code if the
- * exec was not successful.
- * IN THE PARENT PROCESS, the signals SIGQUIT and SIGINT are disabled,
- * the process waits until the newly forked process exits, the
- * signals are restored to their original status, and the return
- * status of the process is analyzed.
- * All run routines return: -1 if the exec failed or if the child was
- * terminated abnormally; otherwise, the exit code of the child is
- * returned.
- *
- **********************************************************************
- * HISTORY
- * $Log: run.c,v $
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.1 89/10/14 19:53:39 rvb
- * Initial revision
- *
- * Revision 1.2 89/08/03 14:36:46 mja
- * Update run() and runp() to use <varargs.h>.
- * [89/04/19 mja]
- *
- * 23-Sep-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged old runv and runvp modules.
- *
- * 22-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check and kill if child process was stopped.
- *
- * 30-Apr-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Adapted for 4.2 BSD UNIX: Conforms to new signals and wait.
- *
- * 15-July-82 Mike Accetta (mja) and Neal Friedman (naf)
- * at Carnegie-Mellon University
- * Added a return(-1) if vfork fails. This should only happen
- * if there are no more processes available.
- *
- * 28-Jan-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Added setuid and setgid for system programs' use.
- *
- * 21-Jan-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Changed fork to vfork.
- *
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for VAX. The proper way to fork-and-execute a system
- * program is now by "runvp" or "runp", with the program name
- * (rather than an absolute pathname) as the first argument;
- * that way, the "PATH" variable in the environment does the right
- * thing. Too bad execvp and execlp (hence runvp and runp) don't
- * accept a pathlist as an explicit argument.
- *
- **********************************************************************
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <varargs.h>
-#define MAXARGS 100
-
-static int dorun();
-
-int run (name,va_alist)
-char *name;
-va_dcl
-{
- int val;
- va_list ap;
-
- va_start(ap);
- val = runv (name,ap);
- va_end(ap);
- return(val);
-}
-
-int runv (name,argv)
-char *name,**argv;
-{
- return (dorun (name, argv, 0));
-}
-
-int runp (name,va_alist)
-char *name;
-va_dcl
-{
- int val;
- va_list ap;
- char *args[MAXARGS];
- int argno=0;
-
- va_start(ap);
- while (argno < MAXARGS
- && (args[argno++] = va_arg(ap, char *)) != (char *)0);
- va_end(ap);
- val = runvp (name,args);
- return (val);
-}
-
-int runvp (name,argv)
-char *name,**argv;
-{
- return (dorun (name, argv, 1));
-}
-
-static
-int dorun (name,argv,usepath)
-char *name,**argv;
-int usepath;
-{
- int wpid;
- register int pid;
- struct sigvec ignoresig,intsig,quitsig;
- union wait status;
- int execvp(), execv();
- int (*execrtn)() = usepath ? execvp : execv;
-
- if ((pid = vfork()) == -1)
- return(-1); /* no more process's, so exit with error */
-
- if (pid == 0) { /* child process */
- setgid (getgid());
- setuid (getuid());
- (*execrtn) (name,argv);
- fprintf (stderr,"run: can't exec %s\n",name);
- _exit (0377);
- }
-
- ignoresig.sv_handler = SIG_IGN; /* ignore INT and QUIT signals */
- ignoresig.sv_mask = 0;
- ignoresig.sv_onstack = 0;
- sigvec (SIGINT,&ignoresig,&intsig);
- sigvec (SIGQUIT,&ignoresig,&quitsig);
- do {
- wpid = wait3 (&status.w_status, WUNTRACED, 0);
- if (WIFSTOPPED (status)) {
- kill (0,SIGTSTP);
- wpid = 0;
- }
- } while (wpid != pid && wpid != -1);
- sigvec (SIGINT,&intsig,0); /* restore signals */
- sigvec (SIGQUIT,&quitsig,0);
-
- if (WIFSIGNALED (status) || status.w_retcode == 0377)
- return (-1);
-
- return (status.w_retcode);
-}
diff --git a/usr.sbin/sup/lib/salloc.c b/usr.sbin/sup/lib/salloc.c
deleted file mode 100644
index bd0e804..0000000
--- a/usr.sbin/sup/lib/salloc.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- **********************************************************************
- * HISTORY
- * 09-Apr-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed to save length and use bcopy instead of strcpy.
- *
- * 02-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created from routine by same name in Steve Shafer's sup program.
- *
- **********************************************************************
- */
-char *malloc();
-
-char *salloc(p)
-char *p;
-{
- register char *q;
- register int l;
-
- q = malloc(l = strlen(p) + 1);
- if (q != 0)
- bcopy(p, q, l);
- return(q);
-}
diff --git a/usr.sbin/sup/lib/scan.c b/usr.sbin/sup/lib/scan.c
deleted file mode 100644
index 0823e4d..0000000
--- a/usr.sbin/sup/lib/scan.c
+++ /dev/null
@@ -1,1045 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * scan.c - sup list file scanner
- *
- **********************************************************************
- * HISTORY
- * $Log: scan.c,v $
- * Revision 1.3 1995/12/26 05:10:59 peter
- * Apply ports/net/sup/patches/patch-ab
- *
- * Revision 1.2 1995/12/26 05:02:48 peter
- * Apply ports/net/sup/patches/patch-aa...
- *
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.8 92/08/11 12:04:28 mrt
- * Brad's changes: delinted, added forward declarations of static
- * functions.Added Copyright.
- * [92/07/24 mrt]
- *
- * 18-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added host=<hostfile> support to releases file.
- *
- * 11-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added "rsymlink" recursive symbolic link quoting directive.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support.
- *
- * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Lets see if we'll be able to write the scan file BEFORE
- * we collect the data for it. Include sys/file.h and use
- * new definitions for access check codes.
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added type casting information for lint.
- *
- * 21-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check for newonly upgrade when lasttime is the same as
- * scantime. This will save us the trouble of parsing the scanfile
- * when the client has successfully received everything in the
- * scanfile already.
- *
- * 16-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Clear Texec pointers in execT so that Tfree of execT will not
- * free command trees associated with files in listT.
- *
- * 06-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to omit scanned files from list if we want new files
- * only and they are old.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Major rewrite for protocol version 4. Added version numbers to
- * scan file. Also added mode of file in addition to flags.
- * Execute commands are now immediately after file information.
- *
- * 13-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added comments to list file format.
- *
- * 08-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to implement omitany. Currently doesn't know about
- * {a,b,c} patterns.
- *
- * 07-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <c.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <dirent.h>
-#include "sup.h"
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-#define SPECNUMBER 1000
- /* number of filenames produced by a single spec in the list file */
-
-/*******************************************
- *** D A T A S T R U C T U R E S ***
- *******************************************/
-
-typedef enum { /* release options */
- ONEXT, OPREFIX, OLIST, OSCAN,
- OHOST
-} OPTION;
-
-static char *options[] = {
- "next", "prefix", "list", "scan",
- "host",
- 0
-};
-
-typedef enum { /* <collection>/list file lines */
- LUPGRADE, LOMIT, LBACKUP, LEXECUTE,
- LINCLUDE, LNOACCT, LOMITANY, LALWAYS,
- LSYMLINK, LRSYMLINK, LRENAME
-} LISTTYPE;
-
-static char *ltname[] = {
- "upgrade", "omit", "backup", "execute",
- "include", "noaccount", "omitany", "always",
- "symlink", "rsymlink", "rename",
- 0
-};
-
-#define FALWAYS FUPDATE
-
-/* list file lines */
-static TREE *upgT; /* files to upgrade */
-static TREE *flagsT; /* special flags: BACKUP NOACCT */
-static TREE *omitT; /* recursize file omition list */
-static TREE *omanyT; /* non-recursize file omition list */
-static TREE *symT; /* symbolic links to quote */
-static TREE *rsymT; /* recursive symbolic links to quote */
-static TREE *execT; /* execute command list */
-
-/*************************
- *** E X T E R N ***
- *************************/
-
-#ifdef lint
-static char _argbreak;
-#else
-extern char _argbreak; /* break character from nxtarg */
-#endif
-
-extern TREELIST *listTL; /* list of trees for scanning */
-extern TREE *listT; /* final list of files in collection */
-extern TREE *refuseT; /* files refused by client */
-
-extern char *collname; /* collection name */
-extern char *basedir; /* base directory name */
-extern char *prefix; /* collection pathname prefix */
-extern long lasttime; /* time of last upgrade */
-extern long scantime; /* time of this scan */
-extern int trace; /* trace directories */
-extern int newonly; /* new files only */
-
-extern long time();
-
-/*************************************************
- *** STATIC R O U T I N E S ***
- *************************************************/
-
-static makescan();
-static getscan();
-static doscan();
-static readlistfile();
-static expTinsert();
-static listone();
-static listentry();
-static listname();
-static listdir();
-static omitanyone();
-static anyglob();
-static int getscanfile();
-static int chkscanfile();
-static makescanfile();
-static recordone();
-static recordexec();
-
-/*************************************************
- *** L I S T S C A N R O U T I N E S ***
- *************************************************/
-
-static
-passdelim (ptr,delim) /* skip over delimiter */
-char **ptr,delim;
-{
- *ptr = skipover (*ptr, " \t");
- if (_argbreak != delim && **ptr == delim) {
- (*ptr)++;
- *ptr = skipover (*ptr, " \t");
- }
-}
-
-static
-char *parserelease(tlp,relname,args)
-TREELIST **tlp;
-char *relname,*args;
-{
- register TREELIST *tl;
- register char *arg;
- register OPTION option;
- int opno;
- char *nextrel;
-
- tl = (TREELIST *) malloc (sizeof(TREELIST));
- if ((*tlp = tl) == NULL)
- goaway ("Couldn't allocate TREELIST");
- tl->TLnext = NULL;
- tl->TLname = salloc (relname);
- tl->TLprefix = NULL;
- tl->TLlist = NULL;
- tl->TLscan = NULL;
- tl->TLhost = NULL;
- nextrel = NULL;
- args = skipover (args," \t");
- while (*(arg=nxtarg(&args," \t="))) {
- for (opno = 0; options[opno] != NULL; opno++)
- if (strcmp (arg,options[opno]) == 0)
- break;
- if (options[opno] == NULL)
- goaway ("Invalid release option %s for release %s",
- arg,relname);
- option = (OPTION) opno;
- switch (option) {
- case ONEXT:
- passdelim (&args,'=');
- arg = nxtarg (&args," \t");
- nextrel = salloc (arg);
- break;
- case OPREFIX:
- passdelim (&args,'=');
- arg = nxtarg (&args," \t");
- tl->TLprefix = salloc (arg);
- break;
- case OLIST:
- passdelim (&args,'=');
- arg = nxtarg (&args," \t");
- tl->TLlist = salloc (arg);
- break;
- case OSCAN:
- passdelim (&args,'=');
- arg = nxtarg (&args," \t");
- tl->TLscan = salloc (arg);
- break;
- case OHOST:
- passdelim (&args,'=');
- arg = nxtarg (&args," \t");
- tl->TLhost = salloc (arg);
- break;
- }
- }
- return (nextrel);
-}
-
-getrelease (release)
-char *release;
-{
- TREELIST *tl;
- char buf[STRINGLENGTH];
- char *p,*q;
- int rewound;
- FILE *f;
-
- if (release == NULL)
- release = salloc (DEFRELEASE);
- listTL = NULL;
-
- (void) sprintf (buf,FILERELEASES,collname);
- f = fopen (buf,"r");
- if (f != NULL) {
- rewound = TRUE;
- for (;;) {
- p = fgets (buf,STRINGLENGTH,f);
- if (p == NULL) {
- if (rewound)
- break;
- rewind (f);
- rewound = TRUE;
- continue;
- }
- q = index (p,'\n');
- if (q) *q = 0;
- if (index ("#;:",*p)) continue;
- q = nxtarg (&p," \t");
- if (strcmp (q,release) != 0)
- continue;
- release = parserelease (&tl,release,p);
- if (tl->TLprefix == NULL)
- tl->TLprefix = prefix;
- else if (chdir (tl->TLprefix) < 0)
- return (FALSE);
- else
- (void) chdir (basedir);
- tl->TLnext = listTL;
- listTL = tl;
- if (release == NULL)
- break;
- rewound = FALSE;
- }
- (void) fclose (f);
- }
- if (release == NULL)
- return (TRUE);
- if (strcmp (release,DEFRELEASE) != 0)
- return (FALSE);
- (void) parserelease (&tl,release,"");
- tl->TLprefix = prefix;
- tl->TLnext = listTL;
- listTL = tl;
- return (TRUE);
-}
-
-makescanlists (releases)
- char **releases;
-{
- TREELIST *tl;
- char buf[STRINGLENGTH];
- char *p,*q;
- FILE *f;
- char *saveprefix = prefix;
- char **rel_index;
- int count = 0;
-
- (void) sprintf (buf,FILERELEASES,collname);
- f = fopen (buf,"r");
- if (f != NULL) {
- while (p = fgets (buf,STRINGLENGTH,f)) {
- q = index (p,'\n');
- if (q) *q = 0;
- if (index ("#;:",*p)) continue;
- q = nxtarg (&p," \t");
- (void) parserelease (&tl,q,p);
- if ((prefix = tl->TLprefix) == NULL)
- prefix = saveprefix;
- if (prefix != NULL) {
- if (chdir (prefix) < 0)
- goaway ("Can't chdir to %s",prefix);
- (void) chdir (basedir);
- }
- if (releases)
- {
- rel_index = releases;
- while (*rel_index) {
- if (!strcmp (*rel_index, tl->TLname)) {
- makescan (tl->TLlist,tl->TLscan);
- break;
- }
- rel_index++;
- }
- }
- else
- makescan (tl->TLlist,tl->TLscan);
- free ((char *)tl);
- count++;
- }
- (void) fclose (f);
- }
- if (count == 0)
- makescan ((char *)NULL,FILESCANDEF);
-}
-
-static
-scanone (t)
-register TREE *t;
-{
- register TREE *newt;
-
- if (newonly && (t->Tflags&FNEW) == 0)
- return (SCMOK);
- newt = Tinsert (&listT,t->Tname,t->Tflags&FRENAME ? TRUE : FALSE);
- if (newt == NULL)
- return (SCMOK);
- if(t->Tnewname)
- newt->Tnewname = salloc(t->Tnewname);
- newt->Tmode = t->Tmode;
- newt->Tflags = t->Tflags;
- newt->Tmtime = t->Tmtime;
- return (SCMOK);
-}
-
-getscanlists ()
-{
- TREELIST *tl,*stl;
-
- stl = listTL;
- listTL = NULL;
- while ((tl = stl) != NULL) {
- prefix = tl->TLprefix;
- getscan (tl->TLlist,tl->TLscan);
- tl->TLtree = listT;
- stl = tl->TLnext;
- tl->TLnext = listTL;
- listTL = tl;
- }
- listT = NULL;
- for (tl = listTL; tl != NULL; tl = tl->TLnext)
- (void) Tprocess (tl->TLtree,scanone);
-}
-
-static
-makescan (listfile,scanfile)
-char *listfile,*scanfile;
-{
- listT = NULL;
- if(chkscanfile (scanfile)) { /* can we can write a scan file? */
- doscan (listfile); /* read list file and scan disk */
- makescanfile (scanfile);/* record names in scan file */
- Tfree (&listT); /* free file list tree */
- }
-}
-
-static
-getscan (listfile,scanfile)
-char *listfile,*scanfile;
-{
- listT = NULL;
- if (!getscanfile(scanfile)) { /* check for pre-scanned file list */
- scantime = time ((long *)NULL);
- doscan (listfile); /* read list file and scan disk */
- }
-}
-
-static
-doscan (listfile)
- char *listfile;
-{
- char buf[STRINGLENGTH];
- int listone ();
-
- upgT = NULL;
- flagsT = NULL;
- omitT = NULL;
- omanyT = NULL;
- execT = NULL;
- symT = NULL;
- rsymT = NULL;
- if (listfile == NULL)
- listfile = FILELISTDEF;
- (void) sprintf (buf,FILELIST,collname,listfile);
- readlistfile (buf); /* get contents of list file */
- (void) Tprocess (upgT,listone); /* build list of files specified */
- cdprefix ((char *)NULL);
- Tfree (&upgT);
- Tfree (&flagsT);
- Tfree (&omitT);
- Tfree (&omanyT);
- Tfree (&execT);
- Tfree (&symT);
- Tfree (&rsymT);
-}
-
-static
-readlistfile (fname)
-char *fname;
-{
- char buf[STRINGLENGTH],*p;
- register char *q,*r;
- register FILE *f;
- register int ltn,n,i,flags;
- register TREE **t;
- register LISTTYPE lt;
- char *speclist[SPECNUMBER];
-
- f = fopen (fname,"r");
- if (f == NULL) goaway ("Can't read list file %s",fname);
- cdprefix (prefix);
- while (p = fgets (buf,STRINGLENGTH,f)) {
- if (q = index (p,'\n')) *q = '\0';
- if (index ("#;:",*p)) continue;
- q = nxtarg (&p," \t");
- if (*q == '\0') continue;
- for (ltn = 0; ltname[ltn] && strcmp(q,ltname[ltn]) != 0; ltn++);
- if (ltname[ltn] == NULL)
- goaway ("Invalid list file keyword %s",q);
- lt = (LISTTYPE) ltn;
- flags = 0;
- switch (lt) {
- case LUPGRADE:
- t = &upgT;
- break;
- case LRENAME:
- t = &flagsT;
- flags = FRENAME;
- break;
- case LBACKUP:
- t = &flagsT;
- flags = FBACKUP;
- break;
- case LNOACCT:
- t = &flagsT;
- flags = FNOACCT;
- break;
- case LSYMLINK:
- t = &symT;
- break;
- case LRSYMLINK:
- t = &rsymT;
- break;
- case LOMIT:
- t = &omitT;
- break;
- case LOMITANY:
- t = &omanyT;
- break;
- case LALWAYS:
- t = &upgT;
- flags = FALWAYS;
- break;
- case LINCLUDE:
- while (*(q=nxtarg(&p," \t"))) {
- cdprefix ((char *)NULL);
- n = expand (q,speclist,SPECNUMBER);
- for (i = 0; i < n && i < SPECNUMBER; i++) {
- readlistfile (speclist[i]);
- cdprefix ((char *)NULL);
- free (speclist[i]);
- }
- cdprefix (prefix);
- }
- continue;
- case LEXECUTE:
- r = p = q = skipover (p," \t");
- do {
- q = p = skipto (p," \t(");
- p = skipover (p," \t");
- } while (*p != '(' && *p != '\0');
- if (*p++ == '(') {
- *q = '\0';
- do {
- q = nxtarg (&p," \t)");
- if (*q == 0)
- _argbreak = ')';
- else
- expTinsert (q,&execT,0,r,NULL);
- } while (_argbreak != ')');
- continue;
- }
- /* fall through */
- default:
- goaway ("Error in handling list file keyword %d",ltn);
- }
- while (*(q=nxtarg(&p," \t"))) {
- if (lt == LOMITANY)
- (void) Tinsert (t,q,FALSE);
- else if( lt == LRENAME )
- if(*(r=nxtarg(&p," \t")))
- {
- expTinsert (q,t,flags,(char *)NULL,r);
- /*
- * Omit the file it is being
- * renamed to, to avoid confusion
- */
- expTinsert (r,&omitT,0,
- (char *)NULL, (char *)NULL);
- }
- else
- printf("Rename %s without destination "
- "file. Skipping...\n", q);
- else
- expTinsert (q,t,flags,(char *)NULL,(char *)NULL);
- }
- }
- (void) fclose (f);
-}
-
-static
-expTinsert (p,t,flags,exec, q)
-char *p;
-char *q;
-TREE **t;
-int flags;
-char *exec;
-{
- register int n, i;
- register TREE *newt, *ts;
- char *speclist[SPECNUMBER];
- char buf[STRINGLENGTH];
-
- n = expand (p,speclist,SPECNUMBER);
- for (i = 0; i < n && i < SPECNUMBER; i++) {
- newt = Tinsert (t,speclist[i],TRUE);
- newt->Tflags |= flags;
- if (exec) {
- if((ts = Tsearch(flagsT, speclist[i]))
- && ts->Tflags&FRENAME)
- (void) sprintf (buf,exec,ts->Tnewname);
- else
- (void) sprintf (buf,exec,speclist[i]);
- (void) Tinsert (&newt->Texec,buf,FALSE);
- }
- if (q)
- newt->Tnewname = salloc(q);
- free (speclist[i]);
- }
-}
-
-static
-listone(t) /* expand and add one name from upgrade list */
-TREE *t;
-{
- listentry(t->Tname,t->Tname,(char *)NULL,
- (t->Tflags&FALWAYS) != 0);
- return (SCMOK);
-}
-
-static
-listentry(name,fullname,updir,always)
-register char *name, *fullname, *updir;
-int always;
-{
- struct stat statbuf;
- int link = 0;
- int omitanyone ();
-
- if (Tlookup (refuseT,fullname)) return;
- if (!always) {
- if (Tsearch (omitT,fullname)) return;
- if (Tprocess (omanyT,omitanyone,fullname) != SCMOK)
- return;
- }
- if (lstat(name,&statbuf) < 0)
- return;
- if ((statbuf.st_mode&S_IFMT) == S_IFLNK) {
- if (Tsearch (symT,fullname)) {
- listname (fullname,&statbuf);
- return;
- }
- if (Tlookup (rsymT,fullname)) {
- listname (fullname,&statbuf);
- return;
- }
- if (updir) link++;
- if (stat(name,&statbuf) < 0) return;
- }
- if ((statbuf.st_mode&S_IFMT) == S_IFDIR) {
- if (access(name,R_OK|X_OK) < 0) return;
- if (chdir(name) < 0) return;
- listname (fullname,&statbuf);
- if (trace) {
- printf ("Scanning directory %s\n",fullname);
- (void) fflush (stdout);
- }
- listdir (fullname,always);
- if (updir == 0 || link) {
- (void) chdir (basedir);
- if (prefix) (void) chdir (prefix);
- if (updir && *updir) (void) chdir (updir);
- } else
- (void) chdir ("..");
- return;
- }
- if (access(name,R_OK) < 0) return;
- listname (fullname,&statbuf);
-}
-
-static
-listname (name,st)
-register char *name;
-register struct stat *st;
-{
- register TREE *t,*ts;
- register int new;
- register TREELIST *tl;
-
- new = st->st_ctime > lasttime;
- if (newonly && !new) {
- for (tl = listTL; tl != NULL; tl = tl->TLnext)
- if (ts = Tsearch (tl->TLtree,name))
- ts->Tflags &= ~FNEW;
- return;
- }
- t = Tinsert (&listT,name,FALSE);
- if (t == NULL) return;
- t->Tmode = st->st_mode;
- t->Tctime = st->st_ctime;
- t->Tmtime = st->st_mtime;
- if (new) t->Tflags |= FNEW;
- if (ts = Tsearch (flagsT,name)){
- t->Tflags |= ts->Tflags;
- if(t->Tflags&FRENAME)
- t->Tnewname = salloc(ts->Tnewname);
- }
- if (ts = Tsearch (execT,name)) {
- t->Texec = ts->Texec;
- ts->Texec = NULL;
- }
-}
-
-static
-listdir (name,always) /* expand directory */
-char *name;
-int always;
-{
- struct dirent *dentry;
- register DIR *dirp;
- char ename[STRINGLENGTH],newname[STRINGLENGTH],filename[STRINGLENGTH];
- register char *p,*newp;
- register int i;
-
- dirp = opendir (".");
- if (dirp == 0) return; /* unreadable: probably protected */
-
- p = name; /* punt leading ./ and trailing / */
- newp = newname;
- if (p[0] == '.' && p[1] == '/') {
- p += 2;
- while (*p == '/') p++;
- }
- while (*newp++ = *p++) ; /* copy string */
- --newp; /* trailing null */
- while (newp > newname && newp[-1] == '/') --newp; /* trailing / */
- *newp = 0;
- if (strcmp (newname,".") == 0) newname[0] = 0; /* "." ==> "" */
-
- while (dentry=readdir(dirp)) {
- if (dentry->d_ino == 0) continue;
- if (strcmp(dentry->d_name,".") == 0) continue;
- if (strcmp(dentry->d_name,"..") == 0) continue;
- for (i=0; i<=MAXNAMLEN && dentry->d_name[i]; i++)
- ename[i] = dentry->d_name[i];
- ename[i] = 0;
- if (*newname)
- (void) sprintf (filename,"%s/%s",newname,ename);
- else
- (void) strcpy (filename,ename);
- listentry(ename,filename,newname,always);
- }
- closedir (dirp);
-}
-
-static
-omitanyone (t,filename)
-TREE *t;
-char **filename;
-{
- if (anyglob (t->Tname,*filename))
- return (SCMERR);
- return (SCMOK);
-}
-
-static
-anyglob (pattern,match)
-char *pattern,*match;
-{
- register char *p,*m;
- register char *pb,*pe;
-
- p = pattern;
- m = match;
- while (*m && *p == *m ) {
- p++;
- m++;
- }
- if (*p == '\0' && *m == '\0')
- return (TRUE);
- switch (*p++) {
- case '*':
- for (;;) {
- if (*p == '\0')
- return (TRUE);
- if (*m == '\0')
- return (*p == '\0');
- if (anyglob (p,++m))
- return (TRUE);
- }
- case '?':
- return (anyglob (p,++m));
- case '[':
- pb = p;
- while (*(++p) != ']')
- if (*p == '\0')
- return (FALSE);
- pe = p;
- for (p = pb + 1; p != pe; p++) {
- switch (*p) {
- case '-':
- if (p == pb && *m == '-') {
- p = pe + 1;
- return (anyglob (p,++m));
- }
- if (p == pb)
- continue;
- if ((p + 1) == pe)
- return (FALSE);
- if (*m > *(p - 1) &&
- *m <= *(p + 1)) {
- p = pe + 1;
- return (anyglob (p,++m));
- }
- continue;
- default:
- if (*m == *p) {
- p = pe + 1;
- return (anyglob (p,++m));
- }
- }
- }
- return (FALSE);
- default:
- return (FALSE);
- }
-}
-
-/*****************************************
- *** R E A D S C A N F I L E ***
- *****************************************/
-
-static
-int getscanfile (scanfile)
-char *scanfile;
-{
- char buf[STRINGLENGTH];
- struct stat sbuf;
- register FILE *f;
- TREE ts;
- register char *p,*q;
- register TREE *tmp, *t = NULL;
- register notwanted;
- register TREELIST *tl;
-
- if (scanfile == NULL)
- return(FALSE);
- (void) sprintf (buf,FILESCAN,collname,scanfile);
- if (stat(buf,&sbuf) < 0)
- return (FALSE);
- if ((f = fopen (buf,"r")) == NULL)
- return (FALSE);
- if ((p = fgets (buf,STRINGLENGTH,f)) == NULL) {
- (void) fclose (f);
- return (FALSE);
- }
- if (q = index (p,'\n')) *q = '\0';
- if (*p++ != 'V') {
- (void) fclose (f);
- return (FALSE);
- }
- if (atoi (p) != SCANVERSION) {
- (void) fclose (f);
- return (FALSE);
- }
- scantime = sbuf.st_mtime; /* upgrade time is time of supscan,
- * i.e. time of creation of scanfile */
- if (newonly && scantime == lasttime) {
- (void) fclose (f);
- return (TRUE);
- }
- notwanted = FALSE;
- while (p = fgets (buf,STRINGLENGTH,f)) {
- q = index (p,'\n');
- if (q) *q = 0;
- ts.Tflags = 0;
- if (*p == 'X') {
- if (notwanted) continue;
- if (t == NULL)
- goaway ("scanfile format inconsistant");
- (void) Tinsert (&t->Texec,++p,FALSE);
- continue;
- }
- notwanted = FALSE;
- if (*p == 'B') {
- p++;
- ts.Tflags |= FBACKUP;
- }
- if (*p == 'N') {
- p++;
- ts.Tflags |= FNOACCT;
- }
- if (*p == 'R') {
- p++;
- ts.Tflags |= FRENAME;
- }
- if ((q = index (p,' ')) == NULL)
- goaway ("scanfile format inconsistant");
- *q++ = '\0';
- ts.Tmode = atoo (p);
- p = q;
- if ((q = index (p,' ')) == NULL)
- goaway ("scanfile format inconsistant");
- *q++ = '\0';
- ts.Tctime = atoi (p);
- p = q;
- if ((q = index (p,' ')) == NULL)
- goaway ("scanfile format inconsistant");
- *q++ = 0;
- ts.Tmtime = atoi (p);
- p = q;
- ts.Tnewname = NULL;
- if (ts.Tflags & FRENAME){
- if ((q = index (p,' ')) == NULL)
- goaway ("scanfile format inconsistant");
- *q++ = '\0';
- ts.Tnewname = salloc(q);
- q = p;
- }
- if (ts.Tctime > lasttime)
- ts.Tflags |= FNEW;
- else if (newonly) {
- for (tl = listTL; tl != NULL; tl = tl->TLnext)
- if (tmp = Tsearch (tl->TLtree,q))
- tmp->Tflags &= ~FNEW;
- notwanted = TRUE;
- continue;
- }
- if (Tlookup (refuseT,q)) {
- notwanted = TRUE;
- continue;
- }
- t = Tinsert (&listT,q,TRUE);
- t->Tmode = ts.Tmode;
- t->Tflags = ts.Tflags;
- t->Tctime = ts.Tctime;
- t->Tmtime = ts.Tmtime;
- t->Tnewname = ts.Tnewname;
- }
- (void) fclose (f);
- return (TRUE);
-}
-
-/*******************************************
- *** W R I T E S C A N F I L E ***
- *******************************************/
-
-static chkscanfile (scanfile)
-char *scanfile;
-{
- char tname[STRINGLENGTH], fname[STRINGLENGTH];
- FILE *f;
-
- if (scanfile == NULL)
- return(FALSE);
- (void) sprintf (fname,FILESCAN,collname,scanfile);
- (void) sprintf (tname,"%s.temp",fname);
- if (NULL == (f = fopen (tname, "w")))
- goaway ("Can't test scan file temp %s for %s",tname,collname);
- else {
- (void) unlink (tname);
- (void) fclose (f);
- }
- return(TRUE);
-}
-
-static makescanfile (scanfile)
-char *scanfile;
-{
- char tname[STRINGLENGTH],fname[STRINGLENGTH];
- struct timeval tbuf[2];
- FILE *scanF; /* output file for scanned file list */
- int recordone ();
-
- (void) sprintf (fname,FILESCAN,collname,scanfile);
- (void) sprintf (tname,"%s.temp",fname);
- scanF = fopen (tname,"w");
- if (scanF == NULL)
- goaway ("Can't write scan file temp %s for %s",tname,collname);
- fprintf (scanF,"V%d\n",SCANVERSION);
- (void) Tprocess (listT,recordone,scanF);
- (void) fclose (scanF);
- if (rename (tname,fname) < 0)
- goaway ("Can't change %s to %s",tname,fname);
- (void) unlink (tname);
- tbuf[0].tv_sec = time((long *)NULL); tbuf[0].tv_usec = 0;
- tbuf[1].tv_sec = scantime; tbuf[1].tv_usec = 0;
- (void) utimes (fname,tbuf);
-}
-
-static
-recordone (t,scanF)
-TREE *t;
-FILE **scanF;
-{
- int recordexec ();
-
- if (t->Tflags&FBACKUP) fprintf (*scanF,"B");
- if (t->Tflags&FNOACCT) fprintf (*scanF,"N");
- if (t->Tflags&FRENAME) fprintf (*scanF,"R");
-
- fprintf (*scanF,"%o %d %d",
- t->Tmode,t->Tctime,t->Tmtime,t->Tname);
- if ( t->Tflags&FRENAME)
- fprintf (*scanF," %s %s\n",t->Tname, t->Tnewname);
- else
- fprintf (*scanF," %s\n", t->Tname);
- (void) Tprocess (t->Texec,recordexec,*scanF);
- return (SCMOK);
-}
-
-static
-recordexec (t,scanF)
-TREE *t;
-FILE **scanF;
-{
- fprintf(*scanF,"X%s\n",t->Tname);
- return (SCMOK);
-}
-
-cdprefix (prefix)
-char *prefix;
-{
- static char *curprefix = NULL;
-
- if (curprefix == NULL) {
- if (prefix == NULL)
- return;
- (void) chdir (prefix);
- curprefix = prefix;
- return;
- }
- if (prefix == NULL) {
- (void) chdir (basedir);
- curprefix = NULL;
- return;
- }
- if (prefix == curprefix)
- return;
- if (strcmp (prefix, curprefix) == 0) {
- curprefix = prefix;
- return;
- }
- (void) chdir (basedir);
- (void) chdir (prefix);
- curprefix = prefix;
-}
diff --git a/usr.sbin/sup/lib/scm.c b/usr.sbin/sup/lib/scm.c
deleted file mode 100644
index bbfe943..0000000
--- a/usr.sbin/sup/lib/scm.c
+++ /dev/null
@@ -1,609 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * SUP Communication Module for 4.3 BSD
- *
- * SUP COMMUNICATION MODULE SPECIFICATIONS:
- *
- * IN THIS MODULE:
- *
- * CONNECTION ROUTINES
- *
- * FOR SERVER
- * servicesetup (port) establish TCP port connection
- * char *port; name of service
- * service () accept TCP port connection
- * servicekill () close TCP port in use by another process
- * serviceprep () close temp ports used to make connection
- * serviceend () close TCP port
- *
- * FOR CLIENT
- * request (port,hostname,retry) establish TCP port connection
- * char *port,*hostname; name of service and host
- * int retry; true if retries should be used
- * requestend () close TCP port
- *
- * HOST NAME CHECKING
- * p = remotehost () remote host name (if known)
- * char *p;
- * i = samehost () whether remote host is also this host
- * int i;
- * i = matchhost (name) whether remote host is same as name
- * int i;
- * char *name;
- *
- * RETURN CODES
- * All procedures return values as indicated above. Other routines
- * normally return SCMOK on success, SCMERR on error.
- *
- * COMMUNICATION PROTOCOL
- *
- * Described in scmio.c.
- *
- **********************************************************************
- * HISTORY
- * 2-Oct-92 Mary Thompson (mrt) at Carnegie-Mellon University
- * Added conditional declarations of INADDR_NONE and INADDR_LOOPBACK
- * since Tahoe version of <netinet/in.h> does not define them.
- *
- * $Log: scm.c,v $
- * Revision 1.2 1995/12/26 05:02:49 peter
- * Apply ports/net/sup/patches/patch-aa...
- *
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.2 1994/06/20 06:04:04 rgrimes
- * Humm.. they did a lot of #if __STDC__ but failed to properly prototype
- * the code. Also fixed one bad argument to a wait3 call.
- *
- * It won't compile -Wall, but atleast it compiles standard without warnings
- * now.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.13 92/08/11 12:05:35 mrt
- * Added changes from stump:
- * Allow for multiple interfaces, and for numeric addresses.
- * Changed to use builtin port for the "supfiledbg"
- * service when getservbyname() cannot find it.
- * Added forward static declatations, delinted.
- * Updated variable argument usage.
- * [92/08/08 mrt]
- *
- * Revision 1.12 92/02/08 19:01:11 mja
- * Add (struct sockaddr *) casts for HC 2.1.
- * [92/02/08 18:59:09 mja]
- *
- * Revision 1.11 89/08/03 19:49:03 mja
- * Updated to use v*printf() in place of _doprnt().
- * [89/04/19 mja]
- *
- * 11-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Moved sleep into computeBackoff, renamed to dobackoff.
- *
- * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added timeout to backoff.
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed nameserver support.
- *
- * 09-Sep-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed to depend less upon having name of remote host.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon Universtiy
- * Extracted backoff/sleeptime computation from "request" and
- * created "computeBackoff" so that I could use it in sup.c when
- * trying to get to nameservers as a group.
- *
- * 21-May-87 Chriss Stephens (chriss) at Carnegie Mellon University
- * Merged divergent CS and EE versions.
- *
- * 02-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added some bullet-proofing code around hostname calls.
- *
- * 31-Mar-87 Dan Nydick (dan) at Carnegie-Mellon University
- * Fixed for 4.3.
- *
- * 30-May-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to use known values for well-known ports if they are
- * not found in the host table.
- *
- * 19-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed setsockopt SO_REUSEADDR to be non-fatal. Added fourth
- * parameter as described in 4.3 manual entry.
- *
- * 15-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added call of readflush() to requestend() routine.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Major rewrite for protocol version 4. All read/write and crypt
- * routines are now in scmio.c.
- *
- * 14-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added setsockopt SO_REUSEADDR call.
- *
- * 01-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed code to "gracefully" handle unexpected messages. This
- * seems reasonable since it didn't work anyway, and should be
- * handled at a higher level anyway by adhering to protocol version
- * number conventions.
- *
- * 26-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed scm.c to free space for remote host name when connection
- * is closed.
- *
- * 07-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed 4.2 retry code to reload sin values before retry.
- *
- * 22-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to retry initial connection open request.
- *
- * 22-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged 4.1 and 4.2 versions together.
- *
- * 21-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Add close() calls after pipe() call.
- *
- * 12-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Converted for 4.2 sockets; added serviceprep() routine.
- *
- * 04-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for 4.2 BSD.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <errno.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <netdb.h>
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "sup.h"
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff /* -1 return */
-#endif
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK (u_long)0x7f000001 /* 127.0.0.1 */
-#endif
-
-extern int errno;
-static char *myhost ();
-
-char scmversion[] = "4.3 BSD";
-
-/*
- * PROTOTYPES
- */
-#if __STDC__
-int scmerr __P((int, FILE *, char *,...));
-#endif
-/*************************
- *** M A C R O S ***
- *************************/
-
-/* networking parameters */
-#define NCONNECTS 5
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-extern char program[]; /* name of program we are running */
-extern int progpid; /* process id to display */
-
-int netfile = -1; /* network file descriptor */
-
-static int sock = -1; /* socket used to make connection */
-static struct in_addr remoteaddr; /* remote host address */
-static char *remotename = NULL; /* remote host name */
-static int swapmode; /* byte-swapping needed on server? */
-
-/***************************************************
- *** C O N N E C T I O N R O U T I N E S ***
- *** F O R S E R V E R ***
- ***************************************************/
-
-servicesetup (server) /* listen for clients */
-char *server;
-{
- struct sockaddr_in sin;
- struct servent *sp;
- short port;
- int one = 1;
-
- if (myhost () == NULL)
- return (scmerr (-1, stderr, "Local hostname not known"));
- if ((sp = getservbyname(server,"tcp")) == 0) {
- if (strcmp(server, FILEPORT) == 0)
- port = htons((u_short)FILEPORTNUM);
- else if (strcmp(server, DEBUGFPORT) == 0)
- port = htons((u_short)DEBUGFPORTNUM);
- else
- return (scmerr (-1, stderr, "Can't find %s server description",server));
- (void) scmerr (-1, stderr, "%s/tcp: unknown service: using port %d",
- server,port);
- } else
- port = sp->s_port;
- endservent ();
- sock = socket (AF_INET,SOCK_STREAM,0);
- if (sock < 0)
- return (scmerr (errno, stderr, "Can't create socket for connections"));
- if (setsockopt (sock,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof(int)) < 0)
- (void) scmerr (errno, stderr, "Can't set SO_REUSEADDR socket option");
- if (setsockopt (sock,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(int)) < 0)
- (void) scmerr (errno, stderr, "Can't set SO_KEEPALIVE socket option");
- (void) bzero ((char *)&sin,sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_port = port;
- if (bind (sock,(struct sockaddr *)&sin,sizeof(sin)) < 0)
- return (scmerr (errno, stderr, "Can't bind socket for connections"));
- if (listen (sock,NCONNECTS) < 0)
- return (scmerr (errno, stderr, "Can't listen on socket"));
- return (SCMOK);
-}
-
-service ()
-{
- struct sockaddr_in from;
- int x,len;
-
- remotename = NULL;
- len = sizeof (from);
- do {
- netfile = accept (sock,(struct sockaddr *)&from,&len);
- } while (netfile < 0 && errno == EINTR);
- if (netfile < 0)
- return (scmerr (errno, stderr, "Can't accept connections"));
- remoteaddr = from.sin_addr;
- if (read(netfile,(char *)&x,sizeof(int)) != sizeof(int))
- return (scmerr (errno, stderr, "Can't transmit data on connection"));
- if (x == 0x01020304)
- swapmode = 0;
- else if (x == 0x04030201)
- swapmode = 1;
- else
- return (scmerr (-1, stderr, "Unexpected byteswap mode %x",x));
- return (SCMOK);
-}
-
-serviceprep () /* kill temp socket in daemon */
-{
- if (sock >= 0) {
- (void) close (sock);
- sock = -1;
- }
- return (SCMOK);
-}
-
-servicekill () /* kill net file in daemon's parent */
-{
- if (netfile >= 0) {
- (void) close (netfile);
- netfile = -1;
- }
- if (remotename) {
- free (remotename);
- remotename = NULL;
- }
- return (SCMOK);
-}
-
-serviceend () /* kill net file after use in daemon */
-{
- if (netfile >= 0) {
- (void) close (netfile);
- netfile = -1;
- }
- if (remotename) {
- free (remotename);
- remotename = NULL;
- }
- return (SCMOK);
-}
-
-/***************************************************
- *** C O N N E C T I O N R O U T I N E S ***
- *** F O R C L I E N T ***
- ***************************************************/
-
-dobackoff (t,b)
-int *t,*b;
-{
- struct timeval tt;
- unsigned s;
-
- if (*t == 0)
- return (0);
- s = *b * 30;
- if (gettimeofday (&tt,(struct timezone *)NULL) >= 0)
- s += (tt.tv_usec >> 8) % s;
- if (*b < 32) *b <<= 1;
- if (*t != -1) {
- if (s > *t)
- s = *t;
- *t -= s;
- }
- (void) scmerr (-1, stdout, "Will retry in %d seconds",s);
- sleep (s);
- return (1);
-}
-
-request (server,hostname,retry) /* connect to server */
-char *server;
-char *hostname;
-int *retry;
-{
- int x, backoff;
- struct hostent *h;
- struct servent *sp;
- struct sockaddr_in sin, tin;
- short port;
-
- if ((sp = getservbyname(server,"tcp")) == 0) {
- if (strcmp(server, FILEPORT) == 0)
- port = htons((u_short)FILEPORTNUM);
- else if (strcmp(server, DEBUGFPORT) == 0)
- port = htons((u_short)DEBUGFPORTNUM);
- else
- return (scmerr (-1, stderr, "Can't find %s server description",
- server));
- (void) scmerr (-1, stderr, "%s/tcp: unknown service: using port %d",
- server,port);
- } else
- port = sp->s_port;
- (void) bzero ((char *)&sin,sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = inet_addr (hostname);
- if (sin.sin_addr.s_addr == (u_long) INADDR_NONE) {
- if ((h = gethostbyname (hostname)) == NULL)
- return (scmerr (-1, stderr, "Can't find host entry for %s",
- hostname));
- hostname = h->h_name;
- (void) bcopy (h->h_addr,(char *)&sin.sin_addr,h->h_length);
- }
- sin.sin_port = port;
- backoff = 1;
- for (;;) {
- netfile = socket (AF_INET,SOCK_STREAM,0);
- if (netfile < 0)
- return (scmerr (errno, stderr, "Can't create socket"));
- tin = sin;
- if (connect(netfile,(struct sockaddr *)&tin,sizeof(tin)) >= 0)
- break;
- (void) scmerr (errno, stderr, "Can't connect to server for %s",server);
- (void) close(netfile);
- if (!dobackoff (retry,&backoff))
- return (SCMERR);
- }
- remoteaddr = sin.sin_addr;
- remotename = salloc(hostname);
- x = 0x01020304;
- (void) write (netfile,(char *)&x,sizeof(int));
- swapmode = 0; /* swap only on server, not client */
- return (SCMOK);
-}
-
-requestend () /* end connection to server */
-{
- (void) readflush ();
- if (netfile >= 0) {
- (void) close (netfile);
- netfile = -1;
- }
- if (remotename) {
- free (remotename);
- remotename = NULL;
- }
- return (SCMOK);
-}
-
-/*************************************************
- *** H O S T N A M E C H E C K I N G ***
- *************************************************/
-
-static
-char *myhost () /* find my host name */
-{
- struct hostent *h;
- static char name[MAXHOSTNAMELEN];
-
-
- if (name[0] == '\0') {
- if (gethostname (name,MAXHOSTNAMELEN) < 0)
- return (NULL);
- if ((h = gethostbyname (name)) == NULL)
- return (NULL);
- (void) strcpy (name,h->h_name);
- }
- return (name);
-}
-
-char *remotehost () /* remote host name (if known) */
-{
- register struct hostent *h;
-
- if (remotename == NULL) {
- h = gethostbyaddr ((char *)&remoteaddr,sizeof(remoteaddr),
- AF_INET);
- remotename = salloc (h ? h->h_name : inet_ntoa(remoteaddr));
- if (remotename == NULL)
- return("UNKNOWN");
- }
- return (remotename);
-}
-
-int thishost (host)
-register char *host;
-{
- register struct hostent *h;
- char *name;
-
- if ((name = myhost ()) == NULL)
- logquit (1,"Can't find my host entry");
- h = gethostbyname (host);
- if (h == NULL) return (0);
- return (strcasecmp (name,h->h_name) == 0);
-}
-
-int samehost () /* is remote host same as local host? */
-{
- static struct in_addr *intp;
- static int nint = 0;
- struct in_addr *ifp;
- int n;
-
- if (nint <= 0) {
- int s;
- char buf[BUFSIZ];
- struct ifconf ifc;
- struct ifreq *ifr;
- struct sockaddr_in sin;
-
- if ((s = socket (AF_INET,SOCK_DGRAM,0)) < 0)
- logquit (1,"Can't create socket for SIOCGIFCONF");
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_buf = buf;
- if (ioctl (s,SIOCGIFCONF,(char *)&ifc) < 0)
- logquit (1,"SIOCGIFCONF failed");
- (void) close(s);
- if ((nint = ifc.ifc_len/sizeof(struct ifreq)) <= 0)
- return (0);
- intp = (struct in_addr *)
- malloc ((unsigned) nint*sizeof(struct in_addr));
- if ((ifp = intp) == 0)
- logquit (1,"no space for interfaces");
- for (ifr = ifc.ifc_req, n = nint; n > 0; --n, ifr++) {
- (void) bcopy ((char *)&ifr->ifr_addr,(char *)&sin,sizeof(sin));
- *ifp++ = sin.sin_addr;
- }
- }
- if (remoteaddr.s_addr == htonl(INADDR_LOOPBACK))
- return (1);
- for (ifp = intp, n = nint; n > 0; --n, ifp++)
- if (remoteaddr.s_addr == ifp->s_addr)
- return (1);
- return (0);
-}
-
-int matchhost (name) /* is this name of remote host? */
-char *name;
-{
- struct hostent *h;
- struct in_addr addr;
- char **ap;
- if(!strcmp(name,"*"))
- return (1);
- if ((addr.s_addr = inet_addr(name)) != (u_long) INADDR_NONE)
- return (addr.s_addr == remoteaddr.s_addr);
- if ((h = gethostbyname (name)) == 0)
- return (0);
- if (h->h_addrtype != AF_INET || h->h_length != sizeof(struct in_addr))
- return (0);
- for (ap = h->h_addr_list; *ap; ap++)
- if (bcmp ((char *)&remoteaddr,*ap,h->h_length) == 0)
- return (1);
- return (0);
-}
-
-#if __STDC__
-int scmerr (int errno,FILE *filedes,char *fmt,...)
-#else
-/*VARARGS*//*ARGSUSED*/
-int scmerr (va_alist)
-va_dcl
-#endif
-{
-#if !__STDC__
- int errno;
- FILE *filedes;
- char *fmt;
-#endif
- va_list ap;
-
- (void) fflush (filedes);
- if (progpid > 0)
- fprintf (filedes,"%s %d: ",program,progpid);
- else
- fprintf (filedes,"%s: ",program);
-#if __STDC__
- va_start(ap,fmt);
-#else
- va_start(ap);
- errno = va_arg(ap,int);
- fmt = va_arg(ap,char *);
-#endif
- vfprintf(filedes, fmt, ap);
- va_end(ap);
- if (errno >= 0)
- fprintf (filedes,": %s\n",errmsg(errno));
- else
- fprintf (filedes,"\n");
- (void) fflush (filedes);
- return (SCMERR);
-}
-
-/*******************************************************
- *** I N T E G E R B Y T E - S W A P P I N G ***
- *******************************************************/
-
-union intchar {
- int ui;
- char uc[sizeof(int)];
-};
-
-int byteswap (in)
-int in;
-{
- union intchar x,y;
- register int ix,iy;
-
- if (swapmode == 0) return (in);
- x.ui = in;
- iy = sizeof(int);
- for (ix=0; ix<sizeof(int); ix++) {
- --iy;
- y.uc[iy] = x.uc[ix];
- }
- return (y.ui);
-}
diff --git a/usr.sbin/sup/lib/scmio.c b/usr.sbin/sup/lib/scmio.c
deleted file mode 100644
index 713ceef..0000000
--- a/usr.sbin/sup/lib/scmio.c
+++ /dev/null
@@ -1,758 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * SUP Communication Module for 4.3 BSD
- *
- * SUP COMMUNICATION MODULE SPECIFICATIONS:
- *
- * IN THIS MODULE:
- *
- * OUTPUT TO NETWORK
- *
- * MESSAGE START/END
- * writemsg (msg) start message
- * int msg; message type
- * writemend () end message and flush data to network
- *
- * MESSAGE DATA
- * writeint (i) write int
- * int i; integer to write
- * writestring (p) write string
- * char *p; string pointer
- * writefile (f) write open file
- * int f; open file descriptor
- *
- * COMPLETE MESSAGE (start, one data block, end)
- * writemnull (msg) write message with no data
- * int msg; message type
- * writemint (msg,i) write int message
- * int msg; message type
- * int i; integer to write
- * writemstr (msg,p) write string message
- * int msg; message type
- * char *p; string pointer
- *
- * INPUT FROM NETWORK
- * MESSAGE START/END
- * readflush () flush any unread data (close)
- * readmsg (msg) read specified message type
- * int msg; message type
- * readmend () read message end
- *
- * MESSAGE DATA
- * readskip () skip over one input data block
- * readint (i) read int
- * int *i; pointer to integer
- * readstring (p) read string
- * char **p; pointer to string pointer
- * readfile (f) read into open file
- * int f; open file descriptor
- *
- * COMPLETE MESSAGE (start, one data block, end)
- * readmnull (msg) read message with no data
- * int msg; message type
- * readmint (msg,i) read int message
- * int msg; message type
- * int *i; pointer to integer
- * readmstr (msg,p) read string message
- * int msg; message type
- * char **p; pointer to string pointer
- *
- * RETURN CODES
- * All routines normally return SCMOK. SCMERR may be returned
- * by any routine on abnormal (usually fatal) errors. An
- * unexpected MSGGOAWAY will result in SCMEOF being returned.
- *
- * COMMUNICATION PROTOCOL
- * Messages always alternate, with the first message after
- * connecting being sent by the client process.
- *
- * At the end of the conversation, the client process will
- * send a message to the server telling it to go away. Then,
- * both processes will close the network connection.
- *
- * Any time a process receives a message it does not expect,
- * the "readmsg" routine will send a MSGGOAWAY message and
- * return SCMEOF.
- *
- * Each message has this format:
- * ---------- ------------ ------------ ----------
- * |msg type| |count|data| |count|data| ... |ENDCOUNT|
- * ---------- ------------ ------------ ----------
- * size: int int var. int var. int
- *
- * All ints are assumed to be 32-bit quantities. A message
- * with no data simply has a message type followed by ENDCOUNT.
- *
- **********************************************************************
- * HISTORY
- * $Log: scmio.c,v $
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:33 jkh
- * Current sup with compression support.
- *
- * Revision 1.2 1993/05/24 17:57:26 brezak
- * Remove netcrypt.c. Remove unneeded files. Cleanup make.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.7 92/09/09 22:04:41 mrt
- * Removed the data encryption routines from here to netcrypt.c
- * [92/09/09 mrt]
- *
- * Revision 1.6 92/08/11 12:05:57 mrt
- * Brad's changes: Delinted,Added forward declarations of
- * static functions. Added copyright.
- * [92/07/24 mrt]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Found error in debuging code for readint().
- *
- * 01-Apr-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to readdata to "push" data back into the data buffer.
- * Added prereadcount() to return the message count size after
- * reading it and then pushing it back into the buffer. Clear
- * any encryption when a GOAWAY message is detected before reading
- * the reason string. [V5.19]
- *
- * 02-Oct-86 Rudy Nedved (ern) at Carnegie-Mellon University
- * Put a timeout on reading from the network.
- *
- * 25-May-86 Jonathan J. Chew (jjc) at Carnegie-Mellon University
- * Renamed "howmany" parameter to routines "encode" and "decode" from
- * to "count" to avoid conflict with 4.3BSD macro.
- *
- * 15-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added readflush() to flush any unread data from the input
- * buffer. Called by requestend() in scm.c module.
- *
- * 19-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added register variables to decode() for speedup. Added I/O
- * buffering to reduce the number or read/write system calls.
- * Removed readmfil/writemfil routines which were not used and were
- * not compatable with the other similarly defined routines anyway.
- *
- * 19-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created from scm.c I/O and crypt routines.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include "sup.h"
-#include "supmsg.h"
-
-extern int errno;
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-/* end of message */
-#define ENDCOUNT (-1) /* end of message marker */
-#define NULLCOUNT (-2) /* used for sending NULL pointer */
-
-#define RETRIES 15 /* # of times to retry io */
-#define FILEXFER 2048 /* block transfer size */
-#define XFERSIZE(count) ((count > FILEXFER) ? FILEXFER : count)
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-extern int scmerr (); /* error printing routine */
-extern int netfile; /* network file descriptor */
-
-int scmdebug; /* scm debug flag */
-
-int cryptflag; /* whether to encrypt/decrypt data */
-char *cryptbuf; /* buffer for data encryption/decryption */
-
-extern char *goawayreason; /* reason for goaway message */
-
-struct buf {
- char b_data[FILEXFER]; /* buffered data */
- char *b_ptr; /* pointer to end of buffer */
- int b_cnt; /* number of bytes in buffer */
-} buffers[2];
-struct buf *bufptr; /* buffer pointer */
-
-
-/***********************************************
- *** O U T P U T T O N E T W O R K ***
- ***********************************************/
-
-static
-writedata (count,data) /* write raw data to network */
-int count;
-char *data;
-{
- register int x,tries;
- register struct buf *bp;
-
- if (bufptr) {
- if (bufptr->b_cnt + count <= FILEXFER) {
- bcopy (data,bufptr->b_ptr,count);
- bufptr->b_cnt += count;
- bufptr->b_ptr += count;
- return (SCMOK);
- }
- bp = (bufptr == buffers) ? &buffers[1] : buffers;
- bcopy (data,bp->b_data,count);
- bp->b_cnt = count;
- bp->b_ptr = bp->b_data + count;
- data = bufptr->b_data;
- count = bufptr->b_cnt;
- bufptr->b_cnt = 0;
- bufptr->b_ptr = bufptr->b_data;
- bufptr = bp;
- }
- tries = 0;
- for (;;) {
- errno = 0;
- x = write (netfile,data,count);
- if (x > 0) break;
- if (errno) break;
- if (++tries > RETRIES) break;
- if (scmdebug > 0)
- logerr ("SCM Retrying failed network write");
- }
- if (x <= 0) {
- if (errno == EPIPE)
- return (scmerr (-1,stderr,"Network write timed out"));
- if (errno)
- return (scmerr (errno,stderr,"Write error on network"));
- return (scmerr (-1,stderr,"Write retries failed"));
- }
- if (x != count)
- return (scmerr (-1,stderr,"Write error on network returned %d on write of %d",x,count));
- return (SCMOK);
-}
-
-static
-writeblock (count,data) /* write data block */
-int count;
-char *data;
-{
- register int x;
- int y = byteswap(count);
-
- x = writedata (sizeof(int),(char *)&y);
- if (x == SCMOK) x = writedata (count,data);
- return (x);
-}
-
-writemsg (msg) /* write start of message */
-int msg;
-{
- int x;
-
- if (scmdebug > 1)
- loginfo ("SCM Writing message %d",msg);
- if (bufptr)
- return (scmerr (-1,stderr,"Buffering already enabled"));
- bufptr = buffers;
- bufptr->b_ptr = bufptr->b_data;
- bufptr->b_cnt = 0;
- x = byteswap (msg);
- return (writedata(sizeof(int),(char *)&x));
-}
-
-writemend () /* write end of message */
-{
- register int count;
- register char *data;
- int x;
-
- x = byteswap (ENDCOUNT);
- x = writedata (sizeof(int),(char *)&x);
- if (x != SCMOK) return (x);
- if (bufptr == NULL)
- return (scmerr (-1,stderr,"Buffering already disabled"));
- if (bufptr->b_cnt == 0) {
- bufptr = NULL;
- return (SCMOK);
- }
- data = bufptr->b_data;
- count = bufptr->b_cnt;
- bufptr = NULL;
- return (writedata (count, data));
-}
-
-writeint (i) /* write int as data block */
-int i;
-{
- int x;
- if (scmdebug > 2)
- loginfo ("SCM Writing integer %d",i);
- x = byteswap(i);
- return (writeblock(sizeof(int),(char *)&x));
-}
-
-writestring (p) /* write string as data block */
-char *p;
-{
- register int len,x;
- if (p == NULL) {
- int y = byteswap(NULLCOUNT);
- if (scmdebug > 2)
- loginfo ("SCM Writing string NULL");
- return (writedata (sizeof(int),(char *)&y));
- }
- if (scmdebug > 2)
- loginfo ("SCM Writing string %s",p);
- len = strlen (p);
- if (cryptflag) {
- x = getcryptbuf (len+1);
- if (x != SCMOK)
- return (x);
- encode (p,cryptbuf,len);
- p = cryptbuf;
- }
- return (writeblock(len,p));
-}
-
-writefile (f) /* write open file as a data block */
-int f;
-{
- char buf[FILEXFER];
- register int number,sum,filesize,x;
- int y;
- struct stat statbuf;
-
- if (fstat(f,&statbuf) < 0)
- return (scmerr (errno,stderr,"Can't access open file for message"));
- filesize = statbuf.st_size;
- y = byteswap(filesize);
- x = writedata (sizeof(int),(char *)&y);
-
- if (cryptflag) x = getcryptbuf (FILEXFER);
-
- if (x == SCMOK) {
- sum = 0;
- do {
- number = read (f,buf,FILEXFER);
- if (number > 0) {
- if (cryptflag) {
- encode (buf,cryptbuf,number);
- x = writedata (number,cryptbuf);
- }
- else {
- x = writedata (number,buf);
- }
- sum += number;
- }
- } while (x == SCMOK && number > 0);
- }
- if (sum != filesize)
- return (scmerr (-1,stderr,"File size error on output message"));
- if (number < 0)
- return (scmerr (errno,stderr,"Read error on file output message"));
- return (x);
-}
-
-writemnull (msg) /* write message with no data */
-int msg;
-{
- register int x;
- x = writemsg (msg);
- if (x == SCMOK) x = writemend ();
- return (x);
-}
-
-writemint (msg,i) /* write message of one int */
-int msg,i;
-{
- register int x;
- x = writemsg (msg);
- if (x == SCMOK) x = writeint (i);
- if (x == SCMOK) x = writemend ();
- return (x);
-}
-
-writemstr (msg,p) /* write message of one string */
-int msg;
-char *p;
-{
- register int x;
- x = writemsg (msg);
- if (x == SCMOK) x = writestring (p);
- if (x == SCMOK) x = writemend ();
- return (x);
-}
-
-/*************************************************
- *** I N P U T F R O M N E T W O R K ***
- *************************************************/
-
-static
-readdata (count,data) /* read raw data from network */
-int count;
-char *data;
-{
- register char *p;
- register int n,m,x;
- int tries;
- static int bufcnt = 0;
- static char *bufptr;
- static char buffer[FILEXFER];
- static int imask;
- static struct timeval timout;
-
- if (count < 0) {
- if (bufptr + count < buffer)
- return (scmerr (-1,stderr,"No space in buffer %d",count));
- bufptr += count;
- bufcnt -= count;
- bcopy (data,bufptr,-count);
- return (SCMOK);
- }
- if (count == 0 && data == NULL) {
- bufcnt = 0;
- return (SCMOK);
- }
- if (count <= bufcnt) {
- bcopy (bufptr,data,count);
- bufptr += count;
- bufcnt -= count;
- return (SCMOK);
- }
- if (bufcnt > 0) {
- bcopy (bufptr,data,bufcnt);
- data += bufcnt;
- count -= bufcnt;
- }
- bufptr = buffer;
- bufcnt = 0;
- timout.tv_usec = 0;
- timout.tv_sec = 2*60*60;
- p = buffer;
- n = FILEXFER;
- m = count;
- while (m > 0) {
- tries = 0;
- for (;;) {
- imask = 1 << netfile;
-#if defined(__hpux)
- if (select(32,&imask,(int *)0,(int *)0,&timout) < 0)
-#else
- if (select(32,(fd_set *)&imask,(fd_set *)0,(fd_set *)0,&timout) < 0)
-#endif
- imask = 1;
- errno = 0;
- if (imask)
- x = read (netfile,p,n);
- else
- return (scmerr (-1,stderr,"Timeout on network input"));
- if (x > 0) break;
- if (x == 0)
- return (scmerr (-1,stderr,"Premature EOF on network "
- "input"));
- if (errno) break;
- if (++tries > RETRIES) break;
- if (scmdebug > 0)
- loginfo ("SCM Retrying failed network read");
- }
- if (x < 0) {
- if (errno)
- return (scmerr (errno,stderr,"Read error on network"));
- return (scmerr (-1,stderr,"Read retries failed"));
- }
- p += x;
- n -= x;
- m -= x;
- bufcnt += x;
- }
- bcopy (bufptr,data,count);
- bufptr += count;
- bufcnt -= count;
- return (SCMOK);
-}
-
-static
-int readcount (count) /* read count of data block */
-int *count;
-{
- register int x;
- int y;
- x = readdata (sizeof(int),(char *)&y);
- if (x != SCMOK) return (x);
- *count = byteswap(y);
- return (SCMOK);
-}
-
-int prereadcount (count) /* preread count of data block */
-int *count;
-{
- register int x;
- int y;
- x = readdata (sizeof(int),(char *)&y);
- if (x != SCMOK) return (x);
- x = readdata (-sizeof(int),(char *)&y);
- if (x != SCMOK) return (x);
- *count = byteswap(y);
- return (SCMOK);
-}
-
-readflush ()
-{
- return (readdata (0, (char *)NULL));
-}
-
-readmsg (msg) /* read header for expected message */
-int msg; /* if message is unexpected, send back SCMHUH */
-{
- register int x;
- int m;
- if (scmdebug > 1)
- loginfo ("SCM Reading message %d",msg);
- x = readdata (sizeof(int),(char *)&m); /* msg type */
- if (x != SCMOK) return (x);
- m = byteswap(m);
- if (m == msg) return (x);
-
- /* check for MSGGOAWAY in case he noticed problems first */
- if (m != MSGGOAWAY)
- return (scmerr (-1,stderr,"Received unexpected message %d",m));
- (void) netcrypt ((char *)NULL);
- (void) readstring (&goawayreason);
- (void) readmend ();
- if (goawayreason == NULL)
- return (SCMEOF);
- logerr ("SCM GOAWAY %s",goawayreason);
- return (SCMEOF);
-}
-
-readmend ()
-{
- register int x;
- int y;
- x = readdata (sizeof(int),(char *)&y);
- y = byteswap(y);
- if (x == SCMOK && y != ENDCOUNT)
- return (scmerr (-1,stderr,"Error reading end of message"));
- return (x);
-}
-
-readskip () /* skip over one input block */
-{
- register int x;
- int n;
- char buf[FILEXFER];
- x = readcount (&n);
- if (x != SCMOK) return (x);
- if (n < 0)
- return (scmerr (-1,stderr,"Invalid message count %d",n));
- while (x == SCMOK && n > 0) {
- x = readdata (XFERSIZE(n),buf);
- n -= XFERSIZE(n);
- }
- return (x);
-}
-
-int readint (buf) /* read int data block */
-int *buf;
-{
- register int x;
- int y;
- x = readcount (&y);
- if (x != SCMOK) return (x);
- if (y < 0)
- return (scmerr (-1,stderr,"Invalid message count %d",y));
- if (y != sizeof(int))
- return (scmerr (-1,stderr,"Size error for int message is %d",y));
- x = readdata (sizeof(int),(char *)&y);
- (*buf) = byteswap(y);
- if (scmdebug > 2)
- loginfo ("SCM Reading integer %d",*buf);
- return (x);
-}
-
-int readstring (buf) /* read string data block */
-register char **buf;
-{
- register int x;
- int count;
- register char *p;
-
- x = readcount (&count);
- if (x != SCMOK) return (x);
- if (count == NULLCOUNT) {
- if (scmdebug > 2)
- loginfo ("SCM Reading string NULL");
- *buf = NULL;
- return (SCMOK);
- }
- if (count < 0)
- return (scmerr (-1,stderr,"Invalid message count %d",count));
- if (scmdebug > 3)
- loginfo ("SCM Reading string count %d",count);
- if ((p = (char *)malloc ((unsigned)count+1)) == NULL)
- return (scmerr (-1,stderr,"Can't malloc %d bytes for string",count));
- if (cryptflag) {
- x = getcryptbuf (count+1);
- if (x == SCMOK) x = readdata (count,cryptbuf);
- if (x != SCMOK) return (x);
- if (scmdebug > 3)
- printf ("SCM Reading encrypted string %s\n",cryptbuf);
- decode (cryptbuf,p,count);
- }
- else {
- x = readdata (count,p);
- if (x != SCMOK) return (x);
- }
- p[count] = 0; /* NULL at end of string */
- *buf = p;
- if (scmdebug > 2)
- loginfo ("SCM Reading string %s",*buf);
- return (SCMOK);
-}
-
-readfile (f) /* read data block into open file */
-int f;
-{
- register int x;
- int count;
- char buf[FILEXFER];
-
- if (cryptflag) {
- x = getcryptbuf (FILEXFER);
- if (x != SCMOK) return (x);
- }
- x = readcount (&count);
- if (x != SCMOK) return (x);
- if (count < 0)
- return (scmerr (-1,stderr,"Invalid message count %d",count));
- while (x == SCMOK && count > 0) {
- if (cryptflag) {
- x = readdata (XFERSIZE(count),cryptbuf);
- if (x == SCMOK) decode (cryptbuf,buf,XFERSIZE(count));
- }
- else
- x = readdata (XFERSIZE(count),buf);
- if (x == SCMOK) {
- (void) write (f,buf,XFERSIZE(count));
- count -= XFERSIZE(count);
- }
- }
- return (x);
-}
-
-readmnull (msg) /* read null message */
-int msg;
-{
- register int x;
- x = readmsg (msg);
- if (x == SCMOK) x = readmend ();
- return (x);
-}
-
-readmint (msg,buf) /* read int message */
-int msg,*buf;
-{
- register int x;
- x = readmsg (msg);
- if (x == SCMOK) x = readint (buf);
- if (x == SCMOK) x = readmend ();
- return (x);
-}
-
-int readmstr (msg,buf) /* read string message */
-int msg;
-char **buf;
-{
- register int x;
- x = readmsg (msg);
- if (x == SCMOK) x = readstring (buf);
- if (x == SCMOK) x = readmend ();
- return (x);
-}
-
-/**********************************
- *** C R O S S P A T C H ***
- **********************************/
-
-crosspatch ()
-{
- fd_set ibits, obits, xbits;
- register int c;
- char buf[STRINGLENGTH];
-
- for (;;) {
- FD_ZERO (&ibits);
- FD_ZERO (&obits);
- FD_ZERO (&xbits);
- FD_SET (0,&ibits);
- FD_SET (netfile,&ibits);
-#if defined(__hpux)
- if ((c = select(16, (int *)&ibits, (int *)&obits, (int *)&xbits,
-#else
- if ((c = select(16, &ibits, &obits, &xbits,
-#endif
- (struct timeval *)NULL)) < 1) {
- if (c == -1) {
- if (errno == EINTR) {
- continue;
- }
- }
- sleep (5);
- continue;
- }
- if (FD_ISSET (netfile,&ibits)) {
- c = read (netfile,buf,sizeof (buf));
- if (c < 0 && errno == EWOULDBLOCK)
- c = 0;
- else {
- if (c <= 0) {
- break;
- }
- (void) write (1,buf,c);
- }
- }
- if (FD_ISSET(0, &ibits)) {
- c = read (0,buf,sizeof (buf));
- if (c < 0 && errno == EWOULDBLOCK)
- c = 0;
- else {
- if (c <= 0)
- break;
- (void) write (netfile,buf,c);
- }
- }
- }
-}
diff --git a/usr.sbin/sup/lib/skipto.c b/usr.sbin/sup/lib/skipto.c
deleted file mode 100644
index 2fa5a4f..0000000
--- a/usr.sbin/sup/lib/skipto.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/************************************************************************
- * skipover and skipto -- skip over characters in string
- *
- * Usage: p = skipto (string,charset);
- * p = skipover (string,charset);
- *
- * char *p,*charset,*string;
- *
- * Skipto returns a pointer to the first character in string which
- * is in the string charset; it "skips until" a character in charset.
- * Skipover returns a pointer to the first character in string which
- * is not in the string charset; it "skips over" characters in charset.
- ************************************************************************
- * HISTORY
- * 26-Jun-81 David Smith (drs) at Carnegie-Mellon University
- * Skipover, skipto rewritten to avoid inner loop at expense of space.
- *
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Skipover, skipto adapted for VAX from skip() and skipx() on the PDP-11
- * (from Ken Greer). The names are more mnemonic.
- *
- * Sindex adapted for VAX from indexs() on the PDP-11 (thanx to Ralph
- * Guggenheim). The name has changed to be more like the index()
- * and rindex() functions from Bell Labs; the return value (pointer
- * rather than integer) has changed partly for the same reason,
- * and partly due to popular usage of this function.
- */
-
-static unsigned char tab[256] = {
- 0};
-
-char *skipto (string,charset)
-unsigned char *string, *charset;
-{
- register unsigned char *setp,*strp;
-
- tab[0] = 1; /* Stop on a null, too. */
- for (setp=charset; *setp; setp++) tab[*setp]=1;
- for (strp=string; tab[*strp]==0; strp++) ;
- for (setp=charset; *setp; setp++) tab[*setp]=0;
- return ((char *)strp);
-}
-
-char *skipover (string,charset)
-unsigned char *string, *charset;
-{
- register unsigned char *setp,*strp;
-
- tab[0] = 0; /* Do not skip over nulls. */
- for (setp=charset; *setp; setp++) tab[*setp]=1;
- for (strp=string; tab[*strp]; strp++) ;
- for (setp=charset; *setp; setp++) tab[*setp]=0;
- return ((char *)strp);
-}
diff --git a/usr.sbin/sup/lib/stree.c b/usr.sbin/sup/lib/stree.c
deleted file mode 100644
index 5b09430..0000000
--- a/usr.sbin/sup/lib/stree.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * stree.c -- SUP Tree Routines
- *
- **********************************************************************
- * HISTORY
- * $Log: stree.c,v $
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:34 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:17 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.4 92/08/11 12:06:32 mrt
- * Added copyright. Delinted
- * [92/08/10 mrt]
- *
- *
- * Revision 1.3 89/08/15 15:30:57 bww
- * Changed code in Tlookup to Tsearch for each subpart of path.
- * Added indent formatting code to Tprint.
- * From "[89/06/24 gm0w]" at CMU.
- * [89/08/15 bww]
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to please lint.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to initialize new fields. Added Tfree routine.
- *
- * 27-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <c.h>
-#include <sys/param.h>
-#include "sup.h"
-
-#define Static /* static /* comment for debugging */
-
-/*************************************************************
- *** T R E E P R O C E S S I N G R O U T I N E S ***
- *************************************************************/
-
-Tfree (t)
-register TREE **t;
-{
- if (*t == NULL) return;
- Tfree (&((*t)->Tlink));
- Tfree (&((*t)->Texec));
- Tfree (&((*t)->Tlo));
- Tfree (&((*t)->Thi));
- if ((*t)->Tname) free ((*t)->Tname);
- if ((*t)->Tnewname) free ((*t)->Tnewname);
- if ((*t)->Tuser) free ((*t)->Tuser);
- if ((*t)->Tgroup) free ((*t)->Tgroup);
- free (*(char **)t);
- *t = NULL;
-}
-
-Static
-TREE *Tmake (p)
-char *p;
-{
- register TREE *t;
- t = (TREE *) malloc (sizeof (TREE));
- t->Tname = (p == NULL) ? NULL : salloc (p);
- t->Tnewname = NULL;
- t->Tflags = 0;
- t->Tuid = 0;
- t->Tgid = 0;
- t->Tuser = NULL;
- t->Tgroup = NULL;
- t->Tmode = 0;
- t->Tctime = 0;
- t->Tmtime = 0;
- t->Tlink = NULL;
- t->Texec = NULL;
- t->Tbf = 0;
- t->Tlo = NULL;
- t->Thi = NULL;
- return (t);
-}
-
-Static
-TREE *Trotll (tp,tl)
-register TREE *tp,*tl;
-{
- tp->Tlo = tl->Thi;
- tl->Thi = tp;
- tp->Tbf = tl->Tbf = 0;
- return(tl);
-}
-
-Static
-TREE *Trotlh (tp,tl)
-register TREE *tp,*tl;
-{
- register TREE *th;
-
- th = tl->Thi;
- tp->Tlo = th->Thi;
- tl->Thi = th->Tlo;
- th->Thi = tp;
- th->Tlo = tl;
- tp->Tbf = tl->Tbf = 0;
- if (th->Tbf == 1)
- tp->Tbf = -1;
- else if (th->Tbf == -1)
- tl->Tbf = 1;
- th->Tbf = 0;
- return(th);
-}
-
-Static
-TREE *Trothl (tp,th)
-register TREE *tp,*th;
-{
- register TREE *tl;
-
- tl = th->Tlo;
- tp->Thi = tl->Tlo;
- th->Tlo = tl->Thi;
- tl->Tlo = tp;
- tl->Thi = th;
- tp->Tbf = th->Tbf = 0;
- if (tl->Tbf == -1)
- tp->Tbf = 1;
- else if (tl->Tbf == 1)
- th->Tbf = -1;
- tl->Tbf = 0;
- return(tl);
-}
-
-Static
-TREE *Trothh (tp,th)
-register TREE *tp,*th;
-{
- tp->Thi = th->Tlo;
- th->Tlo = tp;
- tp->Tbf = th->Tbf = 0;
- return(th);
-}
-
-Static
-Tbalance (t)
-TREE **t;
-{
- if ((*t)->Tbf < 2 && (*t)->Tbf > -2)
- return;
- if ((*t)->Tbf > 0) {
- if ((*t)->Tlo->Tbf > 0)
- *t = Trotll(*t, (*t)->Tlo);
- else
- *t = Trotlh(*t, (*t)->Tlo);
- } else {
- if ((*t)->Thi->Tbf > 0)
- *t = Trothl(*t, (*t)->Thi);
- else
- *t = Trothh(*t, (*t)->Thi);
- }
-}
-
-Static
-TREE *Tinsertavl (t,p,find,dh)
-TREE **t;
-char *p;
-int find;
-int *dh;
-{
- register TREE *newt;
- register int cmp;
- int deltah;
-
- if (*t == NULL) {
- *t = Tmake (p);
- *dh = 1;
- return (*t);
- }
- if ((cmp = strcmp(p, (*t)->Tname)) == 0) {
- if (!find) return (NULL); /* node already exists */
- *dh = 0;
- return (*t);
- } else if (cmp < 0) {
- if ((newt = Tinsertavl (&((*t)->Tlo),p,find,&deltah)) == NULL)
- return (NULL);
- (*t)->Tbf += deltah;
- } else {
- if ((newt = Tinsertavl (&((*t)->Thi),p,find,&deltah)) == NULL)
- return (NULL);
- (*t)->Tbf -= deltah;
- }
- Tbalance(t);
- if ((*t)->Tbf == 0) deltah = 0;
- *dh = deltah;
- return (newt);
-}
-
-TREE *Tinsert (t,p,find)
-TREE **t;
-register char *p;
-int find;
-{
- int deltah;
-
- if (p != NULL && p[0] == '.' && p[1] == '/') {
- p += 2;
- while (*p == '/') p++;
- if (*p == 0) p = ".";
- }
- return (Tinsertavl (t,p,find,&deltah));
-}
-
-TREE *Tsearch (t,p)
-TREE *t;
-char *p;
-{
- register TREE *x;
- register int cmp;
-
- x = t;
- while (x) {
- cmp = strcmp (p,x->Tname);
- if (cmp == 0) return (x);
- if (cmp < 0) x = x->Tlo;
- else x = x->Thi;
- }
- return (NULL);
-}
-
-TREE *Tlookup (t,p)
-TREE *t;
-char *p;
-{
- register TREE *x;
- char buf[MAXPATHLEN+1];
-
- if (p == NULL)
- return (NULL);
- if (p[0] == '.' && p[1] == '/') {
- p += 2;
- while (*p == '/') p++;
- if (*p == 0) p = ".";
- }
- if ((x = Tsearch (t,p)) != NULL)
- return (x);
- if (*p != '/' && (x = Tsearch (t,".")) != NULL)
- return (x);
- (void) strncpy(buf, p, sizeof(buf)-1);
- buf[MAXPATHLEN] = '\0';
- while ((p = rindex(buf, '/')) != NULL) {
- while (p >= buf && *(p-1) == '/')
- p--;
- if (p == buf)
- *(p+1) = '\0';
- else
- *p = '\0';
- if ((x = Tsearch (t,buf)) != NULL)
- return (x);
- if (p == buf)
- break;
- }
- return (NULL);
-}
-
-Static int process_level;
-
-Static
-int Tsubprocess (t,reverse,f,argp)
-TREE *t;
-int reverse;
-int (*f)();
-int *argp;
-{
- register int x = SCMOK;
- process_level++;
- if (reverse?t->Thi:t->Tlo)
- x = Tsubprocess (reverse?t->Thi:t->Tlo,
- reverse,f,argp);
- if (x == SCMOK) {
- x = (*f) (t,argp);
- if (x == SCMOK) {
- if (reverse?t->Tlo:t->Thi)
- x = Tsubprocess (reverse?t->Tlo:t->Thi,
- reverse,f,argp);
- }
- }
- process_level--;
- return (x);
-}
-
-/* VARARGS2 */
-int Trprocess (t,f,args)
-TREE *t;
-int (*f)();
-int args;
-{
- if (t == NULL) return (SCMOK);
- process_level = 0;
- return (Tsubprocess (t,TRUE,f,&args));
-}
-
-/* VARARGS2 */
-int Tprocess (t,f,args)
-TREE *t;
-int (*f)();
-int args;
-{
- if (t == NULL) return (SCMOK);
- process_level = 0;
- return (Tsubprocess (t,FALSE,f,&args));
-}
-
-Static
-int Tprintone (t)
-TREE *t;
-{
- int i;
- for (i = 0; i < (process_level*2); i++)
- (void) putchar(' ');
- printf ("Node at %X name '%s' flags %o hi %X lo %X\n",t,t->Tname,t->Tflags,t->Thi,t->Tlo);
- return (SCMOK);
-}
-
-Tprint (t,p) /* print tree -- for debugging */
-TREE *t;
-char *p;
-{
- printf ("%s\n",p);
- (void) Tprocess (t,Tprintone);
- printf ("End of tree\n");
- (void) fflush (stdout);
-}
diff --git a/usr.sbin/sup/lib/sup.h b/usr.sbin/sup/lib/sup.h
deleted file mode 100644
index 12f03c3..0000000
--- a/usr.sbin/sup/lib/sup.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/* sup.h -- declarations for sup, supnamesrv, supfilesrv
- *
- * VERSION NUMBER for any program is given by: a.b (c)
- * where a = PROTOVERSION is the protocol version #
- * b = PGMVERSION is program # within protocol
- * c = scmversion is communication module version
- * (i.e. operating system for which scm is configured)
- **********************************************************************
- * HISTORY
- * 13-Sep-92 Mary Thompson (mrt) at Carnegie-Mellon University
- * Changed name of DEFDIR from /usr/cs to /usr.
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * $Log: sup.h,v $
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:34 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:18 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.10 92/08/11 12:06:42 mrt
- * Added definition for DEBUGFPORTNUM, the debugging port number.
- * Changed so that last and when file names could include
- * the relase name if any.
- * [92/07/23 mrt]
- *
- * Revision 1.9 91/04/29 14:39:03 mja
- * Reduce MAXCHILDREN from 8 to 3.
- *
- * Revision 1.8 89/08/23 14:55:30 gm0w
- * Moved coll.dir from supservers to supfiles.
- * [89/08/23 gm0w]
- *
- * 18-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added host=<hostfile> support to releases file.
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support. Removed nameserver support.
- *
- * 27-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added TREELIST and other changes for "release" support.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Version 6 of the network protocol, better support to reflect errors
- * back to server logfile.
- *
- * 21-May-87 Chriss Stephens (chriss) at Carnegie Mellon University
- * Merged divergent CS and EE versions.
- *
- * 19-Sep-86 Mike Accetta (mja) at Carnegie-Mellon University
- * Added FILESUPTDEFAULT definition.
- *
- * 07-Jun-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed FILESRVBUSYWAIT. Now uses exponential backoff.
- *
- * 30-May-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added numeric port numbers to use when port names are not in the
- * host table.
- *
- * 04-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Update protocol version to 5 for name server protocol change to
- * allow multiple repositories per collection. Added FILESRVBUSYWAIT
- * of 5 minutes. Added FILELOCK file to indicate collections that
- * should be exclusively locked when upgraded.
- *
- * 22-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged 4.1 and 4.2 versions together.
- *
- * 04-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for 4.2 BSD.
- *
- **********************************************************************
- */
-
-/* PGMVERSION is defined separately in each program */
-extern char scmversion[]; /* string version of scm */
-#define PROTOVERSION 9 /* version of network protocol */
-#define SCANVERSION 3 /* version of scan file format */
-
-/* TCP servers for name server and file server */
-#define FILEPORT "supfilesrv"
-#define FILEPORTNUM 871
-#define DEBUGFPORT "supfiledbg"
-#define DEBUGFPORTNUM 1127
-
-/* Data files used in scan.c */
-#define FILELIST "sup/%s/%s"
-#define FILESCAN "sup/%s/%s"
-#define FILEHOST "sup/%s/%s"
-#define FILELISTDEF "list"
-#define FILESCANDEF "scan"
-#define FILEHOSTDEF "host"
-#define DEFRELEASE "default"
-
-/* Data files used in sup.c */
-#define FILEBASEDEFAULT "/usr/%s" /* also supfilesrv and supscan */
-#ifdef EE_XXX
-#define FILESUPDEFAULT "%s/supfiles/coll.list"
-#define FILESUPTDEFAULT "%s/supfiles/coll.what"
-#define FILEHOSTS "%s/supfiles/coll.host"
-#else EE_XXX
-#define FILESUPDEFAULT "%s/lib/supfiles/coll.list"
-#define FILESUPTDEFAULT "%s/lib/supfiles/coll.what"
-#define FILEHOSTS "%s/lib/supfiles/coll.host"
-#endif EE_XXX
-#define FILEBKDIR "%s/BACKUP"
-#define FILEBACKUP "%s/BACKUP/%s"
-#define FILELAST "sup/%s/last%s"
-#define FILELASTTEMP "sup/%s/last.temp"
-#define FILELOCK "sup/%s/lock" /* also supfilesrv */
-#define FILEREFUSE "sup/%s/refuse"
-#define FILEWHEN "sup/%s/when%s"
-
-/* Data files used in supfilesrv.c */
-#define FILEXPATCH "%s/sup/xpatch.host"
-#ifdef EE_XXX
-#define FILEDIRS "%s/supfiles/coll.dir" /* also supscan */
-#else EE_XXX
-#define FILEDIRS "%s/lib/supfiles/coll.dir" /* also supscan */
-#endif EE_XXX
-#define FILECRYPT "sup/%s/crypt"
-#define FILELOGFILE "sup/%s/logfile"
-#define FILEPREFIX "sup/%s/prefix" /* also supscan */
-#define FILERELEASES "sup/%s/releases" /* also supscan */
-
-/* String length */
-#define STRINGLENGTH 2000
-
-/* Password transmission encryption key */
-#define PSWDCRYPT "SuperMan"
-/* Test string for encryption */
-#define CRYPTTEST "Hello there, Sailor Boy!"
-
-/* Default directory for system sup information */
-#ifndef DEFDIR
-#ifdef EE_XXX
-#define DEFDIR "/etc"
-#else EE_XXX
-#define DEFDIR "/usr"
-#endif EE_XXX
-#endif DEFDIR
-
-/* Default login account for file server */
-#ifndef DEFUSER
-#define DEFUSER "anon"
-#endif DEFUSER
-
-/* subroutine return codes */
-#define SCMOK (1) /* routine performed correctly */
-#define SCMEOF (0) /* read EOF on network connection */
-#define SCMERR (-1) /* error occurred during routine */
-
-/* data structure for describing a file being upgraded */
-
-struct treestruct {
-/* fields for file information */
- char *Tname; /* path component name */
- char *Tnewname; /* Used for renameing files */
- int Tflags; /* flags of file */
- int Tmode; /* st_mode of file */
- char *Tuser; /* owner of file */
- int Tuid; /* owner id of file */
- char *Tgroup; /* group of file */
- int Tgid; /* group id of file */
- int Tctime; /* inode modification time */
- int Tmtime; /* data modification time */
- struct treestruct *Tlink; /* tree of link names */
- struct treestruct *Texec; /* tree of execute commands */
-/* fields for sibling AVL tree */
- int Tbf; /* balance factor */
- struct treestruct *Tlo,*Thi; /* ordered sibling tree */
-};
-typedef struct treestruct TREE;
-
-/* data structure to represent a list of trees to upgrade */
-
-struct tliststruct {
- struct tliststruct *TLnext; /* next entry in tree list */
-/* fields for tree information */
- char *TLname; /* release name for tree */
- char *TLprefix; /* prefix of tree */
- char *TLlist; /* name of list file */
- char *TLscan; /* name of scan file */
- char *TLhost; /* name of host file */
- TREE *TLtree; /* tree of files to upgrade */
-};
-typedef struct tliststruct TREELIST;
-
-/* bitfield not defined in stat.h */
-#define S_IMODE 07777 /* part of st_mode that chmod sets */
-
-/* flag bits for files */
-#define FNEW 01 /* ctime of file has changed */
-#define FBACKUP 02 /* backup of file is allowed */
-#define FNOACCT 04 /* don't set file information */
-#define FUPDATE 010 /* only set file information */
-#define FRENAME 020 /* Rename this file while updating */
-#define FNEEDED 0100000 /* file needed for upgrade */
-
-/* version 3 compatability */
-#define FCOMPAT 0010000 /* Added to detect execute commands to send */
-
-/* message types now obsolete */
-#define MSGFEXECQ (115)
-#define MSGFEXECNAMES (116)
-
-/* flag bits for files in list of all files */
-#define ALLNEW 01
-#define ALLBACKUP 02
-#define ALLEND 04
-#define ALLDIR 010
-#define ALLNOACCT 020
-#define ALLSLINK 0100
-
-/* flag bits for file mode word */
-#define MODELINK 010000
-#define MODEDIR 040000
-#define MODESYM 0100000
-#define MODENOACCT 0200000
-#define MODEUPDATE 01000000
-
-/* blocking factor for filenames in list of all file names */
-#define BLOCKALL 32
-
-/* end version 3 compatability */
-
-#define MAXCHILDREN 3 /* maximum number of children allowed
- to sup at the same time */
-
-/* scm and stree external declarations */
-char *remotehost();
-TREE *Tinsert(),*Tsearch(),*Tlookup();
diff --git a/usr.sbin/sup/lib/supmsg.c b/usr.sbin/sup/lib/supmsg.c
deleted file mode 100644
index b12c945..0000000
--- a/usr.sbin/sup/lib/supmsg.c
+++ /dev/null
@@ -1,640 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- **********************************************************************
- * HISTORY
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * $Log: supmsg.c,v $
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:35 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:19 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 2.4 92/09/09 22:05:17 mrt
- * Moved PFI definition under __STDC__ conditional since it
- * is already defined in libc.h in this case.
- * [92/09/01 mrt]
- *
- * Revision 2.3 92/08/11 12:08:12 mrt
- * Added copyright
- * [92/08/10 mrt]
- * Brad's changes: Delinted, Incorporated updated variable
- * argument list usage from old msgxfer.c
- * [92/07/24 mrt]
- *
- * Revision 2.2 89/08/23 15:02:56 gm0w
- * Created from separate message modules.
- * [89/08/14 gm0w]
- *
- **********************************************************************
- */
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <libc.h>
-#include <c.h>
-#include "sup.h"
-#define MSGSUBR
-#define MSGFILE
-#include "supmsg.h"
-
-/*
- * signon message
- */
-extern int pgmver; /* program version of partner */
-extern int pgmversion; /* my program version */
-extern char *scmver; /* scm version of partner */
-extern int fspid; /* process id of fileserver */
-
-int msgsignon ()
-{
- register int x;
-
- if (server) {
- x = readmsg (MSGSIGNON);
- if (x == SCMOK) x = readint (&protver);
- if (x == SCMOK) x = readint (&pgmver);
- if (x == SCMOK) x = readstring (&scmver);
- if (x == SCMOK) x = readmend ();
- } else {
- x = writemsg (MSGSIGNON);
- if (x == SCMOK) x = writeint (PROTOVERSION);
- if (x == SCMOK) x = writeint (pgmversion);
- if (x == SCMOK) x = writestring (scmversion);
- if (x == SCMOK) x = writemend ();
- }
- return (x);
-}
-
-int msgsignonack ()
-{
- register int x;
-
- if (server) {
- x = writemsg (MSGSIGNONACK);
- if (x == SCMOK) x = writeint (PROTOVERSION);
- if (x == SCMOK) x = writeint (pgmversion);
- if (x == SCMOK) x = writestring (scmversion);
- if (x == SCMOK) x = writeint (fspid);
- if (x == SCMOK) x = writemend ();
- } else {
- x = readmsg (MSGSIGNONACK);
- if (x == SCMOK) x = readint (&protver);
- if (x == SCMOK) x = readint (&pgmver);
- if (x == SCMOK) x = readstring (&scmver);
- if (x == SCMOK) x = readint (&fspid);
- if (x == SCMOK) x = readmend ();
- }
- return (x);
-}
-
-/*
- * setup message
- */
-extern int xpatch; /* setup crosspatch to a new client */
-extern char *xuser; /* user,group,acct for crosspatch */
-extern char *collname; /* base directory */
-extern char *basedir; /* base directory */
-extern int basedev; /* base directory device */
-extern int baseino; /* base directory inode */
-extern long lasttime; /* time of last upgrade */
-extern int listonly; /* only listing files, no data xfer */
-extern int newonly; /* only send new files */
-extern char *release; /* release name */
-extern int setupack; /* ack return value for setup */
-
-int msgsetup ()
-{
- register int x;
-
- if (server) {
- x = readmsg (MSGSETUP);
- if (x != SCMOK) return (x);
- if (protver >= 7) {
- x = readint (&xpatch);
- if (x != SCMOK) return (x);
- } else
- xpatch = FALSE;
- if (xpatch) {
- x = readstring (&xuser);
- if (x != SCMOK) return (x);
- return (readmend ());
- }
- x = readstring (&collname);
- if (x == SCMOK) x = readint ((int *)&lasttime);
- if (x == SCMOK) x = readstring (&basedir);
- if (x == SCMOK) x = readint (&basedev);
- if (x == SCMOK) x = readint (&baseino);
- if (x == SCMOK) x = readint (&listonly);
- if (x == SCMOK) x = readint (&newonly);
- if (x == SCMOK)
- if (protver < 6)
- release = (char *)NULL;
- else
- x = readstring (&release);
- if (x == SCMOK) x = readmend ();
- } else {
- x = writemsg (MSGSETUP);
- if (x != SCMOK) return (x);
- if (protver >= 7) {
- x = writeint (xpatch);
- if (x != SCMOK) return (x);
- }
- if (xpatch) {
- x = writestring (xuser);
- if (x != SCMOK) return (x);
- return (writemend ());
- }
- if (x == SCMOK) x = writestring (collname);
- if (x == SCMOK) x = writeint ((int)lasttime);
- if (x == SCMOK) x = writestring (basedir);
- if (x == SCMOK) x = writeint (basedev);
- if (x == SCMOK) x = writeint (baseino);
- if (x == SCMOK) x = writeint (listonly);
- if (x == SCMOK) x = writeint (newonly);
- if (x == SCMOK && protver >= 6) x = writestring (release);
- if (x == SCMOK) x = writemend ();
- }
- return (x);
-}
-
-int msgsetupack ()
-{
- if (server)
- return (writemint (MSGSETUPACK,setupack));
- return (readmint (MSGSETUPACK,&setupack));
-}
-
-/*
- * crypt test message
- */
-extern char *crypttest; /* encryption test string */
-
-int msgcrypt ()
-{
- if (server)
- return (readmstr (MSGCRYPT,&crypttest));
- return (writemstr (MSGCRYPT,crypttest));
-}
-
-int msgcryptok ()
-{
- if (server)
- return (writemnull (MSGCRYPTOK));
- return (readmnull (MSGCRYPTOK));
-}
-
-/*
- * login message
- */
-extern char *logcrypt; /* login encryption test */
-extern char *loguser; /* login username */
-extern char *logpswd; /* password for login */
-extern int logack; /* login ack status */
-extern char *logerror; /* error from login */
-
-int msglogin ()
-{
- register int x;
- if (server) {
- x = readmsg (MSGLOGIN);
- if (x == SCMOK) x = readstring (&logcrypt);
- if (x == SCMOK) x = readstring (&loguser);
- if (x == SCMOK) x = readstring (&logpswd);
- if (x == SCMOK) x = readmend ();
- } else {
- x = writemsg (MSGLOGIN);
- if (x == SCMOK) x = writestring (logcrypt);
- if (x == SCMOK) x = writestring (loguser);
- if (x == SCMOK) x = writestring (logpswd);
- if (x == SCMOK) x = writemend ();
- }
- return (x);
-}
-
-int msglogack ()
-{
- register int x;
- if (server) {
- x = writemsg (MSGLOGACK);
- if (x == SCMOK) x = writeint (logack);
- if (x == SCMOK) x = writestring (logerror);
- if (x == SCMOK) x = writemend ();
- } else {
- x = readmsg (MSGLOGACK);
- if (x == SCMOK) x = readint (&logack);
- if (x == SCMOK) x = readstring (&logerror);
- if (x == SCMOK) x = readmend ();
- }
- return (x);
-}
-
-/*
- * refuse list message
- */
-extern TREE *refuseT; /* tree of files to refuse */
-
-static int refuseone (t)
-register TREE *t;
-{
- return (writestring (t->Tname));
-}
-
-int msgrefuse ()
-{
- register int x;
- if (server) {
- char *name;
- x = readmsg (MSGREFUSE);
- if (x == SCMOK) x = readstring (&name);
- while (x == SCMOK) {
- if (name == NULL) break;
- (void) Tinsert (&refuseT,name,FALSE);
- free (name);
- x = readstring (&name);
- }
- if (x == SCMOK) x = readmend ();
- } else {
- x = writemsg (MSGREFUSE);
- if (x == SCMOK) x = Tprocess (refuseT,refuseone);
- if (x == SCMOK) x = writestring ((char *)NULL);
- if (x == SCMOK) x = writemend ();
- }
- return (x);
-}
-
-/*
- * list files message
- */
-extern TREE *listT; /* tree of files to list */
-extern TREE *renameT; /* tree of rename target files */
-extern long scantime; /* time that collection was scanned */
-
-static int listone (t)
-register TREE *t;
-{
- register int x;
-
- x = writestring (t->Tname);
- if ( protver > 8 )
- if (x == SCMOK) x = writestring (t->Tnewname);
- if (x == SCMOK) x = writeint ((int)t->Tmode);
- if (x == SCMOK) x = writeint ((int)t->Tflags);
- if (x == SCMOK) x = writeint (t->Tmtime);
- return (x);
-}
-
-int msglist ()
-{
- register int x;
- if (server) {
- x = writemsg (MSGLIST);
- if (x == SCMOK) x = Tprocess (listT,listone);
- if (x == SCMOK) x = writestring ((char *)NULL);
- if (x == SCMOK) x = writeint ((int)scantime);
- if (x == SCMOK) x = writemend ();
- } else {
- char *name, *newname = NULL;
- int mode,flags,mtime;
- register TREE *t;
- x = readmsg (MSGLIST);
- if (x == SCMOK) x = readstring (&name);
- while (x == SCMOK) {
- if (name == NULL) break;
- if (protver > 8){
- x = readstring (&newname);
- if (x == SCMOK) x = readint (&mode);
- }
- else
- x = readint (&mode);
- if (x == SCMOK) x = readint (&flags);
- if (x == SCMOK) x = readint (&mtime);
- if (x != SCMOK) break;
- t = Tinsert (&listT,name,TRUE);
- free (name);
- t->Tnewname = newname;
- t->Tmode = mode;
- t->Tflags = flags;
- t->Tmtime = mtime;
- x = readstring (&name);
- }
- if (x == SCMOK) x = readint ((int *)&scantime);
- if (x == SCMOK) x = readmend ();
- }
- return (x);
-}
-
-/*
- * files needed message
- */
-extern TREE *needT; /* tree of files to need */
-
-static int needone (t)
-register TREE *t;
-{
- register int x;
- x = writestring (t->Tname);
- if (x == SCMOK) x = writeint ((t->Tflags&FUPDATE) != 0);
- return (x);
-}
-
-int msgneed ()
-{
- register int x;
- if (server) {
- char *name;
- int update;
- register TREE *t;
- x = readmsg (MSGNEED);
- if (x == SCMOK) x = readstring (&name);
- while (x == SCMOK) {
- if (name == NULL) break;
- x = readint (&update);
- if (x != SCMOK) break;
- t = Tinsert (&needT,name,TRUE);
- free (name);
- if (update) t->Tflags |= FUPDATE;
- x = readstring (&name);
- }
- if (x == SCMOK) x = readmend ();
- } else {
- x = writemsg (MSGNEED);
- if (x == SCMOK) x = Tprocess (needT,needone);
- if (x == SCMOK) x = writestring ((char *)NULL);
- if (x == SCMOK) x = writemend ();
- }
- return (x);
-}
-
-/*
- * files denied message
- */
-extern TREE *denyT; /* tree of files to deny */
-
-static int denyone (t)
-register TREE *t;
-{
- return (writestring (t->Tname));
-}
-
-int msgdeny ()
-{
- register int x;
- if (server) {
- x = writemsg (MSGDENY);
- if (x == SCMOK) x = Tprocess (denyT,denyone);
- if (x == SCMOK) x = writestring ((char *)NULL);
- if (x == SCMOK) x = writemend ();
- } else {
- char *name;
- x = readmsg (MSGDENY);
- if (x == SCMOK) x = readstring (&name);
- while (x == SCMOK) {
- if (name == NULL) break;
- (void) Tinsert (&denyT,name,FALSE);
- free (name);
- x = readstring (&name);
- }
- if (x == SCMOK) x = readmend ();
- }
- return (x);
-}
-
-/*
- * send file message
- */
-int msgsend ()
-{
- if (server)
- return (readmnull (MSGSEND));
- return (writemnull (MSGSEND));
-}
-
-/*
- * receive file message
- */
-extern TREE *upgradeT; /* pointer to file being upgraded */
-
-static int writeone (t)
-register TREE *t;
-{
- return (writestring (t->Tname));
-}
-
-
-#if __STDC__
-int msgrecv (PFI xferfile,...)
-#else
-/*VARARGS*//*ARGSUSED*/
-int msgrecv (va_alist)
-va_dcl
-#endif
-{
-#if !__STDC__
- typedef int (*PFI)();
- PFI xferfile;
-#endif
- va_list args;
- register int x;
- register TREE *t = upgradeT;
-#if __STDC__
- va_start(args,xferfile);
-#else
- va_start(args);
- xferfile = va_arg(args, PFI);
-#endif
- if (server) {
- x = writemsg (MSGRECV);
- if (t == NULL) {
- if (x == SCMOK) x = writestring ((char *)NULL);
- if (x == SCMOK) x = writemend ();
- return (x);
- }
- if (x == SCMOK) x = writestring (t->Tname);
- if (protver > 8)
- if (x == SCMOK) x = writestring (t->Tnewname);
- if (x == SCMOK) x = writeint (t->Tmode);
- if (t->Tmode == 0) {
- if (x == SCMOK) x = writemend ();
- return (x);
- }
- if (x == SCMOK) x = writeint (t->Tflags);
- if (x == SCMOK) x = writestring (t->Tuser);
- if (x == SCMOK) x = writestring (t->Tgroup);
- if (x == SCMOK) x = writeint (t->Tmtime);
- if (x == SCMOK) x = Tprocess (t->Tlink,writeone);
- if (x == SCMOK) x = writestring ((char *)NULL);
- if (x == SCMOK) x = Tprocess (t->Texec,writeone);
- if (x == SCMOK) x = writestring ((char *)NULL);
- if (x == SCMOK) x = (*xferfile) (t,args);
- if (x == SCMOK) x = writemend ();
- } else {
- char *linkname,*execcmd;
- if (t == NULL) return (SCMERR);
- x = readmsg (MSGRECV);
- if (x == SCMOK) x = readstring (&t->Tname);
- if (x == SCMOK && t->Tname == NULL) {
- x = readmend ();
- if (x == SCMOK) x = (*xferfile) (NULL,args);
- return (x);
- }
- if (protver > 8)
- if (x == SCMOK) x = readstring (&t->Tnewname);
- if (x == SCMOK) x = readint (&t->Tmode);
- if (t->Tmode == 0) {
- x = readmend ();
- if (x == SCMOK) x = (*xferfile) (t,args);
- return (x);
- }
- if (x == SCMOK) x = readint (&t->Tflags);
- if (x == SCMOK) x = readstring (&t->Tuser);
- if (x == SCMOK) x = readstring (&t->Tgroup);
- if (x == SCMOK) x = readint (&t->Tmtime);
- t->Tlink = NULL;
- if (x == SCMOK) x = readstring (&linkname);
- while (x == SCMOK) {
- if (linkname == NULL) break;
- (void) Tinsert (&t->Tlink,linkname,FALSE);
- free (linkname);
- x = readstring (&linkname);
- }
- t->Texec = NULL;
- if (x == SCMOK) x = readstring (&execcmd);
- while (x == SCMOK) {
- if (execcmd == NULL) break;
- (void) Tinsert (&t->Texec,execcmd,FALSE);
- free (execcmd);
- x = readstring (&execcmd);
- }
- if (x == SCMOK) x = (*xferfile) (t,args);
- if (x == SCMOK) x = readmend ();
- }
- va_end(args);
- return (x);
-}
-
-/*
- * protocol done message
- */
-extern int doneack;
-extern char *donereason;
-
-int msgdone ()
-{
- register int x;
-
- if (protver < 6) {
- printf ("Error, msgdone should not have been called.");
- return (SCMERR);
- }
- if (server) {
- x = readmsg (MSGDONE);
- if (x == SCMOK) x = readint (&doneack);
- if (x == SCMOK) x = readstring (&donereason);
- if (x == SCMOK) x = readmend ();
- } else {
- x = writemsg (MSGDONE);
- if (x == SCMOK) x = writeint (doneack);
- if (x == SCMOK) x = writestring (donereason);
- if (x == SCMOK) x = writemend ();
- }
- return (x);
-}
-
-/*
- * go away message
- */
-extern char *goawayreason; /* reason for goaway */
-
-int msggoaway ()
-{
- return (writemstr (MSGGOAWAY,goawayreason));
-}
-
-/*
- * cross-patch protocol message
- */
-extern int xargc; /* arg count for crosspatch */
-extern char **xargv; /* arg array for crosspatch */
-
-int msgxpatch ()
-{
- register int x;
- register int i;
-
- if (server) {
- x = readmsg (MSGXPATCH);
- if (x != SCMOK) return (x);
- x = readint (&xargc);
- if (x != SCMOK) return (x);
- xargc += 2;
- xargv = (char **)calloc (sizeof (char *),(unsigned)xargc+1);
- if (xargv == NULL)
- return (SCMERR);
- for (i = 2; i < xargc; i++) {
- x = readstring (&xargv[i]);
- if (x != SCMOK) return (x);
- }
- x = readmend ();
- } else {
- x = writemsg (MSGXPATCH);
- if (x != SCMOK) return (x);
- x = writeint (xargc);
- if (x != SCMOK) return (x);
- for (i = 0; i < xargc; i++) {
- x = writestring (xargv[i]);
- if (x != SCMOK) return (x);
- }
- x = writemend ();
- }
- return (x);
-}
-
-/*
- * Compression check protocol message
- */
-extern int docompress; /* Compress file before sending? */
-
-int msgcompress ()
-{
- if (server)
- return (readmint (MSGCOMPRESS,&docompress));
- return (writemint (MSGCOMPRESS, docompress));
-}
diff --git a/usr.sbin/sup/lib/supmsg.h b/usr.sbin/sup/lib/supmsg.h
deleted file mode 100644
index e6185c4..0000000
--- a/usr.sbin/sup/lib/supmsg.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * supmsg.h - global definitions/variables used in msg routines.
- *
- **********************************************************************
- * HISTORY
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * $Log: supmsg.h,v $
- * Revision 1.1.1.1 1995/12/26 04:54:47 peter
- * Import the unmodified version of the sup that we are using.
- * The heritage of this version is not clear. It appears to be NetBSD
- * derived from some time ago.
- *
- * Revision 1.1.1.1 1993/08/21 00:46:35 jkh
- * Current sup with compression support.
- *
- * Revision 1.1.1.1 1993/05/21 14:52:19 cgd
- * initial import of CMU's SUP to NetBSD
- *
- * Revision 1.7 92/08/11 12:08:20 mrt
- * Added copyright.
- * [92/08/10 mrt]
- *
- * Revision 1.6 89/08/23 14:56:42 gm0w
- * Changed MSGF to MSG constants.
- * [89/08/23 gm0w]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support. Removed nameserver support.
- *
- * 29-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added "release" support.
- *
- * 27-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Added MSGFDONE and subvalues, added doneack and donereason.
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added changes to make lint happy.
- *
- * 04-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed hostname to hostT to support multiple repositories per
- * collection. Added FSETUPBUSY to tell clients that server is
- * currently busy.
- *
- * 19-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-/* Special messages reserved for SCM */
-#define MSGGOAWAY (-1) /* see scm.c */
-
-/* Message types -- see supmsg.c */
-#define MSGSIGNON (101)
-#define MSGSIGNONACK (102)
-#define MSGSETUP (103)
-#define MSGSETUPACK (104)
-#define MSGLOGIN (105)
-#define MSGLOGACK (106)
-#define MSGCRYPT (107)
-#define MSGCRYPTOK (108)
-#define MSGREFUSE (109)
-#define MSGLIST (110)
-#define MSGNEED (111)
-#define MSGDENY (112)
-#define MSGSEND (113)
-#define MSGRECV (114)
-#define MSGDONE (115)
-#define MSGXPATCH (117)
-#define MSGCOMPRESS (118)
-
-/* MSGSETUPACK data codes - setupack */
-#define FSETUPOK (999)
-#define FSETUPHOST (998)
-#define FSETUPSAME (997)
-#define FSETUPOLD (996)
-#define FSETUPBUSY (995)
-#define FSETUPRELEASE (994)
-
-/* MSGLOGACK data codes - loginack */
-#define FLOGOK (989)
-#define FLOGNG (988)
-
-/* MSGDONE data codes - doneack */
-#define FDONESUCCESS (979)
-#define FDONEDONTLOG (978)
-#define FDONESRVERROR (977)
-#define FDONEUSRERROR (976)
-#define FDONEGOAWAY (975)
-
-#ifdef MSGSUBR
-
-/* used in all msg routines */
-extern int server; /* true if we are the server */
-extern int protver; /* protocol version of partner */
-
-#else MSGSUBR
-
-#ifdef MSGFILE
-#define EXTERN
-#else MSGFILE
-#define EXTERN extern
-#endif MSGFILE
-
-/* used in all msg routines */
-EXTERN int server; /* true if we are the server */
-
-/* msggoaway */
-EXTERN char *goawayreason; /* reason for goaway */
-
-/* msgsignon */
-EXTERN int pgmversion; /* version of this program */
-EXTERN int protver; /* protocol version of partner */
-EXTERN int pgmver; /* program version of partner */
-EXTERN char *scmver; /* scm version of partner */
-EXTERN int fspid; /* process id of fileserver */
-
-/* msgsetup */
-EXTERN int xpatch; /* setup crosspatch to a new client */
-EXTERN char *xuser; /* user for crosspatch */
-EXTERN char *collname; /* collection name */
-EXTERN char *basedir; /* base directory */
-EXTERN int basedev; /* base directory device */
-EXTERN int baseino; /* base directory inode */
-EXTERN long lasttime; /* time of last upgrade */
-EXTERN int listonly; /* only listing files, no data xfer */
-EXTERN int newonly; /* only send new files */
-EXTERN char *release; /* release name */
-EXTERN int setupack; /* ack return value for setup */
-
-/* msgcrypt */
-EXTERN char *crypttest; /* encryption test string */
-
-/* msglogin */
-EXTERN char *logcrypt; /* login encryption test */
-EXTERN char *loguser; /* login username */
-EXTERN char *logpswd; /* password for login */
-EXTERN int logack; /* login ack status */
-EXTERN char *logerror; /* error string from oklogin */
-
-/* msgxpatch */
-EXTERN int xargc; /* arg count for crosspatch */
-EXTERN char **xargv; /* arg array for crosspatch */
-
-/* msgrefuse */
-EXTERN TREE *refuseT; /* tree of files to refuse */
-
-/* msglist */
-EXTERN TREE *listT; /* tree of files to list */
-EXTERN TREE *renameT; /* tree of file rename targets */
-EXTERN long scantime; /* time that collection was scanned */
-
-/* msgneed */
-EXTERN TREE *needT; /* tree of files to need */
-
-/* msgdeny */
-EXTERN TREE *denyT; /* tree of files to deny */
-
-/* msgrecv */
-/* msgsend */
-EXTERN TREE *upgradeT; /* pointer to file being upgraded */
-
-/* msgdone */
-EXTERN int doneack; /* done ack status */
-EXTERN char *donereason; /* set if indicated by doneack */
-
-#undef EXTERN
-
-#endif MSGSUBR
OpenPOWER on IntegriCloud