summaryrefslogtreecommitdiff
path: root/src/config.h
blob: e71ccec66c80660fe735acdd054f5532facd6185 (plain)
    1 /**
    2  * A class to help with parsing standard config files
    3  *
    4  * Copyright (C) 2014 Aaron Ball
    5  *
    6  * This program is free software: you can redistribute it and/or modify
    7  * it under the terms of the GNU General Public License as published by
    8  * the Free Software Foundation, either version 3 of the License, or
    9  * (at your option) any later version.
   10  *
   11  * This program is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU General Public License
   17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   18  */
   19 #ifndef NOTELESS_CONFIG_H
   20 #define NOTELESS_CONFIG_H
   21 #define config_line_len 120
   22 #define config_max 256
   23 
   24 #include <stdlib.h>
   25 #include <stdio.h>
   26 #include <string.h>
   27 
   28 /**
   29  * Represents a config file in memory. Provides a friendly interface for
   30  * checking configuration variables without having to parse multiple times.
   31  */
   32 typedef struct config {
   33   int count;
   34   char path[256];
   35   char extension[16];
   36   char* keys[config_max];
   37   char* values[config_max];
   38 } config_t;
   39 
   40 int config_load(config_t*, char*);
   41 
   42 void config_free(config_t*);
   43 
   44 int config_isset(config_t*, char*);
   45 
   46 char* config_get(config_t*, char*);
   47 
   48 int config_set(config_t*, char*, char*);
   49 
   50 int config_valid_line_count(char*);
   51 
   52 int config_add(config_t*, char*, char*);
   53 
   54 #endif

Generated by cgit