/* pwd.ccc -- Misosys C program to print the Unix working directory of xtrs */
/* Copyright (c) 1998, Timothy Mann */
/* $Id: pwd.ccc,v 1.3 2008/06/26 04:39:56 mann Exp $ */

/* This software may be copied, modified, and used for any purpose
 * without fee, provided that (1) the above copyright notice is
 * retained, and (2) modified versions are clearly marked as having
 * been modified, with the modifier's name and the date included.  */

#option redirect 0
#include "xtrsemt.h"
#include "xtrsemt.ccc"  /* could use separate compilation instead */

usage()
{
    fprintf(stderr, "usage: pwd\n");
    exit(1);
}

#define ERRBUFSIZE 256
#define DIRBUFSIZE 512

int main(argc, argv)
     int argc;
     char **argv;
{
    int i;
    char *ret;
    char errbuf[ERRBUFSIZE];
    char dirbuf[DIRBUFSIZE];
    if (argc != 1) {
	usage();
    }
    ret = emt_getcwd(dirbuf, DIRBUFSIZE);
    if (ret == NULL) {
	emt_strerror(errno, errbuf, ERRBUFSIZE);
	fprintf(stderr, "pwd: %s\n", errbuf);
	exit(1);
    }
    printf("%s\n", dirbuf);
    exit(0);
}
