shithub: neoventi

ref: a24a074bc3809078435fbcb45250967ec9a5891e
dir: /venti/main.c/

View raw version
#include "platform.h"
#include "dat.h"
#include "fns.h"

struct {
	char *file;
} params;

static inline char*
next(int argc, char **argv, int *i)
{
	if (*i + 1 == argc)
		sysfatal("Expected argument to '%s'!", argv[*i]);
	*i += 1;
	return argv[*i];
}

static void
initargs(void)
{
	params.file = "venti.conf";
}

static void
parseargs(int argc, char **argv)
{
	for(int i = 1; i < argc; i += 1){
		if(streql("-c", argv[i]))
			params.file = next(argc, argv, &i);
		else
			sysfatal("Unrecognized argument: '%s'", argv[i]);
	}
}

int
main(int argc, char **argv)
{
	initargs();
	parseargs(argc, argv);
	loadconfig(params.file);
	sysfatal("TODO: launch server");
	return 0;
}