|
|
1.1 ! root 1: /* ! 2: * endstr --- return a pointer to the end of a string ! 3: */ ! 4: ! 5: char *endstr(s) ! 6: register char *s; ! 7: { ! 8: ! 9: while (*s++) ! 10: ; ! 11: return (--s); ! 12: } ! 13: ! 14: ! 15: /* ! 16: * move --- copy "length" bytes from "from" to "to" ! 17: */ ! 18: ! 19: move(length, from, to) ! 20: register int length; ! 21: register char *from, *to; ! 22: { ! 23: ! 24: while (--length >= 0) ! 25: *to++ = *from++; ! 26: } ! 27: ! 28: ! 29: /* ! 30: * smartmove --- move "length" bytes from "from" to "to"; handle overlap ! 31: */ ! 32: ! 33: smartmove(length, from, to) ! 34: register int length; ! 35: register char *from, *to; ! 36: { ! 37: ! 38: if (from < to && from + length > to) { ! 39: from += length; ! 40: to += length; ! 41: while (--length >= 0) ! 42: *--to = *--from; ! 43: } ! 44: else ! 45: while (--length >= 0) ! 46: *to++ = *from++; ! 47: } ! 48: ! 49: ! 50: #define READ 0 ! 51: #define WRITE 1 ! 52: ! 53: int _outpid; /* the child's process id */ ! 54: ! 55: /* ! 56: * pipeout --- open an output pipe to the specified program ! 57: */ ! 58: ! 59: pipeout(pgm, args) ! 60: char *pgm; ! 61: char *args; ! 62: { ! 63: register int i; ! 64: int pipedes[2]; ! 65: ! 66: pipe(pipedes); ! 67: if ((i = fork()) == 0) { ! 68: close(READ); ! 69: dup(pipedes[READ]); ! 70: closeall(); ! 71: execv(pgm, &args); ! 72: write(2, "no ", 3); ! 73: write(2, pgm, strlen(pgm)); ! 74: write(2, "\n", 1); ! 75: exit(1); ! 76: } ! 77: _outpid = i; ! 78: close(pipedes[READ]); ! 79: return(pipedes[WRITE]); ! 80: } ! 81: ! 82: ! 83: /* ! 84: * clear --- write zeros to the specified block of memory ! 85: */ ! 86: ! 87: clear(bp, len) ! 88: register char *bp; ! 89: register int len; ! 90: { ! 91: register long *lp; ! 92: ! 93: while (((unsigned)bp & (sizeof(long)-1)) && --len >= 0) ! 94: *bp++ = 0; ! 95: lp = (long *)bp; ! 96: while (len >= sizeof(long)) { ! 97: *lp++ = 0; ! 98: len -= sizeof(long); ! 99: } ! 100: bp = (char *)lp; ! 101: while (--len >= 0) ! 102: *bp++ = 0; ! 103: } ! 104: ! 105: ! 106: /* ! 107: * closeall --- close all open files (except stdin, stdout, stderr) ! 108: */ ! 109: ! 110: closeall() ! 111: { ! 112: extern errno; ! 113: register int i; ! 114: ! 115: for (i=3; i<15; ++i) ! 116: close(i); ! 117: errno = 0; ! 118: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.