X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/828615a1268b1799e4092fbbdf7b2e1a5ccceaf2..a8a981d5f148852aba34fa7b1b2ee3ca7ea53954:/usr/src/usr.bin/mail/aux.c diff --git a/usr/src/usr.bin/mail/aux.c b/usr/src/usr.bin/mail/aux.c index 84cd7daab1..2e5229c0f0 100644 --- a/usr/src/usr.bin/mail/aux.c +++ b/usr/src/usr.bin/mail/aux.c @@ -1,12 +1,23 @@ /* * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint -static char *sccsid = "@(#)aux.c 5.6 (Berkeley) %G%"; -#endif not lint +static char sccsid[] = "@(#)aux.c 5.15 (Berkeley) %G%"; +#endif /* not lint */ #include "rcv.h" #include @@ -20,22 +31,16 @@ static char *sccsid = "@(#)aux.c 5.6 (Berkeley) %G%"; /* * Return a pointer to a dynamic copy of the argument. */ - char * savestr(str) char *str; { - register char *cp, *cp2, *top; + char *new; + int size = strlen(str) + 1; - for (cp = str; *cp; cp++) - ; - top = salloc(cp-str + 1); - if (top == NOSTR) - return(NOSTR); - for (cp = str, cp2 = top; *cp; cp++) - *cp2++ = *cp; - *cp2 = 0; - return(top); + if ((new = salloc(size)) != NOSTR) + bcopy(str, new, size); + return new; } /* @@ -57,14 +62,10 @@ panic(fmt, a, b) * Touched messages have the effect of not being sent * back to the system mailbox on exit. */ - -touch(mesg) -{ +touch(mp) register struct message *mp; +{ - if (mesg < 1 || mesg > msgCount) - return; - mp = &message[mesg-1]; mp->m_flag |= MTOUCH; if ((mp->m_flag & MREAD) == 0) mp->m_flag |= MREAD|MSTATUS; @@ -74,7 +75,6 @@ touch(mesg) * Test to see if the passed file name is a directory. * Return true if it is. */ - isdir(name) char name[]; { @@ -88,7 +88,6 @@ isdir(name) /* * Count the number of arguments in the given string raw list. */ - argcount(argv) char **argv; { @@ -103,7 +102,6 @@ argcount(argv) * Return the desired header line from the passed message * pointer (or NOSTR if the desired header field is not available). */ - char * hfield(field, mp) char field[]; @@ -135,7 +133,6 @@ hfield(field, mp) * "colon" is set to point to the colon in the header. * Must deal with \ continuations & other such fraud. */ - gethfield(f, linebuf, rem, colon) register FILE *f; char linebuf[]; @@ -202,7 +199,7 @@ ishfield(linebuf, colon, field) register char *cp = colon; *cp = 0; - if (!icequal(linebuf, field)) { + if (strcasecmp(linebuf, field) != 0) { *cp = ':'; return 0; } @@ -212,29 +209,6 @@ ishfield(linebuf, colon, field) return cp; } -/* - * Compare two strings, ignoring case. - */ - -icequal(s1, s2) - register char *s1, *s2; -{ - register c1, c2; - - for (;;) { - if ((c1 = (unsigned char)*s1++) != - (c2 = (unsigned char)*s2++)) { - if (isupper(c1)) - c1 = tolower(c1); - if (c1 != c2) - return 0; - } - if (c1 == 0) - return 1; - } - /*NOTREACHED*/ -} - /* * Copy a string, lowercasing it as we go. */ @@ -256,7 +230,7 @@ istrcpy(dest, src) * the stack. */ -static int ssp = -1; /* Top of file stack */ +static int ssp; /* Top of file stack */ struct sstack { FILE *s_file; /* File we were in. */ int s_cond; /* Saved state of conditionals */ @@ -268,27 +242,27 @@ struct sstack { * Set the global flag "sourcing" so that others will realize * that they are no longer reading from a tty (in all probability). */ - -source(name) - char name[]; +source(arglist) + char **arglist; { - register FILE *fi; - register char *cp; + FILE *fi; + char *cp; - if ((cp = expand(name)) == NOSTR) + if ((cp = expand(*arglist)) == NOSTR) return(1); if ((fi = fopen(cp, "r")) == NULL) { perror(cp); return(1); } - if (ssp >= NOFILE - 2) { + if (ssp >= NOFILE - 1) { printf("Too much \"sourcing\" going on.\n"); fclose(fi); return(1); } - sstack[++ssp].s_file = input; + sstack[ssp].s_file = input; sstack[ssp].s_cond = cond; sstack[ssp].s_loading = loading; + ssp++; loading = 0; cond = CANY; input = fi; @@ -300,10 +274,9 @@ source(name) * Pop the current input back to the previous level. * Update the "sourcing" flag as appropriate. */ - unstack() { - if (ssp < 0) { + if (ssp <= 0) { printf("\"Source\" stack over-pop.\n"); sourcing = 0; return(1); @@ -311,10 +284,11 @@ unstack() fclose(input); if (cond != CANY) printf("Unmatched \"if\"\n"); + ssp--; cond = sstack[ssp].s_cond; loading = sstack[ssp].s_loading; - input = sstack[ssp--].s_file; - if (ssp < 0) + input = sstack[ssp].s_file; + if (ssp == 0) sourcing = loading; return(0); } @@ -322,43 +296,25 @@ unstack() /* * Touch the indicated file. * This is nifty for the shell. - * If we have the utime() system call, this is better served - * by using that, since it will work for empty files. - * On non-utime systems, we must sleep a second, then read. */ - alter(name) char name[]; { -#ifdef UTIME struct stat statb; long time(); time_t time_p[2]; -#else - register int pid, f; - char w; -#endif UTIME -#ifdef UTIME if (stat(name, &statb) < 0) return; time_p[0] = time((long *) 0) + 1; time_p[1] = statb.st_mtime; utime(name, time_p); -#else - sleep(1); - if ((f = open(name, 0)) < 0) - return; - read(f, &w, 1); - exit(0); -#endif } /* * Examine the passed line buffer and * return true if it is all blanks and tabs. */ - blankline(linebuf) char linebuf[]; { @@ -523,7 +479,6 @@ done: * 1 -- get sender's name for reply * 2 -- get sender's name for Reply */ - char * name1(mp, reptype) register struct message *mp; @@ -597,7 +552,6 @@ charcount(str, c) /* * Are any of the characters in the two strings the same? */ - anyof(s1, s2) register char *s1, *s2; { @@ -611,7 +565,6 @@ anyof(s1, s2) /* * Convert c to upper case */ - raise(c) register c; { @@ -624,7 +577,6 @@ raise(c) /* * Copy s1 to s2, return pointer to null in s2. */ - char * copy(s1, s2) register char *s1, *s2; @@ -635,46 +587,35 @@ copy(s1, s2) return s2 - 1; } -/* - * Add a single character onto a string. - */ - -stradd(str, c) - register char *str; -{ - - while (*str++) - ; - str[-1] = c; - *str = 0; -} - /* * See if the given header field is supposed to be ignored. */ -isign(field) +isign(field, ignore) char *field; + struct ignoretab ignore[2]; { char realfld[BUFSIZ]; + if (ignore == ignoreall) + return 1; /* * Lower-case the string, so that "Status" and "status" * will hash to the same place. */ istrcpy(realfld, field); - if (nretained > 0) - return (!member(realfld, retain)); + if (ignore[1].i_count > 0) + return (!member(realfld, ignore + 1)); else return (member(realfld, ignore)); } member(realfield, table) register char *realfield; - struct ignore **table; + struct ignoretab *table; { register struct ignore *igp; - for (igp = table[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 && equal(igp->i_field, realfield)) return (1);