view scid/main.c @ 33:1d0ddf9e6efd

misc: general documentation
author David Demelier <markand@malikania.fr>
date Thu, 04 Aug 2022 16:47:10 +0200
parents 081e1c258e64
children 319979427566
line wrap: on
line source

/*
 * scid.c -- main scid(8) program file
 *
 * Copyright (c) 2021-2022 David Demelier <markand@malikania.fr>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

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

#include "http.h"
#include "scid.h"
#include "util.h"

static void
usage(void)
{
	fprintf(stderr, "usage: scid [-d database] [-s sock] [-t themedir]\n");
	exit(1);
}

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

	while ((ch = getopt(argc, argv, "d:ft:")) != -1) {
		switch (ch) {
		case 'd':
			util_strlcpy(scid.dbpath, optarg, sizeof (scid.dbpath));
			break;
		case 'f':
			run = &(http_fcgi_run);
			break;
		case 't':
			util_strlcpy(scid.themedir, optarg, sizeof (scid.themedir));
			break;
		default:
			usage();
			break;
		}
	}

	argc -= optind;
	argv += optind;

	scid_init();
	run();
	scid_finish();
}