/*
 * 5799-WZQ (C) COPYRIGHT = NONE
 * LICENSED MATERIALS - PROPERTY OF IBM
 */
/* $Header:getwd.c 12.0$ */
/* $ACIS:getwd.c 12.0$ */
/* $Source: /ibm/acis/usr/src/usr.bin/uucp/RCS/getwd.c,v $ */

#ifndef lint
static char *rcsid = "$Header:getwd.c 12.0$";
#endif

#ifndef lint
static char sccsid[] = "@(#)getwd.c	5.4 (Berkeley) 6/19/85";
#endif

#include "uucp.h"

/*
 *	get working directory
 *
 *	return codes  0 = FAIL
 *		      wkdir = SUCCES
 */

char *
getwd(wkdir)
register char *wkdir;
{
	register FILE *fp;
	extern FILE *rpopen();
	extern int rpclose();
	register char *c;

	*wkdir = '\0';
	if ((fp = rpopen("PATH=/bin:/usr/bin:/usr/ucb;pwd 2>&-", "r")) == NULL)
		return 0;
	if (fgets(wkdir, 100, fp) == NULL) {
		rpclose(fp);
		return 0;
	}
	if (*(c = wkdir + strlen(wkdir) - 1) == '\n')
		*c = '\0';
	rpclose(fp);
	return wkdir;
}
