#include <u.h>
#include <libc.h>
#define NODEFINE
#include <9pm/u.h>
#include <9pm/libc.h>
#include <9pm/ns.h>

static int pm_debug_flags[256];

void
main(int argc, char **argv)
{
	char *s, *os, wd[256];
	Proc *p;

	p = pm_getproc();
	p->err = p->errbuf0;

	pm_conf.osname = "plan 9";
	pm_conf.ostype = PmOsPlan9;
	pm_conf.eve = getuser();
	pm_conf.rootdir = "/";

	pm_debug_flags['a'] = ~0;
	pm_debug_flags['n'] = PmDebugNs;
	pm_debug_flags['f'] = PmDebugFd;
	pm_debug_flags['x'] = PmDebugExit;
	pm_debug_flags['X'] = PmDebugExec;
	pm_debug_flags['N'] = PmDebugNote;
	pm_debug_flags['w'] = PmDebugWait;

	if(s = getenv("9pmdebug")){
		os = s;
		for(; *s; s++)
			pm_debug |= pm_debug_flags[(uchar)*s];
		free(os);
	}

	pm_nsinit();	/* sets up #/, #d, #U, maybe others */
	getwd(wd, sizeof wd);
	p->dot = pm_namec(wd, Atodir, 0, 0);
	pm_main(argc, argv);
	exits(nil);
}
