|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <regexp.h> ! 3: #include <ctype.h> ! 4: #include "mail.h" ! 5: #include "string.h" ! 6: #include "aux.h" ! 7: ! 8: /* expand a path relative to some `.' */ ! 9: extern string * ! 10: abspath(path, dot, to) ! 11: char *path; ! 12: char *dot; ! 13: string *to; ! 14: { ! 15: if (*path == '/') { ! 16: to = s_append(to, path); ! 17: } else { ! 18: to = s_append(to, dot); ! 19: to = s_append(to, path); ! 20: } ! 21: return to; ! 22: } ! 23: ! 24: /* return a pointer to the base component of a pathname */ ! 25: extern char * ! 26: basename(path) ! 27: char *path; ! 28: { ! 29: char *cp; ! 30: ! 31: cp = strrchr(path, '/'); ! 32: return cp==NULL ? path : cp+1; ! 33: } ! 34: ! 35: /* return delivery status required by the mbox */ ! 36: extern int ! 37: delivery_status(line) ! 38: string *line; ! 39: { ! 40: string *s1 = s_new(), *s2 = s_new(); ! 41: char *cline; ! 42: int rv; ! 43: ! 44: s_restart(line); ! 45: cline = s_to_c(line); ! 46: if (*cline=='\0') ! 47: rv = MF_NORMAL; ! 48: else if (IS_HEADER(cline)) ! 49: rv = MF_NORMAL; ! 50: else if (s_parse(line, s1) == 0) ! 51: rv = MF_NOTMBOX; ! 52: else if (s_parse(line, s2) == 0) ! 53: return MF_NOTMBOX; ! 54: else if (strcmp(s_to_c(s2), "to") != 0) ! 55: rv = MF_NOTMBOX; ! 56: else if (strcmp(s_to_c(s1), "Forward") == 0) ! 57: rv = MF_FORWARD; ! 58: else if (strcmp(s_to_c(s1), "Pipe") == 0) ! 59: rv = MF_PIPE; ! 60: else ! 61: rv = MF_NOTMBOX; ! 62: s_free(s1); s_free(s2); ! 63: return rv; ! 64: } ! 65: ! 66: /* append a sub-expression match onto a string */ ! 67: extern void ! 68: append_match(subexp, sp, se) ! 69: regsubexp *subexp; /* regular subexpression matches */ ! 70: register string *sp; /* string to append to */ ! 71: int se; /* index of subexpression to append */ ! 72: { ! 73: register char *cp = subexp[se].sp; ! 74: register char *ep = subexp[se].ep; ! 75: ! 76: for (; cp < ep; cp++) ! 77: s_putc(sp, *cp); ! 78: s_terminate(sp); ! 79: } ! 80: ! 81: /* ! 82: * check for shell characters in a string ! 83: */ ! 84: #define CHARS "()<>{};\\'\"`^&|\r\n \t" ! 85: extern int ! 86: shellchars(cp) ! 87: char *cp; ! 88: { ! 89: char *sp; ! 90: ! 91: for(sp=CHARS; *sp; sp++) ! 92: if(strchr(cp, *sp)) ! 93: return 1; ! 94: for(; *cp; cp++) ! 95: if(!isprint(*cp)) ! 96: return 1; ! 97: return 0; ! 98: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.