code: mafs

ref: 0325bdc87b12a33c16b792c6ed50400b8ffce325
dir: /tests/testconfig.c/

View raw version
#include <u.h>
#include <libc.h>
#include "../dat.h"

/*
	test the config parser
	awk 'BEGIN{p=0}; p==1{print $0}; $1=="mode"{p=1};' test.0/blocks/2 | ./6.testconfig
	disk/block /dev/sdF1/fs 2 | awk 'BEGIN{p=0}; p==1{print $0}; $1=="mode"{p=1};' | ./6.testconfig
 */

int chatty9p = 0;
Config config = {0};
char	service[Servicelen] = "testcofig";

static void
usage(void)
{
	fprint(2, "usage: parseconfig [-D ]\n");
	exits("usage");
}

void
main(int argc, char *argv[])
{
	s8 buf[Ddatasize];
	Errenv env;

	envpp = privalloc();
	envpidx = _nprivates;	/* the index in _privates holding the Errenv location */
	*envpp = &env;
	if(waserror()){
		print(0, "err stack %d: %lux %lux %lux %lux %lux %lux",
			env.nlabel,
			env.label[0][JMPBUFPC], env.label[1][JMPBUFPC],
			env.label[2][JMPBUFPC], env.label[3][JMPBUFPC],
			env.label[4][JMPBUFPC], env.label[5][JMPBUFPC]);
		exits("error");
	}

	ARGBEGIN{
	default:	usage();
	case 'D':	chatty9p=2; break;
	}ARGEND

	if(argc != 0)
		usage();

	chatty9p=2;
	readn(0, buf, Ddatasize);
	parseconfig(buf, &config);
	exits(nil);
}