/** * A class to help with parsing standard config files * * Copyright (C) 2016 Aaron Ball * * This program 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. * * This program 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 this program. If not, see . */ #ifndef NOTELESS_CONFIG_H #define NOTELESS_CONFIG_H #define config_line_len 120 #define config_max 256 #include #include #include /** * Represents a config file in memory. Provides a friendly interface for * checking configuration variables without having to parse multiple times. */ typedef struct config { int count; char path[256]; char extension[16]; char* keys[config_max]; char* values[config_max]; } config_t; int config_load(config_t*, char*); void config_free(config_t*); int config_isset(config_t*, char*); char* config_get(config_t*, char*); int config_set(config_t*, char*, char*); int config_valid_line_count(char*); int config_add(config_t*, char*, char*); #endif