- add missing prototypes.

- fix function call inconsistencies
- fix int <-> long and pointer conversions
It should run now on 64 bit machines...
This commit is contained in:
christos 1996-12-23 19:42:01 +00:00
parent 18a537d1da
commit 9d10a25919
29 changed files with 893 additions and 430 deletions

View File

@ -37,6 +37,8 @@
* Rewritten for VAX.
*
*/
#include "supcdefs.h"
#include "supextern.h"
unsigned int atoo(ap)
char *ap;

View File

@ -31,9 +31,11 @@
* BBN uses a negative OR zero value.
*/
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
#include "supcdefs.h"
#include "supextern.h"
#ifndef __NetBSD__
static char *itoa __P((char *, unsigned));
static char *itoa(p,n)
char *p;
@ -44,10 +46,15 @@ unsigned n;
*p++ = (n%10)+'0';
return(p);
}
#endif
char *errmsg(cod)
int cod;
{
#ifndef __NetBSD__
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
static char unkmsg[] = "Unknown error ";
static char unk[sizeof(unkmsg)+11]; /* trust us */
@ -60,4 +67,7 @@ int cod;
*itoa(&unk[sizeof(unkmsg)-1],cod) = '\0';
return(unk);
#else
return strerror(cod);
#endif
}

View File

