Mercurial > sci
view sciworkerd/main.c @ 19:de4bf839b565
misc: revamp SQL
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 15 Jul 2022 11:11:48 +0200 |
parents | 600204c31bf0 |
children | 2cb228f23f53 |
line wrap: on
line source
/* * sciworkerd.c -- main sciworkerd(8) program file * * Copyright (c) 2021 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 "sciworkerd.h" static void env(void) { const char *env; if ((env = getenv("SCI_URL"))) snprintf(sciworkerd.url, sizeof (sciworkerd.url), "%s", optarg); if ((env = getenv("SCI_WORKER"))) snprintf(sciworkerd.name, sizeof (sciworkerd.name), "%s", optarg); } int main(int argc, char **argv) { int ch, val; env(); opterr = 0; while ((ch = getopt(argc, argv, "j:t:u:w:")) != -1) { switch (ch) { case 'j': if ((val = atoi(optarg)) > 0) sciworkerd.maxjobs = val; break; case 't': if ((val = atoi(optarg)) > 0) sciworkerd.timeout = val; break; case 'u': snprintf(sciworkerd.url, sizeof (sciworkerd.url), "%s", optarg); break; case 'w': snprintf(sciworkerd.name, sizeof (sciworkerd.name), "%s", optarg); break; default: break; } } }