constification from Paul Ripke to make it compile on OS/X

This commit is contained in:
christos 2009-10-16 12:41:37 +00:00
parent f94b517224
commit de1256ff71
14 changed files with 122 additions and 119 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: log.c,v 1.9 2007/12/20 20:17:52 christos Exp $ */
/* $NetBSD: log.c,v 1.10 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -64,7 +64,7 @@ logopen(char *program)
}
void
logquit(int retval, char *fmt, ...)
logquit(int retval, const char *fmt, ...)
{
char buf[STRINGLENGTH];
va_list ap;
@ -81,7 +81,7 @@ logquit(int retval, char *fmt, ...)
}
void
logerr(char *fmt, ...)
logerr(const char *fmt, ...)
{
char buf[STRINGLENGTH];
va_list ap;
@ -98,7 +98,7 @@ logerr(char *fmt, ...)
}
void
loginfo(char *fmt, ...)
loginfo(const char *fmt, ...)
{
char buf[STRINGLENGTH];
va_list ap;
@ -131,7 +131,7 @@ int allow_severity = LIBWRAP_ALLOW_FACILITY | LIBWRAP_ALLOW_SEVERITY;
int deny_severity = LIBWRAP_DENY_FACILITY | LIBWRAP_DENY_SEVERITY;
void
logdeny(char *fmt, ...)
logdeny(const char *fmt, ...)
{
char buf[STRINGLENGTH];
va_list ap;
@ -148,7 +148,7 @@ logdeny(char *fmt, ...)
}
void
logallow(char *fmt, ...)
logallow(const char *fmt, ...)
{
char buf[STRINGLENGTH];
va_list ap;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nxtarg.c,v 1.5 2002/07/10 20:19:41 wiz Exp $ */
/* $NetBSD: nxtarg.c,v 1.6 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1991 Carnegie Mellon University
@ -27,8 +27,8 @@
/*
* nxtarg -- strip off arguments from a string
*
* Usage: p = nxtarg (&q,brk);
* char *p,*q,*brk;
* Usage: p = nxtarg (&q,sep);
* char *p,*q,*sep;
* extern char _argbreak;
*
* q is pointer to next argument in string
@ -36,12 +36,12 @@
* 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".
* first occurence of one of the characters in the string "sep".
* 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.
* If "sep" is 0, then " " is substituted.
*
* HISTORY
* 01-Jul-83 Steven Shafer (sas) at Carnegie-Mellon University
@ -60,7 +60,7 @@
char _argbreak;
char *
nxtarg(char **q, char *brk)
nxtarg(char **q, const char *sep)
{
char *front, *back;
front = *q; /* start of string */
@ -68,9 +68,9 @@ nxtarg(char **q, char *brk)
while (*front && (*front == ' ' || *front == '\t'))
front++;
/* find break character at end */
if (brk == 0)
brk = " ";
back = skipto(front, brk);
if (sep == 0)
sep = " ";
back = skipto(front, sep);
_argbreak = *back;
*q = (*back ? back + 1 : back); /* next arg start loc */
/* elim trailing blanks and tabs */

View File

