view th_config.h @ 322:b9c15c57dc8f

Clean up message functions, add new printMsgQ() helper function for messages that should not go into the log file. Add skeleton help function, accessible via F1 key. And other cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 11 Jun 2011 09:48:26 +0300
parents 0db02b8d2d11
children
line wrap: on
line source

/*
 * Very simple configuration file handling
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2004-2008 Tecnic Software productions (TNSP)
 *
 * Please read file 'COPYING' for information on license and distribution.
 */
#ifndef _TH_CONFIG_H
#define _TH_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

#include "th_util.h"
#include <stdio.h>


/* Definitions
 */
enum ITEM_TYPE {
    ITEM_SECTION = 1,
    ITEM_COMMENT,
    ITEM_STRING,
    ITEM_INT,
    ITEM_UINT,
    ITEM_BOOL,
    ITEM_FLOAT,
    ITEM_HEX_TRIPLET,

    ITEM_STRING_LIST,
    ITEM_HEX_TRIPLET_LIST
};


typedef struct _cfgitem_t {
    int  type;
    char *name;
    union {
        int *val_int;
        unsigned int *val_uint;
        char **val_str;
        BOOL *val_bool;

        void *data;
        qlist_t **list;
        struct _cfgitem_t *section;
    } v;
    
    struct _cfgitem_t *next, *prev;
} cfgitem_t;


/* Functions
 */
int     th_cfg_read(FILE *, char *, cfgitem_t *);
void    th_cfg_free(cfgitem_t *);
int     th_cfg_write(FILE *, char *, cfgitem_t *);

int     th_cfg_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data);
int     th_cfg_add_comment(cfgitem_t **cfg, char *comment);
int     th_cfg_add_int(cfgitem_t **cfg, char *name, int *data, int itemDef);
int     th_cfg_add_uint(cfgitem_t **cfg, char *name, unsigned int *data, unsigned int itemDef);
int     th_cfg_add_string(cfgitem_t **cfg, char *name, char **data, char *itemDef);
int     th_cfg_add_bool(cfgitem_t **cfg, char *name, BOOL *data, BOOL itemDef);
int     th_cfg_add_float(cfgitem_t **cfg, char *name, float *data, float itemDef);
int     th_cfg_add_hexvalue(cfgitem_t **cfg, char *name, int *data, int itemDef);

int     th_cfg_add_string_list(cfgitem_t **cfg, char *name, qlist_t **list);

#ifdef __cplusplus
}
#endif
#endif /* _TH_CONFIG_H */