xref: /csrg-svn/usr.bin/uucp/port/getwd.c (revision 48654)
1*48654Sbostic /*-
2*48654Sbostic  * Copyright (c) 1985 The Regents of the University of California.
3*48654Sbostic  * All rights reserved.
4*48654Sbostic  *
5*48654Sbostic  * %sccs.include.proprietary.c%
6*48654Sbostic  */
7*48654Sbostic 
813656Ssam #ifndef lint
9*48654Sbostic static char sccsid[] = "@(#)getwd.c	5.6 (Berkeley) 04/24/91";
10*48654Sbostic #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 *
2223605Sbloom getwd(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