code: mafs

ref: 80e6c118c65b013bde24f8b9c95881c0e3a73d3e
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);
}