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