version 1.4, 1997/05/30 08:51:32 |
version 1.5, 1997/07/13 21:21:08 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: aux.c,v 1.4 1996/06/08 19:48:10 christos Exp $ */ |
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1980, 1993 |
* Copyright (c) 1980, 1993 |
|
|
|
|
if ((new = salloc(size)) != NOSTR) |
if ((new = salloc(size)) != NOSTR) |
bcopy(str, new, size); |
bcopy(str, new, size); |
return new; |
return(new); |
} |
} |
|
|
/* |
/* |
|
|
} |
} |
bcopy(str, new + oldsize, newsize); |
bcopy(str, new + oldsize, newsize); |
} |
} |
return new; |
return(new); |
} |
} |
|
|
/* |
/* |
|
|
(void)fprintf(stderr, "panic: "); |
(void)fprintf(stderr, "panic: "); |
vfprintf(stderr, fmt, ap); |
vfprintf(stderr, fmt, ap); |
va_end(ap); |
va_end(ap); |
(void)fprintf(stderr, "\n"); |
(void)putc('\n', stderr); |
fflush(stderr); |
fflush(stderr); |
abort(); |
abort(); |
} |
} |
|
|
|
|
for (ap = argv; *ap++ != NOSTR;) |
for (ap = argv; *ap++ != NOSTR;) |
; |
; |
return ap - argv - 1; |
return(ap - argv - 1); |
} |
} |
|
|
/* |
/* |
|
|
|
|
ibuf = setinput(mp); |
ibuf = setinput(mp); |
if ((lc = mp->m_lines - 1) < 0) |
if ((lc = mp->m_lines - 1) < 0) |
return NOSTR; |
return(NOSTR); |
if (readline(ibuf, linebuf, LINESIZE) < 0) |
if (readline(ibuf, linebuf, LINESIZE) < 0) |
return NOSTR; |
return(NOSTR); |
while (lc > 0) { |
while (lc > 0) { |
if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0) |
if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0) |
return oldhfield; |
return(oldhfield); |
if ((hfield = ishfield(linebuf, colon, field)) != NULL) |
if ((hfield = ishfield(linebuf, colon, field)) != NULL) |
oldhfield = save2str(hfield, oldhfield); |
oldhfield = save2str(hfield, oldhfield); |
} |
} |
return oldhfield; |
return(oldhfield); |
} |
} |
|
|
/* |
/* |
|
|
|
|
for (;;) { |
for (;;) { |
if (--rem < 0) |
if (--rem < 0) |
return -1; |
return(-1); |
if ((c = readline(f, linebuf, LINESIZE)) <= 0) |
if ((c = readline(f, linebuf, LINESIZE)) <= 0) |
return -1; |
return(-1); |
for (cp = linebuf; isprint(*cp) && *cp != ' ' && *cp != ':'; |
for (cp = linebuf; isprint(*cp) && *cp != ' ' && *cp != ':'; |
cp++) |
cp++) |
; |
; |
|
|
cp += c; |
cp += c; |
} |
} |
*cp = 0; |
*cp = 0; |
return rem; |
return(rem); |
} |
} |
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
|
|
*cp = 0; |
*cp = 0; |
if (strcasecmp(linebuf, field) != 0) { |
if (strcasecmp(linebuf, field) != 0) { |
*cp = ':'; |
*cp = ':'; |
return 0; |
return(0); |
} |
} |
*cp = ':'; |
*cp = ':'; |
for (cp++; *cp == ' ' || *cp == '\t'; cp++) |
for (cp++; *cp == ' ' || *cp == '\t'; cp++) |
; |
; |
return cp; |
return(cp); |
} |
} |
|
|
/* |
/* |
|
|
if ((cp = expand(*arglist)) == NOSTR) |
if ((cp = expand(*arglist)) == NOSTR) |
return(1); |
return(1); |
if ((fi = Fopen(cp, "r")) == NULL) { |
if ((fi = Fopen(cp, "r")) == NULL) { |
perror(cp); |
warn(cp); |
return(1); |
return(1); |
} |
} |
if (ssp >= NOFILE - 1) { |
if (ssp >= NOFILE - 1) { |
printf("Too much \"sourcing\" going on.\n"); |
puts("Too much \"sourcing\" going on."); |
Fclose(fi); |
(void)Fclose(fi); |
return(1); |
return(1); |
} |
} |
sstack[ssp].s_file = input; |
sstack[ssp].s_file = input; |
|
|
unstack() |
unstack() |
{ |
{ |
if (ssp <= 0) { |
if (ssp <= 0) { |
printf("\"Source\" stack over-pop.\n"); |
puts("\"Source\" stack over-pop."); |
sourcing = 0; |
sourcing = 0; |
return(1); |
return(1); |
} |
} |
Fclose(input); |
(void)Fclose(input); |
if (cond != CANY) |
if (cond != CANY) |
printf("Unmatched \"if\"\n"); |
puts("Unmatched \"if\""); |
ssp--; |
ssp--; |
cond = sstack[ssp].s_cond; |
cond = sstack[ssp].s_cond; |
loading = sstack[ssp].s_loading; |
loading = sstack[ssp].s_loading; |
|
|
break; |
break; |
} |
} |
} |
} |
return cp; |
return(cp); |
} |
} |
|
|
/* |
/* |
|
|
int first = 1; |
int first = 1; |
|
|
if ((cp = hfield("from", mp)) != NOSTR) |
if ((cp = hfield("from", mp)) != NOSTR) |
return cp; |
return(cp); |
if (reptype == 0 && (cp = hfield("sender", mp)) != NOSTR) |
if (reptype == 0 && (cp = hfield("sender", mp)) != NOSTR) |
return cp; |
return(cp); |
ibuf = setinput(mp); |
ibuf = setinput(mp); |
namebuf[0] = '\0'; |
namebuf[0] = '\0'; |
if (readline(ibuf, linebuf, LINESIZE) < 0) |
if (readline(ibuf, linebuf, LINESIZE) < 0) |
|
|
break; |
break; |
cp++; |
cp++; |
if (first) { |
if (first) { |
strcpy(namebuf, cp); |
cp2 = namebuf; |
first = 0; |
first = 0; |
} else |
} else |
strcpy(strrchr(namebuf, '!')+1, cp); |
cp2 = strrchr(namebuf, '!') + 1; |
|
strncpy(cp2, cp, sizeof(namebuf) - (cp2 - namebuf) - 2); |
|
namebuf[sizeof(namebuf) - 2] = '\0'; |
strcat(namebuf, "!"); |
strcat(namebuf, "!"); |
goto newname; |
goto newname; |
} |
} |
|
|
|
|
while (*s1) |
while (*s1) |
if (strchr(s2, *s1++)) |
if (strchr(s2, *s1++)) |
return 1; |
return(1); |
return 0; |
return(0); |
} |
} |
|
|
/* |
/* |
|
|
{ |
{ |
|
|
if (islower(c)) |
if (islower(c)) |
return toupper(c); |
return(toupper(c)); |
return c; |
return(c); |
} |
} |
|
|
/* |
/* |
|
|
|
|
while ((*s2++ = *s1++) != '\0') |
while ((*s2++ = *s1++) != '\0') |
; |
; |
return s2 - 1; |
return(s2 - 1); |
} |
} |
|
|
/* |
/* |
|
|
char *field; |
char *field; |
struct ignoretab ignore[2]; |
struct ignoretab ignore[2]; |
{ |
{ |
char realfld[BUFSIZ]; |
char realfld[LINESIZE]; |
|
|
if (ignore == ignoreall) |
if (ignore == ignoreall) |
return 1; |
return(1); |
/* |
/* |
* Lower-case the string, so that "Status" and "status" |
* Lower-case the string, so that "Status" and "status" |
* will hash to the same place. |
* will hash to the same place. |
*/ |
*/ |
istrcpy(realfld, field); |
istrcpy(realfld, field); |
if (ignore[1].i_count > 0) |
if (ignore[1].i_count > 0) |
return (!member(realfld, ignore + 1)); |
return(!member(realfld, ignore + 1)); |
else |
else |
return (member(realfld, ignore)); |
return(member(realfld, ignore)); |
} |
} |
|
|
int |
int |
|
|
for (igp = table->i_head[hash(realfield)]; igp != 0; igp = igp->i_link) |
for (igp = table->i_head[hash(realfield)]; igp != 0; igp = igp->i_link) |
if (*igp->i_field == *realfield && |
if (*igp->i_field == *realfield && |
equal(igp->i_field, realfield)) |
equal(igp->i_field, realfield)) |
return (1); |
return(1); |
return (0); |
return(0); |
} |
} |