|
|
1.1 ! root 1: /* getcwd.c ! 2: Replacement for the getcwd function that just calls /bin/pwd. */ ! 3: ! 4: #include "uucp.h" ! 5: ! 6: #include "sysdep.h" ! 7: ! 8: #include <errno.h> ! 9: ! 10: char * ! 11: getcwd (zbuf, cbuf) ! 12: char *zbuf; ! 13: size_t cbuf; ! 14: { ! 15: const char *azargs[2]; ! 16: FILE *e; ! 17: pid_t ipid; ! 18: int cread; ! 19: int ierr; ! 20: ! 21: azargs[0] = PWD_PROGRAM; ! 22: azargs[1] = NULL; ! 23: e = espopen (azargs, TRUE, &ipid); ! 24: if (e == NULL) ! 25: return NULL; ! 26: ! 27: ierr = 0; ! 28: ! 29: cread = fread (zbuf, sizeof (char), cbuf, e); ! 30: if (cread == 0) ! 31: ierr = errno; ! 32: ! 33: (void) fclose (e); ! 34: ! 35: if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0) ! 36: { ! 37: ierr = EACCES; ! 38: cread = 0; ! 39: } ! 40: ! 41: if (cread != 0) ! 42: { ! 43: if (zbuf[cread - 1] == '\n') ! 44: zbuf[cread - 1] = '\0'; ! 45: else ! 46: { ! 47: ierr = ERANGE; ! 48: cread = 0; ! 49: } ! 50: } ! 51: ! 52: if (cread == 0) ! 53: { ! 54: errno = ierr; ! 55: return NULL; ! 56: } ! 57: ! 58: return zbuf; ! 59: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.