|
|
1.1 ! root 1: /* ! 2: * miscellany ! 3: */ ! 4: ! 5: #include "mgr.h" ! 6: #include <setjmp.h> ! 7: #include <stdio.h> ! 8: #include <ctype.h> ! 9: #include <libc.h> ! 10: ! 11: /* ! 12: * trap errors from recomp and regexec ! 13: */ ! 14: ! 15: jmp_buf rxerr; ! 16: ! 17: regerror(s) ! 18: char *s; ! 19: { ! 20: logevent("regex error: %s\n", s); ! 21: longjmp(rxerr, 1); ! 22: } ! 23: ! 24: ! 25: /* ! 26: * read a line from the remote end ! 27: */ ! 28: char * ! 29: rdline(f) ! 30: int f; ! 31: { ! 32: static char buf[ARB]; ! 33: register char *p; ! 34: register int n; ! 35: ! 36: for (p = buf; p-buf<ARB-1; p++) { ! 37: n = read(f, p, 1); ! 38: if (n <= 0) ! 39: break; ! 40: if (*p == '\r' || *p == '\n' || *p == '\0') { ! 41: *++p = '\0'; ! 42: return (buf); ! 43: } ! 44: } ! 45: return NULL; ! 46: } ! 47: ! 48: ! 49: /* ! 50: * compile a regular expression inserting a ^ at the beginning and ! 51: * a $ at the end. ! 52: */ ! 53: regexp * ! 54: nregcomp(re) ! 55: char *re; ! 56: { ! 57: char fullre[ARB]; ! 58: register char *cp=fullre; ! 59: ! 60: *cp++ = '^'; ! 61: while(*re) ! 62: *cp++ = *re++; ! 63: *cp++ = '$'; ! 64: *cp = '\0'; ! 65: return regcomp(fullre); ! 66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.