@ -70,6 +70,8 @@
#include <ctype.h>
#include <libc.h>
#include <setjmp.h>
#include <stdlib.h>
#include <unistd.h>
static jmp_buf sjbuf;
@ -83,17 +85,26 @@ static char **BUFFER; /* pointer to the buffer */
static int BUFSIZE; /* maximum number in buffer */
static int bufcnt; /* current number in buffer */
static void glob();
static void matchdir();
static int execbrc();
static int match();
static int amatch();
static void addone();
static int addpath();
static int gethdir();
#define fixit(a) (a[0] ? a : ".")
#ifndef __P
#ifdef __STDC__
#define __P(a) a
#else
#define __P(a) ()
#endif
#endif
int expand __P((char *, char **, int));
static void glob __P((char *));
static void matchdir __P((char *));
static int execbrc __P((char *, char *));
static int match __P((char *, char *));
static int amatch __P((char *, char *));
static void addone __P((char *, char *));
static int addpath __P((int));
static int gethdir __P((char *));
int expand(spec, buffer, bufsize)
register char *spec;
char **buffer;
@ -282,7 +293,7 @@ static int amatch(s, p)
case '[':
ok = 0;
lc = 077777;
while (cc = *p++) {
while ((cc = *p++) != 0) {
if (cc == ']') {
if (ok) break;
return (0);
@ -352,7 +363,8 @@ static void addone(s1, s2)
}
BUFFER[bufcnt++] = ep;
while (*s1) *ep++ = *s1++;
while (*ep++ = *s2++);
while ((*ep++ = *s2++) != '\0')
continue;
}
static int addpath(c)
@ -368,7 +380,6 @@ static int addpath(c)
static int gethdir(home)
char *home;
{
struct passwd *getpwnam();
register struct passwd *pp = getpwnam(home);
if (pp == 0)

View File

@ -45,7 +45,8 @@
*/
#include <stdio.h>
int filecopy();
#include "supcdefs.h"
#include "supextern.h"
int ffilecopy (here,there)
FILE *here, *there;

View File

@ -52,6 +52,8 @@
*/
#define BUFFERSIZE 10240
#include "supcdefs.h"
#include "supextern.h"
int filecopy (here,there)
int here,there;

View File

@ -26,6 +26,12 @@
**********************************************************************
* HISTORY
* $Log: libc.h,v $
* Revision 1.2 1996/12/23 19:42:05 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.1.1.1 1993/05/21 14:52:17 cgd
* initial import of CMU's SUP to NetBSD
*
@ -115,9 +121,6 @@ extern FILE *fwantwrite();
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*);
@ -148,9 +151,7 @@ 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();
@ -188,7 +189,9 @@ extern long atot();
/* 4.3 BSD standard library routines; taken from man(3) */
#if defined(__STDC__)
#if 0
typedef int (*PFI)();
#endif
#if defined(c_plusplus)
typedef int (*PFI2)(...);
#endif /* c_plusplus */

View File

@ -27,6 +27,12 @@
**********************************************************************
* HISTORY
* $Log: log.c,v $
* Revision 1.2 1996/12/23 19:42:06 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.1.1.1 1993/05/21 14:52:17 cgd
* initial import of CMU's SUP to NetBSD
*
@ -51,20 +57,12 @@
#include <stdio.h>
#include <sys/syslog.h>
#include <c.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "sup.h"
#ifdef lint
/*VARARGS1*//*ARGSUSED*/
static void quit(status) {};
#endif /* lint */
#include "supcdefs.h"
#include "supextern.h"
static int opened = 0;
void
logopen(program)
char *program;
{
@ -73,7 +71,8 @@ char *program;
opened++;
}
#if __STDC__
void
#ifdef __STDC__
logquit(int retval,char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -81,16 +80,15 @@ logquit(va_alist)
va_dcl
#endif
{
#if !__STDC__
int retval;
char *fmt;
#endif
char buf[STRINGLENGTH];
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
int retval;
char *fmt;
va_start(ap);
retval = va_arg(ap,int);
fmt = va_arg(ap,char *);
@ -102,10 +100,11 @@ va_dcl
closelog ();
exit (retval);
}
quit (retval,"SUP: %s\n",buf);
quit (retval,"SUP: %s\n", buf);
}
#if __STDC__
void
#ifdef __STDC__
logerr(char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -113,15 +112,14 @@ logerr(va_alist)
va_dcl
#endif
{
#if !__STDC__
char *fmt;
#endif
char buf[STRINGLENGTH];
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
char *fmt;
va_start(ap);
fmt = va_arg(ap,char *);
#endif
@ -135,7 +133,8 @@ va_dcl
(void) fflush (stderr);
}
#if __STDC__
void
#ifdef __STDC__
loginfo(char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -143,15 +142,14 @@ loginfo(va_alist)
va_dcl
#endif
{
#if !__STDC__
char *fmt;
#endif
char buf[STRINGLENGTH];
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
char *fmt;
va_start(ap);
fmt = va_arg(ap,char *);
#endif

View File

@ -25,6 +25,12 @@
/**********************************************************************
* HISTORY
* $Log: netcryptvoid.c,v $
* Revision 1.2 1996/12/23 19:42:07 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.1.1.1 1993/05/21 14:52:17 cgd
* initial import of CMU's SUP to NetBSD
*
@ -47,7 +53,8 @@
*/
#include <libc.h>
#include "sup.h"
#include "supcdefs.h"
#include "supextern.h"
#include "supmsg.h"
/*********************************************

View File

@ -52,9 +52,10 @@
*
* Originally from klg (Ken Greer); IUS/SUS UNIX.
*/
#include "supcdefs.h"
#include "supextern.h"
char _argbreak;
char *skipto();
char *nxtarg (q,brk)
char **q,*brk;
@ -65,7 +66,7 @@ char **q,*brk;
while (*front && (*front == ' ' || *front == '\t')) front++;
/* find break character at end */
if (brk == 0) brk = " ";
back = skipto (front,brk);
back = skipto ((unsigned char *) front,(unsigned char *) brk);
_argbreak = *back;
*q = (*back ? back+1 : back); /* next arg start loc */
/* elim trailing blanks and tabs */

View File

@ -56,7 +56,10 @@
* If you want to be cute, you can also resolve ".."s at that time.
*
*/
#include "supcdefs.h"
#include "supextern.h"
void
path (original,direc,file)
char *original,*direc,*file;
{
@ -67,7 +70,7 @@ char *original,*direc,*file;
/* copy and note the end */
p = original;
y = direc;
while (*y++ = *p++) ; /* copy string */
while ((*y++ = *p++) != '\0') ; /* 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 */

View File

@ -36,6 +36,12 @@
**********************************************************************
* HISTORY
* $Log: quit.c,v $
* Revision 1.2 1996/12/23 19:42:09 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.1.1.1 1993/05/21 14:52:17 cgd
* initial import of CMU's SUP to NetBSD
*
@ -47,17 +53,30 @@
*/
#include <stdio.h>
#include <varargs.h>
#include "supcdefs.h"
#include "supextern.h"
quit (status, fmt, va_alist)
int status;
char *fmt;
void
#ifdef __STDC__
quit (int status, char * fmt, ...)
#else
quit (va_alist)
va_dcl
#endif
{
va_list args;
#ifdef __STDC__
va_start(args, fmt);
#else
int status;
char *fmt;
va_start(args);
status = va_arg(args, int);
fmt = va_arg(args, char *);
#endif
fflush(stdout);
va_start(args);
(void) vfprintf(stderr, fmt, args);
va_end(args);
exit(status);

View File

@ -48,6 +48,12 @@
**********************************************************************
* HISTORY
* $Log: run.c,v $
* Revision 1.4 1996/12/23 19:42:09 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.3 1996/09/05 16:50:03 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -115,7 +121,9 @@
#include <signal.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <varargs.h>
#include "supcdefs.h"
#include "supextern.h"
#ifndef __STDC__
#ifndef const
@ -123,17 +131,28 @@
#endif
#endif
static int dorun();
static int dorun __P((char *, char **, int));
int run (name,va_alist)
char *name;
int
#ifdef __STDC__
run(char *name, ...)
#else
run(va_alist)
va_dcl
#endif
{
int val;
va_list ap;
#ifdef __STDC__
va_start(ap, name);
#else
char *name;
va_start(ap);
val = runv (name,ap);
name = va_arg(ap, char *);
#endif
val = runv (name, (char **) ap);
va_end(ap);
return(val);
}
@ -144,15 +163,26 @@ char *name,**argv;
return (dorun (name, argv, 0));
}
int runp (name,va_alist)
char *name;
int
#ifdef __STDC__
runp(char *name, ...)
#else
runp (va_alist)
va_dcl
#endif
{
int val;
va_list ap;
#ifdef __STDC__
va_start(ap, name);
#else
char *name;
va_start(ap);
val = runvp (name,ap);
name = va_arg(ap, char *);
#endif
val = runvp (name, (char **) ap);
va_end(ap);
return (val);
}
@ -172,8 +202,6 @@ int usepath;
register int pid;
struct sigaction ignoresig,intsig,quitsig;
int status;
int execvp(), execv();
int (*execrtn)() = usepath ? execvp : execv;
if ((pid = vfork()) == -1)
return(-1); /* no more process's, so exit with error */
@ -181,7 +209,10 @@ int usepath;
if (pid == 0) { /* child process */
setgid (getgid());
setuid (getuid());
(*execrtn) (name,argv);
if (usepath)
execvp(name,argv);
else
execv(name,argv);
fprintf (stderr,"run: can't exec %s\n",name);
_exit (0377);
}

View File

@ -33,7 +33,9 @@
*
**********************************************************************
*/
char *malloc();
#include "supcdefs.h"
#include "supextern.h"
char *salloc(p)
char *p;

View File

@ -28,6 +28,12 @@
**********************************************************************
* HISTORY
* $Log: scan.c,v $
* Revision 1.6 1996/12/23 19:42:11 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.5 1996/09/05 16:50:04 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -128,7 +134,8 @@
#endif
#include <sys/file.h>
#include <unistd.h>
#include "sup.h"
#include "supcdefs.h"
#include "supextern.h"
/*************************
*** M A C R O S ***
@ -203,34 +210,35 @@ extern char *rcs_branch;
extern int candorcs;
#endif
extern long time();
/*************************************************
*** STATIC R O U T I N E S ***
*************************************************/
static void passdelim __P((char **, int ));
static char *parserelease __P((TREELIST **, char *, char *));
static int scanone __P((TREE *, void *));
static void makescan __P((char *, char *));
static void getscan __P((char *, char *));
static void doscan __P((char *));
static void readlistfile __P((char *));
static void expTinsert __P((char *, TREE **, int, char *));
static int listone __P((TREE *, void *));
static void listentry __P((char *, char *, char *, int));
static void listname __P((char *, struct stat *));
static void listdir __P((char *, int));
static int omitanyone __P((TREE *, void *));
static int anyglob __P((char *, char *));
static int getscanfile __P((char *));
static void chkscanfile __P((char *));
static void makescanfile __P((char *));
static int recordone __P((TREE *, void *));
static int recordexec __P((TREE *, void *));
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 chkscanfile();
static makescanfile();
static recordone();
static recordexec();
/*************************************************
*** L I S T S C A N R O U T I N E S ***
*************************************************/
static
static void
passdelim (ptr,delim) /* skip over delimiter */
char **ptr,delim;
{
@ -302,6 +310,7 @@ char *relname,*args;
return (nextrel);
}
int
getrelease (release)
char *release;
{
@ -360,6 +369,7 @@ char *release;
return (TRUE);
}
void
makescanlists ()
{
TREELIST *tl;
@ -372,7 +382,7 @@ makescanlists ()
(void) sprintf (buf,FILERELEASES,collname);
f = fopen (buf,"r");
if (f != NULL) {
while (p = fgets (buf,sizeof(buf),f)) {
while ((p = fgets (buf,sizeof(buf),f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
if (index ("#;:",*p)) continue;
@ -395,9 +405,10 @@ makescanlists ()
makescan ((char *)NULL,(char *)NULL);
}
static
scanone (t)
static int
scanone (t, v)
register TREE *t;
void *v;
{
register TREE *newt;
@ -412,6 +423,7 @@ register TREE *t;
return (SCMOK);
}
void
getscanlists ()
{
TREELIST *tl,*stl;
@ -428,10 +440,10 @@ getscanlists ()
}
listT = NULL;
for (tl = listTL; tl != NULL; tl = tl->TLnext)
(void) Tprocess (tl->TLtree,scanone);
(void) Tprocess (tl->TLtree, scanone, NULL);
}
static
static void
makescan (listfile,scanfile)
char *listfile,*scanfile;
{
@ -442,12 +454,10 @@ char *listfile,*scanfile;
Tfree (&listT); /* free file list tree */
}
static
static void
getscan (listfile,scanfile)
char *listfile,*scanfile;
{
struct tm *utc_time;
listT = NULL;
if (!getscanfile(scanfile)) { /* check for pre-scanned file list */
scantime = time ((long *)NULL);
@ -455,12 +465,11 @@ char *listfile,*scanfile;
}
}
static
static void
doscan (listfile)
char *listfile;
{
char buf[STRINGLENGTH];
int listone ();
upgT = NULL;
flagsT = NULL;
@ -473,7 +482,7 @@ doscan (listfile)
listfile = FILELISTDEF;
(void) sprintf (buf,FILELIST,collname,listfile);
readlistfile (buf); /* get contents of list file */
(void) Tprocess (upgT,listone); /* build list of files specified */
(void) Tprocess (upgT,listone, NULL); /* build list of files specified */
cdprefix ((char *)NULL);
Tfree (&upgT);
Tfree (&flagsT);
@ -484,7 +493,7 @@ doscan (listfile)
Tfree (&rsymT);
}
static
static void
readlistfile (fname)
char *fname;
{
@ -492,15 +501,15 @@ char *fname;
register char *q,*r;
register FILE *f;
register int ltn,n,i,flags;
register TREE **t;
register TREE **t = NULL;
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,sizeof(buf),f)) {
if (q = index (p,'\n')) *q = '\0';
while ((p = fgets (buf,sizeof(buf),f)) != NULL) {
if ((q = index (p,'\n')) != NULL) *q = '\0';
if (index ("#;:",*p)) continue;
q = nxtarg (&p," \t");
if (*q == '\0') continue;
@ -580,7 +589,7 @@ char *fname;
(void) fclose (f);
}
static
static void
expTinsert (p,t,flags,exec)
char *p;
TREE **t;
@ -604,22 +613,22 @@ char *exec;
}
}
static
listone (t) /* expand and add one name from upgrade list */
static int
listone (t, v) /* expand and add one name from upgrade list */
TREE *t;
void *v;
{
listentry(t->Tname,t->Tname,(char *)NULL,(t->Tflags&FALWAYS) != 0);
return (SCMOK);
}
static
static void
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) {
@ -682,7 +691,7 @@ int always;
listname (fullname,&statbuf);
}
static
static void
listname (name,st)
register char *name;
register struct stat *st;
@ -694,7 +703,7 @@ register struct stat *st;
new = st->st_ctime > lasttime;
if (newonly && !new) {
for (tl = listTL; tl != NULL; tl = tl->TLnext)
if (ts = Tsearch (tl->TLtree,name))
if ((ts = Tsearch (tl->TLtree,name)) != NULL)
ts->Tflags &= ~FNEW;
return;
}
@ -704,15 +713,15 @@ register struct stat *st;
t->Tctime = st->st_ctime;
t->Tmtime = st->st_mtime;
if (new) t->Tflags |= FNEW;
if (ts = Tsearch (flagsT,name))
if ((ts = Tsearch (flagsT,name)) != NULL)
t->Tflags |= ts->Tflags;
if (ts = Tsearch (execT,name)) {
if ((ts = Tsearch (execT,name)) != NULL) {
t->Texec = ts->Texec;
ts->Texec = NULL;
}
}
static
static void
listdir (name,always) /* expand directory */
char *name;
int always;
@ -736,13 +745,13 @@ int always;
p += 2;
while (*p == '/') p++;
}
while (*newp++ = *p++) ; /* copy string */
while ((*newp++ = *p++) != '\0') ; /* 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)) {
while ((dentry=readdir(dirp)) != NULL) {
if (dentry->d_ino == 0) continue;
if (strcmp(dentry->d_name,".") == 0) continue;
if (strcmp(dentry->d_name,"..") == 0) continue;
@ -758,17 +767,18 @@ int always;
closedir (dirp);
}
static
omitanyone (t,filename)
static int
omitanyone (t,fv)
TREE *t;
char **filename;
void *fv;
{
if (anyglob (t->Tname,*filename))
char *filename = fv;
if (anyglob (t->Tname,filename))
return (SCMERR);
return (SCMOK);
}
static
static int
anyglob (pattern,match)
char *pattern,*match;
{
@ -860,7 +870,7 @@ char *scanfile;
(void) fclose (f);
return (FALSE);
}
if (q = index (p,'\n')) *q = '\0';
if ((q = index (p,'\n')) != NULL) *q = '\0';
if (*p++ != 'V') {
(void) fclose (f);
return (FALSE);
@ -876,7 +886,7 @@ char *scanfile;
return (TRUE);
}
notwanted = FALSE;
while (p = fgets (buf,sizeof(buf),f)) {
while ((p = fgets (buf,sizeof(buf),f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
ts.Tflags = 0;
@ -915,7 +925,7 @@ char *scanfile;
ts.Tflags |= FNEW;
else if (newonly) {
for (tl = listTL; tl != NULL; tl = tl->TLnext)
if (tmp = Tsearch (tl->TLtree,fname))
if ((tmp = Tsearch (tl->TLtree,fname)) != NULL)
tmp->Tflags &= ~FNEW;
notwanted = TRUE;
continue;
@ -938,7 +948,7 @@ char *scanfile;
*** W R I T E S C A N F I L E ***
*******************************************/
static chkscanfile (scanfile)
static void chkscanfile (scanfile)
char *scanfile;
{
char tname[STRINGLENGTH], fname[STRINGLENGTH];
@ -956,13 +966,12 @@ char *scanfile;
}
}
static makescanfile (scanfile)
static void makescanfile (scanfile)
char *scanfile;
{
char tname[STRINGLENGTH],fname[STRINGLENGTH];
struct timeval tbuf[2];
FILE *scanF; /* output file for scanned file list */
int recordone ();
if (scanfile == NULL)
scanfile = FILESCANDEF;
@ -982,34 +991,36 @@ char *scanfile;
(void) utimes (fname,tbuf);
}
static
recordone (t,scanF)
static int
recordone (t,v)
TREE *t;
FILE **scanF;
void *v;
{
int recordexec ();
FILE *scanF = v;
char fname[MAXPATHLEN*4+1];
if (t->Tflags&FBACKUP) fprintf (*scanF,"B");
if (t->Tflags&FNOACCT) fprintf (*scanF,"N");
if (t->Tflags&FBACKUP) fprintf (scanF,"B");
if (t->Tflags&FNOACCT) fprintf (scanF,"N");
strvis(fname, t->Tname, VIS_WHITE);
fprintf (*scanF,"%o %d %d %s\n",
fprintf (scanF,"%o %d %d %s\n",
t->Tmode,t->Tctime,t->Tmtime,fname);
(void) Tprocess (t->Texec,recordexec,*scanF);
(void) Tprocess (t->Texec,recordexec, scanF);
return (SCMOK);
}
static
recordexec (t,scanF)
static int
recordexec (t,v)
TREE *t;
FILE **scanF;
void *v;
{
FILE *scanF = v;
char fname[MAXPATHLEN*4+1];
strvis(fname, t->Tname, VIS_WHITE);
fprintf(*scanF,"X%s\n",fname);
fprintf(scanF,"X%s\n",fname);
return (SCMOK);
}
void
cdprefix (prefix)
char *prefix;
{

View File

@ -69,6 +69,12 @@
* since Tahoe version of <netinet/in.h> does not define them.
*
* $Log: scm.c,v $
* Revision 1.4 1996/12/23 19:42:12 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.3 1996/09/05 16:50:05 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -206,7 +212,8 @@
#else
#include <varargs.h>
#endif
#include "sup.h"
#include "supcdefs.h"
#include "supextern.h"
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff /* -1 return */
@ -216,7 +223,6 @@
#endif
extern int errno;
static char *myhost ();
char scmversion[] = "4.3 BSD";
extern int silent;
@ -242,15 +248,15 @@ static struct in_addr remoteaddr; /* remote host address */
static char *remotename = NULL; /* remote host name */
static int swapmode; /* byte-swapping needed on server? */
#if __STDC__
int scmerr(int,char *,...);
#endif
static char *myhost __P((void));
/***************************************************
*** 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 ***
***************************************************/
int
servicesetup (server) /* listen for clients */
char *server;
{
@ -288,6 +294,7 @@ char *server;
return (SCMOK);
}
int
service ()
{
struct sockaddr_in from;
@ -312,6 +319,7 @@ service ()
return (SCMOK);
}
int
serviceprep () /* kill temp socket in daemon */
{
if (sock >= 0) {
@ -321,6 +329,7 @@ serviceprep () /* kill temp socket in daemon */
return (SCMOK);
}
int
servicekill () /* kill net file in daemon's parent */
{
if (netfile >= 0) {
@ -334,6 +343,7 @@ servicekill () /* kill net file in daemon's parent */
return (SCMOK);
}
int
serviceend () /* kill net file after use in daemon */
{
if (netfile >= 0) {
@ -352,7 +362,7 @@ serviceend () /* kill net file after use in daemon */
*** F O R C L I E N T ***
***************************************************/
dobackoff (t,b)
int dobackoff (t,b)
int *t,*b;
{
struct timeval tt;
@ -375,6 +385,7 @@ int *t,*b;
return (1);
}
int
request (server,hostname,retry) /* connect to server */
char *server;
char *hostname;
@ -431,6 +442,7 @@ int *retry;
return (SCMOK);
}
int
requestend () /* end connection to server */
{
(void) readflush ();
@ -551,7 +563,7 @@ char *name;
return (0);
}
#if __STDC__
#ifdef __STDC__
int scmerr (int errno,char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -559,24 +571,24 @@ int scmerr (va_alist)
va_dcl
#endif
{
#if !__STDC__
va_list ap;
#ifdef __STDC__
va_start(ap,fmt);
#else
int errno;
char *fmt;
va_start(ap);
errno = va_arg(ap,int);
fmt = va_arg(ap,char *);
#endif
va_list ap;
(void) fflush (stdout);
if (progpid > 0)
fprintf (stderr,"%s %d: ",program,progpid);
else
fprintf (stderr,"%s: ",program);
#if __STDC__
va_start(ap,fmt);
#else
va_start(ap);
errno = va_arg(ap,int);
fmt = va_arg(ap,char *);
#endif
vfprintf(stderr, fmt, ap);
va_end(ap);
if (errno >= 0)

View File

@ -109,6 +109,12 @@
**********************************************************************
* HISTORY
* $Log: scmio.c,v $
* Revision 1.3 1996/12/23 19:42:13 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.2 1993/05/24 17:57:26 brezak
* Remove netcrypt.c. Remove unneeded files. Cleanup make.
*
@ -166,7 +172,8 @@
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/time.h>
#include "sup.h"
#include "supcdefs.h"
#include "supextern.h"
#include "supmsg.h"
extern int errno;
@ -187,7 +194,6 @@ extern int errno;
*** 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 */
@ -204,12 +210,17 @@ struct buf {
} buffers[2];
struct buf *bufptr; /* buffer pointer */
static int writedata __P((int, char *));
static int writeblock __P((int, char *));
static int readdata __P((int, char *));
static int readcount __P((int *));
/***********************************************
*** O U T P U T T O N E T W O R K ***
***********************************************/
static
static int
writedata (count,data) /* write raw data to network */
int count;
char *data;
@ -256,7 +267,7 @@ char *data;
return (SCMOK);
}
static
static int
writeblock (count,data) /* write data block */
int count;
char *data;
@ -269,6 +280,7 @@ char *data;
return (x);
}
int
writemsg (msg) /* write start of message */
int msg;
{
@ -285,6 +297,7 @@ int msg;
return (writedata(sizeof(int),(char *)&x));
}
int
writemend () /* write end of message */
{
register int count;
@ -306,6 +319,7 @@ writemend () /* write end of message */
return (writedata (count, data));
}
int
writeint (i) /* write int as data block */
int i;
{
@ -316,6 +330,7 @@ int i;
return (writeblock(sizeof(int),(char *)&x));
}
int
writestring (p) /* write string as data block */
char *p;
{
@ -339,11 +354,12 @@ char *p;
return (writeblock(len,p));
}
int
writefile (f) /* write open file as a data block */
int f;
{
char buf[FILEXFER];
register int number,sum,filesize,x;
register int number = 0,sum = 0,filesize,x;
int y;
struct stat statbuf;
@ -378,6 +394,7 @@ int f;
return (x);
}
int
writemnull (msg) /* write message with no data */
int msg;
{
@ -387,6 +404,7 @@ int msg;
return (x);
}
int
writemint (msg,i) /* write message of one int */
int msg,i;
{
@ -397,6 +415,7 @@ int msg,i;
return (x);
}
int
writemstr (msg,p) /* write message of one string */
int msg;
char *p;
@ -412,7 +431,7 @@ char *p;
*** I N P U T F R O M N E T W O R K ***
*************************************************/
static
static int
readdata (count,data) /* read raw data from network */
int count;
char *data;
@ -516,11 +535,13 @@ int *count;
return (SCMOK);
}
int
readflush ()
{
return (readdata (0, (char *)NULL));
}
int
readmsg (msg) /* read header for expected message */
int msg; /* if message is unexpected, send back SCMHUH */
{
@ -545,6 +566,7 @@ int msg; /* if message is unexpected, send back SCMHUH */
return (SCMEOF);
}
int
readmend ()
{
register int x;
@ -556,6 +578,7 @@ readmend ()
return (x);
}
int
readskip () /* skip over one input block */
{
register int x;
@ -630,6 +653,7 @@ register char **buf;
return (SCMOK);
}
int
readfile (f) /* read data block into open file */
int f;
{
@ -660,6 +684,7 @@ int f;
return (x);
}
int
readmnull (msg) /* read null message */
int msg;
{
@ -669,6 +694,7 @@ int msg;
return (x);
}
int
readmint (msg,buf) /* read int message */
int msg,*buf;
{
@ -694,6 +720,7 @@ char **buf;
*** C R O S S P A T C H ***
**********************************/
void
crosspatch ()
{
fd_set ibits, obits, xbits;

View File

@ -50,11 +50,14 @@
* and partly due to popular usage of this function.
*/
static unsigned char tab[256] = {
#include "supcdefs.h"
#include "supextern.h"
static char tab[256] = {
0};
char *skipto (string,charset)
unsigned char *string, *charset;
char *string, *charset;
{
register unsigned char *setp,*strp;
@ -66,7 +69,7 @@ unsigned char *string, *charset;
}
char *skipover (string,charset)
unsigned char *string, *charset;
char *string, *charset;
{
register unsigned char *setp,*strp;

View File

@ -28,6 +28,12 @@
**********************************************************************
* HISTORY
* $Log: stree.c,v $
* Revision 1.2 1996/12/23 19:42:14 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.1.1.1 1993/05/21 14:52:17 cgd
* initial import of CMU's SUP to NetBSD
*
@ -57,14 +63,27 @@
#include <libc.h>
#include <c.h>
#include <sys/param.h>
#include "sup.h"
#include "supcdefs.h"
#include "supextern.h"
#define Static static /* comment for debugging */
Static TREE *Tmake __P((char *));
Static TREE *Trotll __P((TREE *, TREE *));
Static TREE *Trotlh __P((TREE *, TREE *));
Static TREE *Trothl __P((TREE *, TREE *));
Static TREE *Trothh __P((TREE *, TREE *));
Static void Tbalance __P((TREE **));
Static TREE *Tinsertavl __P((TREE **, char *, int, int *));
Static int Tsubprocess __P((TREE *, int, int (*f )(TREE *, void *), void *));
Static int Tprintone __P((TREE *, void *));
#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 ***
*************************************************************/
void
Tfree (t)
register TREE **t;
{
@ -163,7 +182,7 @@ register TREE *tp,*th;
return(th);
}
Static
Static void
Tbalance (t)
TREE **t;
{
@ -290,8 +309,8 @@ Static
int Tsubprocess (t,reverse,f,argp)
TREE *t;
int reverse;
int (*f)();
int *argp;
int (*f) __P((TREE *, void *));
void *argp;
{
register int x = SCMOK;
process_level++;
@ -313,42 +332,44 @@ int *argp;
/* VARARGS2 */
int Trprocess (t,f,args)
TREE *t;
int (*f)();
int args;
int (*f) __P((TREE *, void *));
void *args;
{
if (t == NULL) return (SCMOK);
process_level = 0;
return (Tsubprocess (t,TRUE,f,&args));
return (Tsubprocess (t,TRUE,f,args));
}
/* VARARGS2 */
int Tprocess (t,f,args)
TREE *t;
int (*f)();
int args;
int (*f) __P((TREE *, void *));
void *args;
{
if (t == NULL) return (SCMOK);
process_level = 0;
return (Tsubprocess (t,FALSE,f,&args));
return (Tsubprocess (t,FALSE,f,args));
}
Static
int Tprintone (t)
int Tprintone (t, v)
TREE *t;
void *v;
{
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);
printf ("Node at %p name '%s' flags %o hi %p lo %p\n",t,t->Tname,t->Tflags,t->Thi,t->Tlo);
return (SCMOK);
}
void
Tprint (t,p) /* print tree -- for debugging */
TREE *t;
char *p;
{
printf ("%s\n",p);
(void) Tprocess (t,Tprintone);
(void) Tprocess (t,Tprintone, NULL);
printf ("End of tree\n");
(void) fflush (stdout);
}

View File

@ -39,6 +39,12 @@
* across the network to save BandWidth
*
* $Log: sup.h,v $
* Revision 1.4 1996/12/23 19:42:15 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.3 1995/06/03 21:21:54 christos
* Changes to write ascii timestamps in the when files.
* Looked into making it 64 bit clean, but it is hopeless.
@ -258,8 +264,8 @@ typedef struct tliststruct TREELIST;
#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();
long getwhen();
int putwhen();
#ifdef __STDC__
# include <stdarg.h>
#else
# include <varargs.h>
#endif

View File

@ -33,6 +33,12 @@
* across the network to save BandWidth
*
* $Log: supcdefs.h,v $
* Revision 1.4 1996/12/23 19:42:16 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.3 1996/09/05 16:50:07 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -84,6 +90,8 @@
#include <pwd.h>
#include <grp.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
@ -98,10 +106,6 @@
#include "supmsg.h"
extern int errno;
extern uid_t getuid();
extern gid_t getgid();
extern long time();
extern int PGMVERSION;
/*******************************************

View File

@ -174,6 +174,12 @@
* across the network to save BandWidth
*
* $Log: supcmain.c,v $
* Revision 1.6 1996/12/23 19:42:17 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.5 1996/09/05 16:50:08 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -345,6 +351,7 @@
#define SYS_rpause (-5)
#endif
#endif
#include "supextern.h"
/*********************************************
*** G L O B A L V A R I A B L E S ***
@ -367,17 +374,22 @@ int rpauseflag; /* don't disable resource pausing */
int xpatchflag; /* crosspatched with remote system */
int portdebug; /* network debugging ports */
int main __P((int, char **));
static int checkcoll __P((TREE *, void *));
static void doswitch __P((char *, TREE **, int *, int *));
static char *init __P((int, char **));
/*************************************
*** M A I N R O U T I N E ***
*************************************/
main (argc,argv)
int
main (argc, argv)
int argc;
char **argv;
{
char *init ();
char *progname,*supfname;
int restart,sfdev,sfino,sfmtime;
int restart,sfdev = 0,sfino = 0, sfmtime = 0;
struct stat sbuf;
struct sigaction ign;
@ -391,8 +403,9 @@ char **argv;
supfname = init (argc,argv);
restart = -1; /* don't make restart checks */
if (*progname == '/' && *supfname == '/') {
if (stat (supfname,&sbuf) < 0)
if (stat (supfname,&sbuf) < 0) {
logerr ("Can't stat supfile %s",supfname);
}
else {
sfdev = sbuf.st_dev;
sfino = sbuf.st_ino;
@ -437,7 +450,7 @@ char **argv;
logquit (1,"Restart failed");
}
}
while (thisC = firstC) {
while ((thisC = firstC) != NULL) {
firstC = firstC->Cnext;
free (thisC->Cname);
Tfree (&thisC->Chtree);
@ -466,7 +479,7 @@ char **argv;
#define Twant Tuid
#define Tcount Tgid
void doswitch (argp,collTp,oflagsp,aflagsp)
static void doswitch (argp,collTp,oflagsp,aflagsp)
char *argp;
register TREE **collTp;
int *oflagsp,*aflagsp;
@ -589,7 +602,7 @@ int *oflagsp,*aflagsp;
}
}
char *init (argc,argv)
static char *init (argc,argv)
int argc;
char **argv;
{
@ -603,7 +616,6 @@ char **argv;
register TREE *t;
TREE *collT; /* collections we are interested in */
long timenow; /* startup time */
int checkcoll ();
int oflags,aflags;
int cwant;
#ifdef MACH
@ -613,7 +625,6 @@ char **argv;
int (*oldsigsys)();
#endif
#endif /* MACH */
char *fmttime();
sysflag = FALSE; /* not system upgrade */
timeflag = FALSE; /* don't print times */
@ -672,7 +683,7 @@ char **argv;
firstC = NULL;
lastC = NULL;
bogus = FALSE;
while (p = fgets (buf,STRINGLENGTH,f)) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = index (p,'\n');
if (q) *q = '\0';
if (index ("#;:",*p)) continue;
@ -698,7 +709,7 @@ char **argv;
}
c->Cflags |= oflags;
c->Cflags &= ~aflags;
if (t = Tsearch (collT,c->Cname)) {
if ((t = Tsearch (collT,c->Cname)) != NULL) {
c->Cflags |= t->Toflags;
c->Cflags &= ~t->Taflags;
}
@ -715,7 +726,7 @@ char **argv;
}
if (bogus) logquit (1,"Aborted due to supfile errors");
if (f != stdin) (void) fclose (f);
if (cwant) (void) Tprocess (collT,checkcoll);
if (cwant) (void) Tprocess (collT,checkcoll, NULL);
Tfree (&collT);
if (firstC == NULL) logquit (1,"No collections to upgrade");
timenow = time ((long *)NULL);
@ -731,8 +742,10 @@ char **argv;
return (salloc (supfname));
}
checkcoll (t)
static int
checkcoll (t, dummy)
register TREE *t;
void *dummy;
{
if (!t->Twant) return (SCMOK);
if (t->Tcount == 0)

View File

@ -32,6 +32,12 @@
* across the network to save BandWidth
*
* $Log: supcmeat.c,v $
* Revision 1.8 1996/12/23 19:42:18 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.7 1996/09/05 16:50:09 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -154,12 +160,8 @@
*/
#include "supcdefs.h"
#include "supextern.h"
#include <sys/wait.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
TREE *lastT; /* last filenames in collection */
jmp_buf sjbuf; /* jump location for network errors */
@ -171,22 +173,27 @@ extern COLLECTION *thisC; /* collection list pointer */
extern int rpauseflag; /* don't disable resource pausing */
extern int portdebug; /* network debugging ports */
#if __STDC__
int done(int,char *,...);
int goaway(char *,...);
#endif
/*************************************************
*** U P G R A D E C O L L E C T I O N ***
*************************************************/
static int needone __P((TREE *, void *));
static int recvone __P((TREE *, void *));
static int denyone __P((TREE *, void *));
static int deleteone __P((TREE *, void *));
static int linkone __P((TREE *, void *));
static int execone __P((TREE *, void *));
static int finishone __P((TREE *, void *));
/* The next two routines define the fsm to support multiple fileservers
* per collection.
*/
getonehost (t,state)
int getonehost (t,v)
register TREE *t;
int *state;
void *v;
{
long *state = v;
if (t->Tflags != *state)
return (SCMOK);
if (*state != 0 && t->Tmode == SCMEOF) {
@ -202,9 +209,10 @@ int *state;
}
TREE *getcollhost (tout,backoff,state,nhostsp)
int *tout,*backoff,*state,*nhostsp;
int *tout,*backoff,*nhostsp;
long *state;
{
static int laststate = 0;
static long laststate = 0;
static int nhosts = 0;
if (*state != laststate) {
@ -212,7 +220,7 @@ int *tout,*backoff,*state,*nhostsp;
laststate = *state;
nhosts = 0;
}
if (Tprocess (thisC->Chtree,getonehost,*state) == SCMEOF) {
if (Tprocess (thisC->Chtree, getonehost, state) == SCMEOF) {
if (*state != 0 && nhosts == 0 && !dobackoff (tout,backoff))
return (NULL);
nhosts++;
@ -231,11 +239,12 @@ int *tout,*backoff,*state,*nhostsp;
* host machine.
*/
getcoll ()
void getcoll (void)
{
register TREE *t;
register int x;
int tout,backoff,state,nhosts;
int tout,backoff,nhosts;
long state;
collname = thisC->Cname;
tout = thisC->Ctimeout;
@ -336,11 +345,11 @@ int *tout;
/*** Tell file server what to connect to ***/
setup (t)
int setup (t)
register TREE *t;
{
char relsufix[STRINGLENGTH];
register int f,x;
register int x;
struct stat sbuf;
if (chdir (thisC->Cbase) < 0)
@ -421,11 +430,12 @@ register TREE *t;
goaway ("Unrecognized file server setup status %d",setupack);
}
/* NOTREACHED */
return FALSE;
}
/*** Tell file server what account to use ***/
int login ()
void login (void)
{
char buf[STRINGLENGTH];
register int f,x;
@ -509,9 +519,8 @@ int login ()
* which are no longer on the repository.
*/
int listfiles ()
void listfiles ()
{
int needone(), denyone(), deleteone();
char buf[STRINGLENGTH];
char relsufix[STRINGLENGTH];
register char *p,*q;
@ -526,8 +535,8 @@ int listfiles ()
(void) sprintf (buf,FILELAST,collname,relsufix);
f = fopen (buf,"r");
if (f) {
while (p = fgets (buf,STRINGLENGTH,f)) {
if (q = index (p,'\n')) *q = '\0';
while ((p = fgets (buf,STRINGLENGTH,f))) {
if ((q = index (p,'\n'))) *q = '\0';
if (index ("#;:",*p)) continue;
(void) Tinsert (&lastT,p,FALSE);
}
@ -537,8 +546,8 @@ int listfiles ()
(void) sprintf (buf,FILEREFUSE,collname);
f = fopen (buf,"r");
if (f) {
while (p = fgets (buf,STRINGLENGTH,f)) {
if (q = index (p,'\n')) *q = '\0';
while ((p = fgets (buf,STRINGLENGTH,f))) {
if ((q = index (p,'\n'))) *q = '\0';
if (index ("#;:",*p)) continue;
(void) Tinsert (&refuseT,p,FALSE);
}
@ -554,7 +563,7 @@ int listfiles ()
goaway ("Error reading file list from file server");
if (thisC->Cprefix) (void) chdir (thisC->Cprefix);
needT = NULL;
(void) Tprocess (listT,needone);
(void) Tprocess (listT,needone, NULL);
Tfree (&listT);
x = msgneed ();
if (x != SCMOK)
@ -565,15 +574,16 @@ int listfiles ()
if (x != SCMOK)
goaway ("Error reading denied files list from file server");
if (thisC->Cflags&CFVERBOSE)
(void) Tprocess (denyT,denyone);
(void) Tprocess (denyT,denyone, NULL);
Tfree (&denyT);
if (thisC->Cflags&(CFALL|CFDELETE|CFOLD))
(void) Trprocess (lastT,deleteone);
(void) Trprocess (lastT,deleteone, NULL);
Tfree (&refuseT);
}
needone (t)
static int needone (t, dummy)
register TREE *t;
void *dummy;
{
register TREE *newt;
register int exists, fetch;
@ -620,15 +630,17 @@ register TREE *t;
return (SCMOK);
}
denyone (t)
static int denyone (t, v)
register TREE *t;
void *v;
{
vnotify ("SUP: Access denied to %s\n",t->Tname);
return (SCMOK);
}
deleteone (t)
static int deleteone (t, v)
TREE *t;
void *v;
{
struct stat sbuf;
register int x;
@ -724,10 +736,9 @@ TREE *t;
* badly and best just stop the program as soon as possible.
*/
recvfiles ()
void recvfiles (void)
{
register int x;
int recvone ();
int recvmore;
/* Does the protocol support compression */
@ -755,7 +766,7 @@ recvfiles ()
}
/* prepare the target, if necessary */
prepare (name,mode,newp,statp)
int prepare (name,mode,newp,statp)
char *name;
int mode,*newp;
struct stat *statp;
@ -807,14 +818,14 @@ struct stat *statp;
return (TRUE);
}
recvone (t,ap)
static int recvone (t,v)
register TREE *t;
va_list ap;
void *v;
{
register int x;
va_list ap = v;
int x = 0;
int new;
struct stat sbuf;
int linkone (),execone ();
int *recvmore = va_arg(ap,int *);
/* check for end of file list */
@ -859,7 +870,7 @@ va_list ap;
}
if ((t->Tmode&S_IFMT) == S_IFREG)
(void) Tprocess (t->Tlink,linkone,t->Tname);
(void) Tprocess (t->Texec,execone);
(void) Tprocess (t->Texec,execone, NULL);
return (SCMOK);
}
@ -1040,21 +1051,22 @@ register struct stat *statp;
return (FALSE);
}
linkone (t,fname) /* link to file already received */
static int linkone (t,fv) /* link to file already received */
register TREE *t;
register char **fname;
void *fv;
{
register char *fname = fv;
struct stat fbuf,sbuf;
register char *name = t->Tname;
int new,x;
char *type;
if (stat(*fname,&fbuf) < 0) { /* source file */
if (stat(fname,&fbuf) < 0) { /* source file */
if (thisC->Cflags&CFLIST) {
vnotify ("SUP Would link %s to %s\n",name,*fname);
vnotify ("SUP Would link %s to %s\n",name,fname);
return (SCMOK);
}
notify ("SUP: Can't link %s to missing file %s\n",name,*fname);
notify ("SUP: Can't link %s to missing file %s\n",name,fname);
thisC->Cnogood = TRUE;
return (SCMOK);
}
@ -1067,25 +1079,26 @@ register char **fname;
fbuf.st_dev == sbuf.st_dev && fbuf.st_ino == sbuf.st_ino)
return (SCMOK);
if (thisC->Cflags&CFLIST) {
vnotify ("SUP Would link %s to %s\n",name,*fname);
vnotify ("SUP Would link %s to %s\n",name,fname);
return (SCMOK);
}
(void) unlink (name);
type = "";
if ((x = link (*fname,name)) < 0) {
if ((x = link (fname,name)) < 0) {
type = "symbolic ";
x = symlink (*fname,name);
x = symlink (fname,name);
}
if (x < 0 || lstat(name,&sbuf) < 0) {
notify ("SUP: Unable to create %slink %s\n",type,name);
return (TRUE);
}
vnotify ("SUP Created %slink %s to %s\n",type,name,*fname);
vnotify ("SUP Created %slink %s to %s\n",type,name,fname);
return (SCMOK);
}
execone (t) /* execute command for file */
static int execone (t, v) /* execute command for file */
register TREE *t;
void *v;
{
int w;
@ -1123,7 +1136,7 @@ char *from; /* 0 if reading from network */
register int fromf,tof,istemp,x;
char dpart[STRINGLENGTH],fpart[STRINGLENGTH];
char tname[STRINGLENGTH];
struct stat sbuf;
static int true = 1;
static int thispid = 0; /* process id # */
@ -1189,7 +1202,8 @@ char *from; /* 0 if reading from network */
if (x != SCMOK)
goaway ("Can't skip file transfer");
}
return (TRUE);
if (true)
return (TRUE);
}
if (fromf >= 0) { /* read file */
x = filecopy (fromf,tof);
@ -1314,7 +1328,7 @@ char *from; /* 0 if reading from network */
/*** Finish connection with file server ***/
finishup (x)
void finishup (x)
int x;
{
char tname[STRINGLENGTH],fname[STRINGLENGTH];
@ -1322,7 +1336,6 @@ int x;
char collrelname[STRINGLENGTH];
long tloc;
FILE *finishfile; /* record of all filenames */
int f,finishone();
if ((thisC->Cflags&CFURELSUF) && release) {
(void) sprintf (relsufix,".%s",release);
@ -1411,16 +1424,18 @@ int x;
Tfree (&lastT);
}
finishone (t,finishfile)
int finishone (t,fv)
TREE *t;
FILE **finishfile;
void *fv;
{
FILE *finishfile = fv;
if ((thisC->Cflags&CFDELETE) == 0 || (t->Tflags&FUPDATE))
fprintf (*finishfile,"%s\n",t->Tname);
fprintf (finishfile,"%s\n",t->Tname);
return (SCMOK);
}
#if __STDC__
void
#ifdef __STDC__
done (int value,char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -1428,21 +1443,21 @@ done (va_alist)
va_dcl
#endif
{
#if !__STDC__
int value;
char *fmt;
#endif
char buf[STRINGLENGTH];
va_list ap;
(void) netcrypt ((char *)NULL);
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
int value;
char *fmt;
va_start(ap);
value = va_arg(ap,int);
fmt = va_arg(ap,char *);
#endif
(void) netcrypt ((char *)NULL);
if (fmt)
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
@ -1460,7 +1475,9 @@ va_dcl
if (!dontjump)
longjmp (sjbuf,TRUE);
}
#if __STDC__
void
#ifdef __STDC__
goaway (char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -1468,19 +1485,19 @@ goaway (va_alist)
va_dcl
#endif
{
#if !__STDC__
register char *fmt;
#endif
char buf[STRINGLENGTH];
va_list ap;
(void) netcrypt ((char *)NULL);
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
register char *fmt;
va_start(ap);
fmt = va_arg(ap,char *);
#endif
(void) netcrypt ((char *)NULL);
if (fmt) {
vsnprintf(buf, sizeof(buf), fmt, ap);
goawayreason = buf;

View File

@ -27,6 +27,12 @@
**********************************************************************
* HISTORY
* $Log: supcmisc.c,v $
* Revision 1.4 1996/12/23 19:42:19 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.3 1996/09/05 16:50:10 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -73,12 +79,8 @@
**********************************************************************
*/
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "supcdefs.h"
#include "supextern.h"
struct liststruct { /* uid and gid lists */
char *Lname; /* name */
@ -96,20 +98,21 @@ static LIST *uidL[LISTSIZE]; /* uid and gid lists */
static LIST *gidL[LISTSIZE];
extern COLLECTION *thisC; /* collection list pointer */
#if __STDC__
int notify (char *, ...);
#endif
static int Lhash __P((char *));
static void Linsert __P((LIST **, char *, int));
static LIST *Llookup __P((LIST **, char *));
/*************************************************
*** P R I N T U P D A T E T I M E S ***
*************************************************/
void
prtime ()
{
char buf[STRINGLENGTH];
char relsufix[STRINGLENGTH];
long twhen;
int f;
if ((thisC->Cflags&CFURELSUF) && thisC->Crelease)
(void) sprintf (relsufix,".%s",thisC->Crelease);
@ -179,7 +182,7 @@ char *name;
return (((len&HASHMASK)<<HASHBITS)|(((int)c)&HASHMASK));
}
static
static void
Linsert (table,name,number)
LIST **table;
char *name;
@ -207,7 +210,7 @@ char *name;
return (l);
}
ugconvert (uname,gname,uid,gid,mode)
void ugconvert (uname,gname,uid,gid,mode)
char *uname,*gname;
int *uid,*gid,*mode;
{
@ -225,18 +228,18 @@ int *uid,*gid,*mode;
first = FALSE;
}
pw = NULL;
if (u = Llookup (uidL,uname))
if ((u = Llookup (uidL,uname)) != NULL)
*uid = u->Lnumber;
else if (pw = getpwnam (uname)) {
else if ((pw = getpwnam (uname)) != NULL) {
Linsert (uidL,salloc(uname),pw->pw_uid);
*uid = pw->pw_uid;
}
if (u || pw) {
if (g = Llookup (gidL,gname)) {
if ((g = Llookup (gidL,gname)) != NULL) {
*gid = g->Lnumber;
return;
}
if (gr = getgrnam (gname)) {
if ((gr = getgrnam (gname)) != NULL) {
Linsert (gidL,salloc(gname),gr->gr_gid);
*gid = gr->gr_gid;
return;
@ -267,7 +270,8 @@ int *uid,*gid,*mode;
*** U T I L I T Y R O U T I N E S ***
*********************************************/
#if __STDC__
void
#ifdef __STDC__
notify (char *fmt,...) /* record error message */
#else
/*VARARGS*//*ARGSUSED*/
@ -275,18 +279,17 @@ notify (va_alist) /* record error message */
va_dcl
#endif
{
#if !__STDC__
char *fmt;
#endif
char buf[STRINGLENGTH];
char collrelname[STRINGLENGTH];
long tloc;
static FILE *noteF = NULL; /* mail program on pipe */
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
char *fmt;
va_start(ap);
fmt = va_arg(ap,char *);
#endif
@ -323,6 +326,7 @@ va_dcl
(void) fflush (noteF);
}
void
lockout (on) /* lock out interrupts */
int on;
{

View File

@ -27,6 +27,12 @@
**********************************************************************
* HISTORY
* $Log: supcname.c,v $
* Revision 1.3 1996/12/23 19:42:19 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.2 1995/09/16 19:12:14 glass
* if the function returns nothing, declare it void
*
@ -57,6 +63,7 @@
*/
#include "supcdefs.h"
#include "supextern.h"
extern COLLECTION *firstC; /* collection list pointer */
@ -83,7 +90,8 @@ void getnams ()
f = fopen (buf,"r");
if (f == NULL) logquit (1,"Can't open %s",buf);
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
if (q = index (p,'\n')) *q = '\0';
if ((q = index (p,'\n')) != NULL)
*q = '\0';
if (index ("#;:",*p)) continue;
q = nxtarg (&p,"= \t");
p = skipover (p," \t");

View File

@ -32,6 +32,12 @@
* across the network to save BandWidth
*
* $Log: supcparse.c,v $
* Revision 1.5 1996/12/23 19:42:20 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.4 1995/06/09 04:33:34 christos
* fixed bug related to the ascii `when' files previous fix, where the -t
* option would fail to read the timestamp files.
@ -69,6 +75,7 @@
*/
#include "supcdefs.h"
#include "supextern.h"
#ifdef lint
@ -88,26 +95,28 @@ struct option {
char *op_name;
OPTION op_enum;
} options[] = {
"host", OHOST,
"base", OBASE,
"hostbase", OHOSTBASE,
"prefix", OPREFIX,
"release", ORELEASE,
"notify", ONOTIFY,
"login", OLOGIN,
"password", OPASSWORD,
"crypt", OCRYPT,
"backup", OBACKUP,
"delete", ODELETE,
"execute", OEXECUTE,
"old", OOLD,
"timeout", OTIMEOUT,
"keep", OKEEP,
"use-rel-suffix", OURELSUF,
"compress", OCOMPRESS
{ "host", OHOST },
{ "base", OBASE },
{ "hostbase", OHOSTBASE },
{ "prefix", OPREFIX },
{ "release", ORELEASE },
{ "notify", ONOTIFY },
{ "login", OLOGIN },
{ "password", OPASSWORD },
{ "crypt", OCRYPT },
{ "backup", OBACKUP },
{ "delete", ODELETE },
{ "execute", OEXECUTE },
{ "old", OOLD },
{ "timeout", OTIMEOUT },
{ "keep", OKEEP },
{ "use-rel-suffix", OURELSUF },
{ "compress", OCOMPRESS }
};
passdelim (ptr,delim) /* skip over delimiter */
static void passdelim __P((char **, int ));
static void passdelim (ptr,delim) /* skip over delimiter */
char **ptr,delim;
{
*ptr = skipover (*ptr, " \t");
@ -117,7 +126,7 @@ char **ptr,delim;
}
}
parsecoll(c,collname,args)
int parsecoll(c,collname,args)
COLLECTION *c;
char *collname,*args;
{

View File

@ -0,0 +1,177 @@
#ifndef __P
#ifdef __STDC__
#define __P(a) a
#else
#define __P(a) ()
#endif
#endif
/* atoo.c */
unsigned int atoo __P((char *));
#if 0
/* ci.c */
int ci __P((char *, FILE *, int, CIENTRY *, char *, char *));
#endif
/* errmsg.c */
char *errmsg __P((int));
/* expand.c */
int expand __P((char *, char **, int));
/* ffilecopy.c */
int ffilecopy __P((FILE *, FILE *));
/* filecopy.c */
int filecopy __P((int, int ));
/* log.c */
void logopen __P((char *));
void logquit __P((int, char *, ...));
void logerr __P((char *, ...));
void loginfo __P((char *, ...));
/* netcryptvoid.c */
int netcrypt __P((char *));
int getcryptbuf __P((int));
void decode __P((char *, char *, int));
void encode __P((char *, char *, int));
/* nxtarg.c */
char *nxtarg __P((char **, char *));
/* path.c */
void path __P((char *, char *, char *));
/* quit.c */
void quit __P((int, char *, ...));
/* run.c */
int run __P((char *, ...));
int runv __P((char *, char **));
int runp __P((char *, ...));
int runvp __P((char *, char **));
int runio __P((char *const[], const char *, const char *, const char *));
/* salloc.c */
char *salloc __P((char *));
/* scan.c */
int getrelease __P((char *));
void makescanlists __P((void));
void getscanlists __P((void));
void cdprefix __P((char *));
/* scm.c */
int servicesetup __P((char *));
int service __P((void));
int serviceprep __P((void));
int servicekill __P((void));
int serviceend __P((void));
int dobackoff __P((int *, int *));
int request __P((char *, char *, int *));
int requestend __P((void));
char *remotehost __P((void));
int thishost __P((char *));
int samehost __P((void));
int matchhost __P((char *));
int scmerr __P((int, char *, ...));
int byteswap __P((int));
/* scmio.c */
int writemsg __P((int));
int writemend __P((void));
int writeint __P((int));
int writestring __P((char *));
int writefile __P((int));
int writemnull __P((int));
int writemint __P((int, int ));
int writemstr __P((int, char *));
int prereadcount __P((int *));
int readflush __P((void));
int readmsg __P((int));
int readmend __P((void));
int readskip __P((void));
int readint __P((int *));
int readstring __P((char **));
int readfile __P((int));
int readmnull __P((int));
int readmint __P((int, int *));
int readmstr __P((int, char **));
void crosspatch __P((void));
/* skipto.c */
char *skipto __P((char *, char *));
char *skipover __P((char *, char *));
/* stree.c */
void Tfree __P((TREE **));
TREE *Tinsert __P((TREE **, char *, int));
TREE *Tsearch __P((TREE *, char *));
TREE *Tlookup __P((TREE *, char *));
int Trprocess __P((TREE *, int (*)(TREE *, void *), void *));
int Tprocess __P((TREE *, int (*)(TREE *, void *), void *));
void Tprint __P((TREE *, char *));
/* supcmeat.c */
int getonehost __P((TREE *, void *));
TREE *getcollhost __P((int *, int *, long *, int *));
void getcoll __P((void));
int signon __P((TREE *, int, int *));
int setup __P((TREE *));
void login __P((void));
void listfiles __P((void));
void recvfiles __P((void));
int prepare __P((char *, int, int *, struct stat *));
int recvdir __P((TREE *, int, struct stat *));
int recvsym __P((TREE *, int, struct stat *));
int recvreg __P((TREE *, int, struct stat *));
int copyfile __P((char *, char *));
void finishup __P((int));
void done __P((int, char *, ...));
void goaway __P((char *, ...));
/* supcmisc.c */
void prtime __P((void));
int establishdir __P((char *));
int estabd __P((char *, char *));
void ugconvert __P((char *, char *, int *, int *, int *));
void notify __P((char *, ...));
void lockout __P((int));
char *fmttime __P((long));
/* supcname.c */
void getnams __P((void));
/* supcparse.c */
int parsecoll __P((COLLECTION *, char *, char *));
long getwhen __P((char *, char *));
int putwhen __P((char *, long));
/* supmsg.c */
int msgsignon __P((void));
int msgsignonack __P((void));
int msgsetup __P((void));
int msgsetupack __P((void));
int msgcrypt __P((void));
int msgcryptok __P((void));
int msglogin __P((void));
int msglogack __P((void));
int msgrefuse __P((void));
int msglist __P((void));
int msgneed __P((void));
int msgdeny __P((void));
int msgsend __P((void));
int msgrecv __P((int (*)(TREE *, void *), ...));
int msgdone __P((void));
int msggoaway __P((void));
int msgxpatch __P((void));
int msgcompress __P((void));
/* vprintf.c */
int vprintf __P((const char *, va_list));
int vfprintf __P((FILE *, const char *, va_list));
int vsprintf __P((char *, const char *, va_list));
int vsnprintf __P((char *, size_t, const char *, va_list));

View File

@ -22,6 +22,7 @@
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*
*/
/*
* supfilesrv -- SUP File Server
*
@ -43,6 +44,12 @@
* across the network to save BandWidth
*
* $Log: supfilesrv.c,v $
* Revision 1.10 1996/12/23 19:42:22 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.9 1996/09/05 16:50:12 christos
* - for portability make sure that we never use "" as a pathname, always convert
* it to "."
@ -290,19 +297,12 @@
# include <sys/statvfs.h>
#endif
#include "sup.h"
#include "supcdefs.h"
#include "supextern.h"
#define MSGFILE
#include "supmsg.h"
#ifdef lint
/*VARARGS1*//*ARGSUSED*/
static void quit(status) {};
#endif /* lint */
extern int errno;
long time ();
uid_t getuid ();
int maxchildren;
/*
@ -377,15 +377,43 @@ HASH *uidH[HASHSIZE]; /* for uid and gid lookup */
HASH *gidH[HASHSIZE];
HASH *inodeH[HASHSIZE]; /* for inode lookup for linked file check */
char *fmttime (); /* time format routine */
#if __STDC__
int goaway(char *fmt,...);
#endif
/* supfilesrv.c */
int main __P((int, char **));
void chldsig __P((int));
void usage __P((void));
void init __P((int, char **));
void answer __P((void));
void srvsignon __P((void));
void srvsetup __P((void));
void docrypt __P((void));
void srvlogin __P((void));
void listfiles __P((void));
int denyone __P((TREE *, void *));
void sendfiles __P((void));
int sendone __P((TREE *, void *));
int senddir __P((TREE *, void *));
int sendfile __P((TREE *, void *));
void srvfinishup __P((long));
void Hfree __P((HASH **));
HASH *Hlookup __P((HASH **, int, int ));
void Hinsert __P((HASH **, int, int , char *, TREE *));
TREE *linkcheck __P((TREE *, int, int ));
char *uconvert __P((int));
char *gconvert __P((int));
char *changeuid __P((char *, char *, int, int ));
void goaway __P((char *, ...));
char *fmttime __P((long));
int local_file __P((int, struct stat *));
int stat_info_ok __P((struct stat *, struct stat *));
int link_nofollow __P((int));
int link_nofollow __P((int));
/*************************************
*** M A I N R O U T I N E ***
*************************************/
int
main (argc,argv)
int argc;
char **argv;
@ -393,7 +421,6 @@ char **argv;
register int x,pid;
sigset_t nset, oset;
struct sigaction chld,ign;
void chldsig ();
long tloc;
/* initialize global variables */
@ -473,11 +500,13 @@ chldsig(snum)
*** I N I T I A L I Z A T I O N ***
*****************************************/
void
usage ()
{
quit (1,"Usage: supfilesrv [ -l | -P | -N | -C <max children> | -H <host> <user> <cryptfile> <supargs> ]\n");
}
void
init (argc,argv)
int argc;
char **argv;
@ -560,8 +589,8 @@ char **argv;
f = fopen (cryptkey,"r");
if (f == NULL)
quit (1,"Unable to open cryptfile %s\n",cryptkey);
if (p = fgets (buf,STRINGLENGTH,f)) {
if (q = index (p,'\n')) *q = '\0';
if ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
if ((q = index (p,'\n')) != NULL) *q = '\0';
if (*p == '\0')
quit (1,"No cryptkey found in %s\n",cryptkey);
cryptkey = salloc (buf);
@ -638,6 +667,7 @@ char **argv;
*** A N S W E R R E Q U E S T ***
*****************************************/
void
answer ()
{
long starttime;
@ -657,10 +687,10 @@ answer ()
lockfd = -1;
starttime = time ((long *)NULL);
if (!setjmp (sjbuf)) {
signon ();
setup ();
srvsignon ();
srvsetup ();
docrypt ();
login ();
srvlogin ();
if (xpatch) {
int fd;
@ -682,7 +712,7 @@ answer ()
listfiles ();
sendfiles ();
}
finishup (starttime);
srvfinishup (starttime);
if (collname) free (collname);
if (basedir) free (basedir);
if (prefix) free (prefix);
@ -712,7 +742,8 @@ answer ()
*** S I G N O N C L I E N T ***
*****************************************/
signon ()
void
srvsignon ()
{
register int x;
@ -729,7 +760,8 @@ signon ()
*** E X C H A N G E S E T U P I N F O R M A T I O N ***
*****************************************************************/
setup ()
void
srvsetup ()
{
register int x;
char *p,*q;
@ -751,7 +783,6 @@ setup ()
}
if (xpatch) {
register struct passwd *pw;
extern int link_nofollow(), local_file();
if ((pw = getpwnam (xuser)) == NULL) {
setupack = FSETUPSAME;
@ -776,7 +807,7 @@ setup ()
if ((f = fopen (buf,"r")) != NULL) {
struct stat fsbuf;
while (p = fgets (buf,STRINGLENGTH,f)) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
if (index ("#;:",*p)) continue;
@ -829,7 +860,7 @@ setup ()
(void) sprintf (buf,FILEDIRS,DEFDIR);
f = fopen (buf,"r");
if (f) {
while (p = fgets (buf,STRINGLENGTH,f)) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
if (index ("#;:",*p)) continue;
@ -852,7 +883,7 @@ setup ()
(void) sprintf (buf,FILEPREFIX,collname);
f = fopen (buf,"r");
if (f) {
while (p = fgets (buf,STRINGLENGTH,f)) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
if (index ("#;:",*p)) continue;
@ -897,7 +928,7 @@ setup ()
f = fopen (buf,"r");
if (f) {
int hostok = FALSE;
while (p = fgets (buf,STRINGLENGTH,f)) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
int not;
q = index (p,'\n');
if (q) *q = 0;
@ -944,6 +975,7 @@ setup ()
if (x != SCMOK) goaway ("Error sending setup reply to client");
}
void
/** Test data encryption **/
docrypt ()
{
@ -952,7 +984,6 @@ docrypt ()
char buf[STRINGLENGTH];
register FILE *f;
struct stat sbuf;
extern int link_nofollow(), local_file();
if (!xpatch) {
(void) sprintf (buf,FILECRYPT,collname);
@ -968,7 +999,8 @@ docrypt ()
if (cryptkey == NULL &&
(p = fgets (buf,STRINGLENGTH,f))) {
if (q = index (p,'\n')) *q = '\0';
if ((q = index (p,'\n')) != NULL)
*q = '\0';
if (*p) cryptkey = salloc (buf);
}
if (local_file(fileno(f), &fsbuf) > 0
@ -1002,10 +1034,10 @@ docrypt ()
*** C O N N E C T T O P R O P E R A C C O U N T ***
***************************************************************/
login ()
void
srvlogin ()
{
char *changeuid ();
register int x,fileuid,filegid;
register int x,fileuid = -1,filegid = -1;
(void) netcrypt (PSWDCRYPT); /* encrypt acct name and password */
x = msglogin ();
@ -1054,9 +1086,9 @@ login ()
*** M A K E N A M E L I S T ***
*****************************************/
void
listfiles ()
{
int denyone();
register int x;
refuseT = NULL;
@ -1073,22 +1105,24 @@ listfiles ()
if (x != SCMOK)
goaway ("Error reading needed files list from client");
denyT = NULL;
(void) Tprocess (needT,denyone);
(void) Tprocess (needT,denyone, NULL);
Tfree (&needT);
x = msgdeny ();
if (x != SCMOK) goaway ("Error sending denied files list to client");
Tfree (&denyT);
}
denyone (t)
int
denyone (t, v)
register TREE *t;
void *v;
{
register TREELIST *tl;
register char *name = t->Tname;
register int update = (t->Tflags&FUPDATE) != 0;
struct stat sbuf;
register TREE *tlink;
TREE *linkcheck ();
char slinkname[STRINGLENGTH];
register int x;
@ -1141,9 +1175,9 @@ register TREE *t;
*** S E N D F I L E S ***
*********************************/
void
sendfiles ()
{
int sendone(),senddir(),sendfile();
register TREELIST *tl;
register int x;
@ -1168,12 +1202,12 @@ sendfiles ()
}
}
#endif
(void) Tprocess (tl->TLtree,sendone);
(void) Tprocess (tl->TLtree,sendone, NULL);
}
/* send directories in reverse order */
for (tl = listTL; tl != NULL; tl = tl->TLnext) {
cdprefix (tl->TLprefix);
(void) Trprocess (tl->TLtree,senddir);
(void) Trprocess (tl->TLtree,senddir, NULL);
}
x = msgsend ();
if (x != SCMOK)
@ -1184,16 +1218,13 @@ sendfiles ()
goaway ("Error sending file to client");
}
sendone (t)
int
sendone (t, v)
TREE *t;
void *v;
{
register int x,fd;
register int fdtmp;
char temp_file[STRINGLENGTH], rcs_file[STRINGLENGTH];
int status;
char *uconvert(),*gconvert();
int sendfile ();
int ac;
char temp_file[STRINGLENGTH];
char *av[50]; /* More than enough */
if ((t->Tflags&FNEEDED) == 0) /* only send needed files */
@ -1311,12 +1342,12 @@ TREE *t;
return (SCMOK);
}
senddir (t)
int
senddir (t, v)
TREE *t;
void *v;
{
register int x;
char *uconvert(),*gconvert();
int sendfile ();
if ((t->Tflags&FNEEDED) == 0) /* only send needed files */
return (SCMOK);
@ -1332,10 +1363,12 @@ TREE *t;
return (SCMOK);
}
sendfile (t,ap)
int
sendfile (t,v)
register TREE *t;
va_list ap;
void *v;
{
va_list ap = v;
register int x;
int fd = va_arg(ap,int);
if ((t->Tmode&S_IFMT) != S_IFREG || listonly || (t->Tflags&FUPDATE))
@ -1350,13 +1383,13 @@ va_list ap;
*** E N D C O N N E C T I O N ***
*****************************************/
finishup (starttime)
void
srvfinishup (starttime)
long starttime;
{
register int x = SCMOK;
char tmpbuf[BUFSIZ], *p, lognam[STRINGLENGTH];
int logfd;
struct stat sbuf;
long finishtime;
char *releasename;
@ -1424,13 +1457,14 @@ long starttime;
*** H A S H T A B L E R O U T I N E S ***
***************************************************/
void
Hfree (table)
HASH **table;
{
register HASH *h;
register int i;
for (i = 0; i < HASHSIZE; i++)
while (h = table[i]) {
while ((h = table[i]) != NULL) {
table[i] = h->Hnext;
if (h->Hname) free (h->Hname);
free ((char *)h);
@ -1448,6 +1482,7 @@ int num1,num2;
return (h);
}
void
Hinsert (table,num1,num2,name,tree)
HASH **table;
int num1,num2;
@ -1515,7 +1550,6 @@ char *changeuid (namep,passwordp,fileuid,filegid)
char *namep,*passwordp;
int fileuid,filegid;
{
char *okpassword ();
char *group,*account,*pswdp;
struct passwd *pwd;
struct group *grp;
@ -1529,7 +1563,7 @@ int fileuid,filegid;
#if CMUCS
int *grps;
#endif /* CMUCS */
char *p;
char *p = NULL;
if (namep == NULL) {
pwd = getpwuid (fileuid);
@ -1688,7 +1722,8 @@ int fileuid,filegid;
return (NULL);
}
#if __STDC__
void
#ifdef __STDC__
goaway (char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -1696,19 +1731,19 @@ goaway (va_alist)
va_dcl
#endif
{
#if !__STDC__
register char *fmt;
#endif
char buf[STRINGLENGTH];
va_list ap;
(void) netcrypt ((char *)NULL);
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
register char *fmt;
va_start(ap);
fmt = va_arg(ap,char *);
#endif
(void) netcrypt ((char *)NULL);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
goawayreason = salloc (buf);

View File

@ -31,6 +31,12 @@
* across the network to save BandWidth
*
* $Log: supmsg.c,v $
* Revision 1.3 1996/12/23 19:42:23 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.2 1993/08/04 17:46:23 brezak
* Changes from nate for gzip'ed sup
*
@ -58,14 +64,10 @@
#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"
#include "supcdefs.h"
#include "supextern.h"
#define MSGSUBR
#define MSGFILE
#include "supmsg.h"
@ -78,6 +80,12 @@ extern int pgmversion; /* my program version */
extern char *scmver; /* scm version of partner */
extern int fspid; /* process id of fileserver */
static int refuseone __P((TREE *, void *));
static int listone __P((TREE *, void *));
static int needone __P((TREE *, void *));
static int denyone __P((TREE *, void *));
static int writeone __P((TREE *, void *));
int msgsignon ()
{
register int x;
@ -266,8 +274,9 @@ int msglogack ()
*/
extern TREE *refuseT; /* tree of files to refuse */
static int refuseone (t)
static int refuseone (t, v)
register TREE *t;
void *v;
{
return (writestring (t->Tname));
}
@ -288,7 +297,7 @@ int msgrefuse ()
if (x == SCMOK) x = readmend ();
} else {
x = writemsg (MSGREFUSE);
if (x == SCMOK) x = Tprocess (refuseT,refuseone);
if (x == SCMOK) x = Tprocess (refuseT,refuseone, NULL);
if (x == SCMOK) x = writestring ((char *)NULL);
if (x == SCMOK) x = writemend ();
}
@ -301,8 +310,9 @@ int msgrefuse ()
extern TREE *listT; /* tree of files to list */
extern long scantime; /* time that collection was scanned */
static int listone (t)
static int listone (t, v)
register TREE *t;
void *v;
{
register int x;
@ -318,7 +328,7 @@ int msglist ()
register int x;
if (server) {
x = writemsg (MSGLIST);
if (x == SCMOK) x = Tprocess (listT,listone);
if (x == SCMOK) x = Tprocess (listT,listone, NULL);
if (x == SCMOK) x = writestring ((char *)NULL);
if (x == SCMOK) x = writeint ((int)scantime);
if (x == SCMOK) x = writemend ();
@ -352,8 +362,9 @@ int msglist ()
*/
extern TREE *needT; /* tree of files to need */
static int needone (t)
static int needone (t, v)
register TREE *t;
void *v;
{
register int x;
x = writestring (t->Tname);
@ -382,7 +393,7 @@ int msgneed ()
if (x == SCMOK) x = readmend ();
} else {
x = writemsg (MSGNEED);
if (x == SCMOK) x = Tprocess (needT,needone);
if (x == SCMOK) x = Tprocess (needT,needone, NULL);
if (x == SCMOK) x = writestring ((char *)NULL);
if (x == SCMOK) x = writemend ();
}
@ -394,8 +405,9 @@ int msgneed ()
*/
extern TREE *denyT; /* tree of files to deny */
static int denyone (t)
static int denyone (t, v)
register TREE *t;
void *v;
{
return (writestring (t->Tname));
}
@ -405,7 +417,7 @@ int msgdeny ()
register int x;
if (server) {
x = writemsg (MSGDENY);
if (x == SCMOK) x = Tprocess (denyT,denyone);
if (x == SCMOK) x = Tprocess (denyT,denyone, NULL);
if (x == SCMOK) x = writestring ((char *)NULL);
if (x == SCMOK) x = writemend ();
} else {
@ -438,33 +450,32 @@ int msgsend ()
*/
extern TREE *upgradeT; /* pointer to file being upgraded */
static int writeone (t)
static int writeone (t,v)
register TREE *t;
void *v;
{
return (writestring (t->Tname));
}
#if __STDC__
int msgrecv (PFI xferfile,...)
#ifdef __STDC__
int msgrecv (int (*xferfile)(TREE *, void *),...)
#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__
#ifdef __STDC__
va_start(args,xferfile);
#else
int (*xferfile)(TREE *, void *);
va_start(args);
xferfile = va_arg(args, PFI);
xferfile = va_arg(args, int (*)(TREE *, void *));
#endif
if (server) {
x = writemsg (MSGRECV);
@ -483,9 +494,9 @@ va_dcl
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 = Tprocess (t->Tlink,writeone, NULL);
if (x == SCMOK) x = writestring ((char *)NULL);
if (x == SCMOK) x = Tprocess (t->Texec,writeone);
if (x == SCMOK) x = Tprocess (t->Texec,writeone, NULL);
if (x == SCMOK) x = writestring ((char *)NULL);
if (x == SCMOK) x = (*xferfile) (t,args);
if (x == SCMOK) x = writemend ();

View File

@ -39,6 +39,12 @@
**********************************************************************
* HISTORY
* $Log: supscan.c,v $
* Revision 1.2 1996/12/23 19:42:23 christos
* - add missing prototypes.
* - fix function call inconsistencies
* - fix int <-> long and pointer conversions
* It should run now on 64 bit machines...
*
* Revision 1.1.1.1 1993/05/21 14:52:19 cgd
* initial import of CMU's SUP to NetBSD
*
@ -124,12 +130,8 @@
#endif
#include <sys/time.h>
#include <sys/types.h>
#include "sup.h"
#ifdef lint
/*VARARGS1*//*ARGSUSED*/
static void quit(status) {};
#endif /* lint */
#include "supcdefs.h"
#include "supextern.h"
#define PGMVERSION 6
@ -137,13 +139,13 @@ static void quit(status) {};
*** D A T A S T R U C T U R E S ***
*******************************************/
struct collstruct { /* one per collection to be upgraded */
struct scan_collstruct { /* one per collection to be upgraded */
char *Cname; /* collection name */
char *Cbase; /* local base directory */
char *Cprefix; /* local collection pathname prefix */
struct collstruct *Cnext; /* next collection */
struct scan_collstruct *Cnext; /* next collection */
};
typedef struct collstruct COLLECTION;
typedef struct scan_collstruct SCAN_COLLECTION;
/*********************************************
*** G L O B A L V A R I A B L E S ***
@ -151,7 +153,7 @@ typedef struct collstruct COLLECTION;
int trace; /* -v flag */
COLLECTION *firstC; /* collection list pointer */
SCAN_COLLECTION *firstC; /* collection list pointer */
char *collname; /* collection name */
char *basedir; /* base directory name */
char *prefix; /* collection pathname prefix */
@ -164,17 +166,27 @@ TREELIST *listTL; /* list of all files specified by <coll>.list */
TREE *listT; /* final list of files in collection */
TREE *refuseT = NULL; /* list of all files specified by <coll>.list */
long time ();
void usage __P((void));
void init __P((int, char **));
static SCAN_COLLECTION *getscancoll __P((char *, char *, char *));
int localhost __P((char *));
int main __P((int, char **));
/*************************************
*** M A I N R O U T I N E ***
*************************************/
int
main (argc,argv)
int argc;
char **argv;
{
register COLLECTION *c;
SCAN_COLLECTION *c;
#if __GNUC__
/* Avoid longjmp clobbering */
(void) &c;
#endif
init (argc,argv); /* process arguments */
for (c = firstC; c; c = c->Cnext) {
@ -196,7 +208,7 @@ char **argv;
ctime (&scantime));
(void) fflush (stdout);
}
while (c = firstC) {
while ((c = firstC) != NULL) {
firstC = firstC->Cnext;
free (c->Cname);
free (c->Cbase);
@ -210,6 +222,7 @@ char **argv;
*** I N I T I A L I Z A T I O N ***
*****************************************/
void
usage ()
{
fprintf (stderr,"Usage: supscan [ -v ] collection [ basedir ]\n");
@ -218,15 +231,16 @@ usage ()
exit (1);
}
void
init (argc,argv)
int argc;
char **argv;
{
char buf[STRINGLENGTH],fbuf[STRINGLENGTH],*p,*q;
FILE *f;
COLLECTION **c, *getcoll();
SCAN_COLLECTION **c;
int fflag,sflag;
char *filename;
char *filename = NULL;
trace = FALSE;
fflag = FALSE;
@ -273,7 +287,7 @@ char **argv;
collname = nxtarg (&p," \t=");
p = skipover (p," \t=");
if (!localhost (p)) continue;
*c = getcoll(filename,salloc (collname),
*c = getscancoll(filename,salloc (collname),
(char *)NULL);
if (*c) c = &((*c)->Cnext);
}
@ -285,13 +299,13 @@ char **argv;
c = &firstC;
if ((f = fopen (filename,"r")) == NULL)
quit (1,"supscan: Unable to open %s\n",filename);
while (p = fgets (buf,STRINGLENGTH,f)) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
if (index ("#;:",*p)) continue;
q = nxtarg (&p," \t=");
p = skipover (p," \t=");
*c = getcoll(filename,salloc (q),salloc (p));
*c = getscancoll(filename,salloc (q),salloc (p));
if (*c) c = &((*c)->Cnext);
}
(void) fclose (f);
@ -299,21 +313,21 @@ char **argv;
}
if (argc < 2 || argc > 3)
usage ();
firstC = getcoll(filename,salloc (argv[1]),
firstC = getscancoll(filename,salloc (argv[1]),
argc > 2 ? salloc (argv[2]) : (char *)NULL);
}
COLLECTION *
getcoll(filename, collname, basedir)
static SCAN_COLLECTION *
getscancoll(filename, collname, basedir)
register char *filename,*collname,*basedir;
{
char buf[STRINGLENGTH],*p,*q;
FILE *f;
COLLECTION *c;
SCAN_COLLECTION *c;
if (basedir == NULL) {
if (f = fopen (filename,"r")) {
while (p = fgets (buf,STRINGLENGTH,f)) {
if ((f = fopen (filename,"r")) != NULL) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
if (index ("#;:",*p)) continue;
@ -338,8 +352,8 @@ register char *filename,*collname,*basedir;
}
prefix = NULL;
(void) sprintf (buf,FILEPREFIX,collname);
if (f = fopen (buf,"r")) {
while (p = fgets (buf,STRINGLENGTH,f)) {
if ((f = fopen (buf,"r")) != NULL) {
while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) {
q = index (p,'\n');
if (q) *q = 0;
if (index ("#;:",*p)) continue;
@ -353,7 +367,7 @@ register char *filename,*collname,*basedir;
}
(void) fclose (f);
}
if ((c = (COLLECTION *) malloc (sizeof(COLLECTION))) == NULL)
if ((c = (SCAN_COLLECTION *) malloc (sizeof(SCAN_COLLECTION))) == NULL)
quit (1,"supscan: can't malloc collection structure\n");
c->Cname = collname;
c->Cbase = basedir;
@ -361,7 +375,9 @@ register char *filename,*collname,*basedir;
c->Cnext = NULL;
return (c);
}
#if __STDC__
void
#ifdef __STDC__
goaway (char *fmt,...)
#else
/*VARARGS*//*ARGSUSED*/
@ -369,14 +385,13 @@ goaway (va_alist)
va_dcl
#endif
{
#if !__STDC__
char *fmt;
#endif
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap,fmt);
#else
char *fmt;
va_start(ap);
fmt = va_arg(ap,char *);
#endif