148654Sbostic /*- 2*62391Sbostic * Copyright (c) 1985, 1993 3*62391Sbostic * The Regents of the University of California. All rights reserved. 448654Sbostic * 548654Sbostic * %sccs.include.proprietary.c% 648654Sbostic */ 748654Sbostic 813656Ssam #ifndef lint 9*62391Sbostic static char sccsid[] = "@(#)getwd.c 8.1 (Berkeley) 06/06/93"; 1048654Sbostic #endif /* not lint */ 1113656Ssam 1213656Ssam #include "uucp.h" 1313656Ssam 1417835Sralph /* 1517835Sralph * get working directory 1613656Ssam * 1723605Sbloom * return codes 0 = FAIL 1823605Sbloom * wkdir = SUCCES 1913656Ssam */ 2013656Ssam 2123605Sbloom char * getwd(wkdir)2223605Sbloomgetwd(wkdir) 2313656Ssam register char *wkdir; 2413656Ssam { 2513656Ssam register FILE *fp; 2613656Ssam extern FILE *rpopen(); 2713656Ssam extern int rpclose(); 2813656Ssam register char *c; 2913656Ssam 3013656Ssam *wkdir = '\0'; 3144709Strent if ((fp = rpopen("PATH=/bin:/usr/bin;pwd 2>&-", "r")) == NULL) 3223605Sbloom return 0; 3317835Sralph if (fgets(wkdir, 100, fp) == NULL) { 3417835Sralph rpclose(fp); 3523605Sbloom return 0; 3613656Ssam } 3713656Ssam if (*(c = wkdir + strlen(wkdir) - 1) == '\n') 3813656Ssam *c = '\0'; 3913656Ssam rpclose(fp); 4023605Sbloom return wkdir; 4113656Ssam } 42