💾 Archived View for gemini.thededem.de › lc19 › src › src › conf.c captured on 2021-12-03 at 14:04:38.

View Raw

More Information

-=-=-=-=-=-=-

/* Copyright 2020, 2021 Lukas Wedeking
 *
 * This file is part of LC19.
 *
 * LC19 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * LC19 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LC19.  If not, see <https://www.gnu.org/licenses/>.
 */

#define _XOPEN_SOURCE 500

#include "../include/conf.h"

#include<assert.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void
conf_init(int argc, char *argv[])
{
	extern struct Configuration configuration;
	extern enum Loglevel loglevel;

	for (int i = 0; i < argc; i++) {
		if (strncmp(argv[i], "--data-dir=", 11) == 0
				&& argv[i][11] != 0x0) {
			configuration.data_dir = argv[i] + 11;
		} else if (strncmp(argv[i], "--loglevel=info", 15) == 0
				&& argv[i][15] == 0x0) {
			loglevel = LOGLEVEL_INFO;
		} else if (strncmp(argv[i], "--loglevel=debug", 16) == 0
				&& argv[i][16] == 0x0) {
			loglevel = LOGLEVEL_DEBUG;
		}
	}
}