@ -1,4 +1,4 @@
/* $NetBSD: quit.c,v 1.5 2002/07/10 20:19:41 wiz Exp $ */
/* $NetBSD: quit.c,v 1.6 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1991 Carnegie Mellon University
@ -49,7 +49,7 @@
#include "supextern.h"
void
quit(int status, char *fmt, ...)
quit(int status, const char *fmt, ...)
{
va_list args;

View File

@ -1,4 +1,4 @@
/* $NetBSD: scm.c,v 1.26 2009/01/15 15:58:42 christos Exp $ */
/* $NetBSD: scm.c,v 1.27 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -373,7 +373,7 @@ dobackoff(int *t, int *b)
if (*b < 32)
*b <<= 1;
if (*t != -1) {
if (s > *t)
if (s > (unsigned) *t)
s = *t;
*t -= s;
}
@ -486,7 +486,7 @@ myhost(void)
return (name);
}
char *
const char *
remotehost(void)
{ /* remote host name (if known) */
char h1[NI_MAXHOST];
@ -652,7 +652,7 @@ matchhost(char *name)
}
int
scmerr(int error, char *fmt, ...)
scmerr(int error, const char *fmt, ...)
{
va_list ap;
@ -692,7 +692,7 @@ byteswap(int in)
return (in);
x.ui = in;
iy = sizeof(int);
for (ix = 0; ix < sizeof(int); ix++) {
for (ix = 0; ix < (int) sizeof(int); ix++) {
--iy;
y.uc[iy] = x.uc[ix];
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: scmio.c,v 1.16 2006/05/25 02:10:53 christos Exp $ */
/* $NetBSD: scmio.c,v 1.17 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -199,7 +199,7 @@ struct buf {
char *b_ptr; /* pointer to end of buffer */
int b_cnt; /* number of bytes in buffer */
} buffers[2];
struct buf *bufptr; /* buffer pointer */
struct buf *gblbufptr; /* buffer pointer */
static int writedata(int, char *);
static int writeblock(int, char *);
@ -217,22 +217,22 @@ writedata(int count, char *data)
int x, tries;
struct buf *bp;
if (bufptr) {
if (bufptr->b_cnt + count <= FILEXFER) {
memcpy(bufptr->b_ptr, data, count);
bufptr->b_cnt += count;
bufptr->b_ptr += count;
if (gblbufptr) {
if (gblbufptr->b_cnt + count <= FILEXFER) {
memcpy(gblbufptr->b_ptr, data, count);
gblbufptr->b_cnt += count;
gblbufptr->b_ptr += count;
return (SCMOK);
}
bp = (bufptr == buffers) ? &buffers[1] : buffers;
bp = (gblbufptr == buffers) ? &buffers[1] : buffers;
memcpy(bp->b_data, 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;
data = gblbufptr->b_data;
count = gblbufptr->b_cnt;
gblbufptr->b_cnt = 0;
gblbufptr->b_ptr = gblbufptr->b_data;
gblbufptr = bp;
}
tries = 0;
for (;;) {
@ -278,11 +278,11 @@ writemsg(int msg)
if (scmdebug > 1)
loginfo("SCM Writing message %d", msg);
if (bufptr)
if (gblbufptr)
return (scmerr(-1, "Buffering already enabled"));
bufptr = buffers;
bufptr->b_ptr = bufptr->b_data;
bufptr->b_cnt = 0;
gblbufptr = buffers;
gblbufptr->b_ptr = gblbufptr->b_data;
gblbufptr->b_cnt = 0;
x = byteswap(msg);
return (writedata(sizeof(int), (char *) &x));
}
@ -298,15 +298,15 @@ writemend(void)
x = writedata(sizeof(int), (char *) &x);
if (x != SCMOK)
return (x);
if (bufptr == NULL)
if (gblbufptr == NULL)
return (scmerr(-1, "Buffering already disabled"));
if (bufptr->b_cnt == 0) {
bufptr = NULL;
if (gblbufptr->b_cnt == 0) {
gblbufptr = NULL;
return (SCMOK);
}
data = bufptr->b_data;
count = bufptr->b_cnt;
bufptr = NULL;
data = gblbufptr->b_data;
count = gblbufptr->b_cnt;
gblbufptr = NULL;
return (writedata(count, data));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: skipto.c,v 1.5 2002/07/10 20:19:43 wiz Exp $ */
/* $NetBSD: skipto.c,v 1.6 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1991 Carnegie Mellon University
@ -58,9 +58,9 @@
static char tab[256] = { 0 };
char *
skipto(char *string, char *charset)
skipto(const char *string, const char *charset)
{
char *setp, *strp;
const char *setp, *strp;
tab[0] = 1; /* Stop on a null, too. */
for (setp = charset; *setp; setp++)
@ -69,13 +69,13 @@ skipto(char *string, char *charset)
continue;
for (setp = charset; *setp; setp++)
tab[(unsigned char) *setp] = 0;
return strp;
return __UNCONST(strp);
}
char *
skipover(char *string, char *charset)
skipover(const char *string, const char *charset)
{
char *setp, *strp;
const char *setp, *strp;
tab[0] = 0; /* Do not skip over nulls. */
for (setp = charset; *setp; setp++)
@ -84,5 +84,5 @@ skipover(char *string, char *charset)
continue;
for (setp = charset; *setp; setp++)
tab[(unsigned char) *setp] = 0;
return strp;
return __UNCONST(strp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: stree.c,v 1.12 2007/12/20 20:17:52 christos Exp $ */
/* $NetBSD: stree.c,v 1.13 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -59,13 +59,13 @@
#include "libc.h"
#include "c.h"
static TREE *Tmake(char *);
static TREE *Tmake(const char *);
static TREE *Trotll(TREE *, TREE *);
static TREE *Trotlh(TREE *, TREE *);
static TREE *Trothl(TREE *, TREE *);
static TREE *Trothh(TREE *, TREE *);
static void Tbalance(TREE **);
static TREE *Tinsertavl(TREE **, char *, int, int *);
static TREE *Tinsertavl(TREE **, const char *, int, int *);
static int Tsubprocess(TREE *, int, int (*f) (TREE *, void *), void *);
static int Tprintone(TREE *, void *);
@ -94,7 +94,7 @@ Tfree(TREE ** t)
}
static TREE *
Tmake(char *p)
Tmake(const char *p)
{
TREE *t;
t = (TREE *) malloc(sizeof(TREE));
@ -192,7 +192,7 @@ Tbalance(TREE ** t)
}
static TREE *
Tinsertavl(TREE ** t, char *p, int find, int *dh)
Tinsertavl(TREE ** t, const char *p, int find, int *dh)
{
TREE *newt;
int cmp;
@ -225,7 +225,7 @@ Tinsertavl(TREE ** t, char *p, int find, int *dh)
}
TREE *
Tinsert(TREE ** t, char *p, int find)
Tinsert(TREE ** t, const char *p, int find)
{
int deltah;
@ -240,7 +240,7 @@ Tinsert(TREE ** t, char *p, int find)
}
TREE *
Tsearch(TREE * t, char *p)
Tsearch(TREE * t, const char *p)
{
TREE *x;
int cmp;
@ -259,10 +259,11 @@ Tsearch(TREE * t, char *p)
}
TREE *
Tlookup(TREE * t, char *p)
Tlookup(TREE * t, const char *p)
{
TREE *x;
char buf[MAXPATHLEN + 1];
char *q;
if (p == NULL)
return (NULL);
@ -279,16 +280,16 @@ Tlookup(TREE * t, char *p)
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';
while ((q = rindex(buf, '/')) != NULL) {
while (q >= buf && *(q - 1) == '/')
q--;
if (q == buf)
*(q + 1) = '\0';
else
*p = '\0';
*q = '\0';
if ((x = Tsearch(t, buf)) != NULL)
return (x);
if (p == buf)
if (q == buf)
break;
}
return (NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: supcmain.c,v 1.27 2009/07/17 20:31:20 jakllsch Exp $ */
/* $NetBSD: supcmain.c,v 1.28 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -361,14 +361,16 @@ int
main(int argc, char **argv)
{
char *progname, *supfname;
int restart, sfdev = 0, sfino = 0;
int restart;
dev_t sfdev = 0;
ino_t sfino = 0;
time_t sfmtime = 0;
struct stat sbuf;
struct sigaction ign;
/* initialize global variables */
pgmversion = PGMVERSION;/* export version number */
server = FALSE; /* export that we're not a server */
isserver = FALSE; /* export that we're not a server */
collname = NULL; /* no current collection yet */
dontjump = TRUE; /* clear setjmp buffer */
progname = estrdup(argv[0]);
@ -597,7 +599,7 @@ init(int argc, char **argv)
char buf[STRINGLENGTH], *p;
const char *u;
char username[STRINGLENGTH];
char *supfname, *arg;
char *supfname, **arg;
COLLECTION *c, *lastC;
FILE *f;
int bogus;

View File

@ -1,4 +1,4 @@
/* $NetBSD: supcmeat.c,v 1.34 2009/01/16 10:24:20 junyoung Exp $ */
/* $NetBSD: supcmeat.c,v 1.35 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -1457,7 +1457,7 @@ finishone(TREE * t, void *fv)
}
void
done(int value, char *fmt, ...)
done(int value, const char *fmt, ...)
{
char buf[STRINGLENGTH];
va_list ap;

View File

@ -1,4 +1,4 @@
/* $NetBSD: supcmisc.c,v 1.19 2009/01/15 15:58:42 christos Exp $ */
/* $NetBSD: supcmisc.c,v 1.20 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -264,7 +264,7 @@ ugconvert(char *uname, char *gname, int *uid, int *gid, int *mode)
*********************************************/
void
notify(char *fmt, ...)
notify(const char *fmt, ...)
{ /* record error message */
char buf[STRINGLENGTH];
char collrelname[STRINGLENGTH];

View File

@ -1,4 +1,4 @@
/* $NetBSD: supextern.h,v 1.20 2009/01/15 15:58:42 christos Exp $ */
/* $NetBSD: supextern.h,v 1.21 2009/10/16 12:41:37 christos Exp $ */
struct stat;
@ -16,16 +16,16 @@ int filecopy(int, int );
/* log.c */
void logopen(char *);
void logquit(int, char *, ...)
void logquit(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
void logerr(char *, ...)
void logerr(const char *, ...)
__attribute__((__format__(__printf__, 1, 2))) ;
void loginfo(char *, ...)
void loginfo(const char *, ...)
__attribute__((__format__(__printf__, 1, 2)));
#ifdef LIBWRAP
void logdeny(char *, ...)
void logdeny(const char *, ...)
__attribute__((__format__(__printf__, 1, 2)));
void logallow(char *, ...)
void logallow(const char *, ...)
__attribute__((__format__(__printf__, 1, 2)));
#endif
@ -36,13 +36,13 @@ void decode(char *, char *, int);
void encode(char *, char *, int);
/* nxtarg.c */
char *nxtarg(char **, char *);
char *nxtarg(char **, const char *);
/* path.c */
void path(char *, char *, char *);
/* quit.c */
void quit(int, char *, ...)
void quit(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
/* read_line.c */
@ -74,11 +74,11 @@ int serviceend(void);
int dobackoff(int *, int *);
int request(char *, char *, int *);
int requestend(void);
char *remotehost(void);
const char *remotehost(void);
int thishost(char *);
int samehost(void);
int matchhost(char *);
int scmerr(int, char *, ...)
int scmerr(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
int byteswap(int);
@ -105,14 +105,14 @@ int readmstr(int, char **);
void crosspatch(void);
/* skipto.c */
char *skipto(char *, char *);
char *skipover(char *, char *);
char *skipto(const char *, const char *);
char *skipover(const char *, const char *);
/* stree.c */
void Tfree(TREE **);
TREE *Tinsert(TREE **, char *, int);
TREE *Tsearch(TREE *, char *);
TREE *Tlookup(TREE *, char *);
TREE *Tinsert(TREE **, const char *, int);
TREE *Tsearch(TREE *, const char *);
TREE *Tlookup(TREE *, const char *);
int Trprocess(TREE *, int (*)(TREE *, void *), void *);
int Tprocess(TREE *, int (*)(TREE *, void *), void *);
void Tprint(TREE *, char *);
@ -132,9 +132,9 @@ int recvsym(TREE *, int, struct stat *);
int recvreg(TREE *, int, struct stat *);
int copyfile(char *, char *);
void finishup(int);
void done(int, char *, ...)
void done(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
void goaway(char *, ...)
void goaway(const char *, ...)
__attribute__((__format__(__printf__, 1, 2)));
/* supcmisc.c */
@ -143,7 +143,7 @@ int establishdir(char *);
int makedir(char *, unsigned int, struct stat *);
int estabd(char *, char *);
void ugconvert(char *, char *, int *, int *, int *);
void notify(char *, ...)
void notify(const char *, ...)
__attribute__((__format__(__printf__, 1, 2)));
void lockout(int);
char *fmttime(time_t);

View File

@ -1,4 +1,4 @@
/* $NetBSD: supfilesrv.c,v 1.41 2007/12/20 20:17:52 christos Exp $ */
/* $NetBSD: supfilesrv.c,v 1.42 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -363,7 +363,7 @@ TREE *linkcheck(TREE *, int, int);
char *uconvert(int);
char *gconvert(int);
char *changeuid(char *, char *, int, int);
void goaway(char *, ...);
void goaway(const char *, ...);
char *fmttime(time_t);
int local_file(int, struct stat *);
int stat_info_ok(struct stat *, struct stat *);
@ -387,7 +387,7 @@ main(int argc, char **argv)
/* initialize global variables */
pgmversion = PGMVERSION;/* export version number */
server = TRUE; /* export that we're not a server */
isserver = TRUE; /* export that we're not a server */
collname = NULL; /* no current collection yet */
maxchildren = MAXCHILDREN; /* defined in sup.h */
@ -593,7 +593,7 @@ init(int argc, char **argv)
uidH[i] = gidH[i] = inodeH[i] = NULL;
return;
}
server = FALSE;
isserver = FALSE;
if (argc < 1)
usage();
f = fopen(cryptkey, "r");
@ -1777,7 +1777,7 @@ changeuid(char *namep, char *passwordp, int fileuid, int filegid)
}
void
goaway(char *fmt, ...)
goaway(const char *fmt, ...)
{
char buf[STRINGLENGTH];
va_list ap;

View File

@ -1,4 +1,4 @@
/* $NetBSD: supmsg.c,v 1.15 2006/12/20 16:33:35 christos Exp $ */
/* $NetBSD: supmsg.c,v 1.16 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -80,7 +80,7 @@ msgsignon(void)
{
int x;
if (server) {
if (isserver) {
x = readmsg(MSGSIGNON);
if (x == SCMOK)
x = readint(&protver);
@ -109,7 +109,7 @@ msgsignonack(void)
{
int x;
if (server) {
if (isserver) {
x = writemsg(MSGSIGNONACK);
if (x == SCMOK)
x = writeint(PROTOVERSION);
@ -156,7 +156,7 @@ msgsetup(void)
{
int x;
if (server) {
if (isserver) {
x = readmsg(MSGSETUP);
if (x != SCMOK)
return (x);
@ -233,7 +233,7 @@ msgsetup(void)
int
msgsetupack(void)
{
if (server)
if (isserver)
return (writemint(MSGSETUPACK, setupack));
return (readmint(MSGSETUPACK, &setupack));
}
@ -245,7 +245,7 @@ extern char *crypttest; /* encryption test string */
int
msgcrypt(void)
{
if (server)
if (isserver)
return (readmstr(MSGCRYPT, &crypttest));
return (writemstr(MSGCRYPT, crypttest));
}
@ -253,7 +253,7 @@ msgcrypt(void)
int
msgcryptok(void)
{
if (server)
if (isserver)
return (writemnull(MSGCRYPTOK));
return (readmnull(MSGCRYPTOK));
}
@ -270,7 +270,7 @@ int
msglogin(void)
{
int x;
if (server) {
if (isserver) {
x = readmsg(MSGLOGIN);
if (x == SCMOK)
x = readstring(&logcrypt);
@ -298,7 +298,7 @@ int
msglogack(void)
{
int x;
if (server) {
if (isserver) {
x = writemsg(MSGLOGACK);
if (x == SCMOK)
x = writeint(logack);
@ -332,7 +332,7 @@ int
msgrefuse(void)
{
int x;
if (server) {
if (isserver) {
char *name;
x = readmsg(MSGREFUSE);
if (x == SCMOK)
@ -383,7 +383,7 @@ int
msglist(void)
{
int x;
if (server) {
if (isserver) {
x = writemsg(MSGLIST);
if (x == SCMOK)
x = Tprocess(listT, listone, NULL);
@ -443,7 +443,7 @@ int
msgneed(void)
{
int x;
if (server) {
if (isserver) {
char *name;
int update;
TREE *t;
@ -490,7 +490,7 @@ int
msgdeny(void)
{
int x;
if (server) {
if (isserver) {
x = writemsg(MSGDENY);
if (x == SCMOK)
x = Tprocess(denyT, denyone, NULL);
@ -522,7 +522,7 @@ msgdeny(void)
int
msgsend(void)
{
if (server)
if (isserver)
return (readmnull(MSGSEND));
return (writemnull(MSGSEND));
}
@ -546,7 +546,7 @@ msgrecv(int (*xferfile)(TREE *, va_list), ...)
TREE *t = upgradeT;
va_start(args, xferfile);
if (server) {
if (isserver) {
x = writemsg(MSGRECV);
if (t == NULL) {
if (x == SCMOK)
@ -664,7 +664,7 @@ msgdone(void)
printf("Error, msgdone should not have been called.");
return (SCMERR);
}
if (server) {
if (isserver) {
x = readmsg(MSGDONE);
if (x == SCMOK)
x = readint(&doneack);
@ -705,7 +705,7 @@ msgxpatch(void)
int x;
int i;
if (server) {
if (isserver) {
x = readmsg(MSGXPATCH);
if (x != SCMOK)
return (x);
@ -746,7 +746,7 @@ extern int docompress; /* Compress file before sending? */
int
msgcompress(void)
{
if (server)
if (isserver)
return (readmint(MSGCOMPRESS, &docompress));
return (writemint(MSGCOMPRESS, docompress));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: supmsg.h,v 1.6 2001/01/16 02:50:32 cgd Exp $ */
/* $NetBSD: supmsg.h,v 1.7 2009/10/16 12:41:37 christos Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@ -109,7 +109,7 @@
#ifdef MSGSUBR
/* used in all msg routines */
extern int server; /* true if we are the server */
extern int isserver; /* true if we are the server */
extern int protver; /* protocol version of partner */
#else /* MSGSUBR */
@ -121,7 +121,7 @@ extern int protver; /* protocol version of partner */
#endif /* MSGFILE */
/* used in all msg routines */
EXTERN int server; /* true if we are the server */
EXTERN int isserver; /* true if we are the server */
/* msggoaway */
EXTERN char *goawayreason; /* reason for goaway */