view sciwebd.c @ 2:5fa3d2f479b2

sci: initial upload support
author David Demelier <markand@malikania.fr>
date Thu, 10 Jun 2021 10:39:21 +0200
parents f1de39079243
children 3051ef92173a
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <stdnoreturn.h>
#include <unistd.h>

#include "http.h"
#include "log.h"

const char *sock = VARDIR "/run/sci.sock";

noreturn static void
usage(void)
{
	fprintf(stderr, "usage: %s [-f] [-s sock]\n", getprogname());
	exit(1);
}

static void
init(void)
{
	log_open(getprogname());
}

static void
finish(void)
{
	log_finish();
}

int
main(int argc, char **argv)
{
	int ch;
	void (*run)(void) = &(http_cgi_run);

	setprogname("sciwebd");

	while ((ch = getopt(argc, argv, "fs:")) != -1) {
		switch (ch) {
		case 'f':
			run = &(http_fcgi_run);
			break;
		case 's':
			sock = optarg;
			break;
		default:
			usage();
			break;
		}
	}

	init();
	run();
	finish();
}