code: mafs

ref: a6e9ab0ced8523fb8099afa4547dc27793e27462
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[Namelen] = "testcofig";

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

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

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

	if(argc != 0)
		usage();

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