diff th_config.h @ 70:a0e1b29be35d

Refactor configuration file handling module rather thoroughly. The API is broken by these changes.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 15 Nov 2012 19:32:00 +0200
parents 28156333ef4c
children 50006067bcd1
line wrap: on
line diff
--- a/th_config.h	Thu Nov 15 19:22:42 2012 +0200
+++ b/th_config.h	Thu Nov 15 19:32:00 2012 +0200
@@ -12,8 +12,7 @@
 extern "C" {
 #endif
 
-#include "th_util.h"
-#include <stdio.h>
+#include "th_ioctx.h"
 
 
 /* Definitions
@@ -34,7 +33,8 @@
 };
 
 
-typedef struct _cfgitem_t {
+typedef struct _th_cfgitem_t
+{
     int  type;
     char *name;
     union {
@@ -45,29 +45,30 @@
 
         void *data;
         qlist_t **list;
-        struct _cfgitem_t *section;
+        struct _th_cfgitem_t *section;
     } v;
     
-    struct _cfgitem_t *next, *prev;
-} cfgitem_t;
+    struct _th_cfgitem_t *next, *prev;
+} th_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_read(th_ioctx_t *, th_cfgitem_t *);
+void    th_cfg_free(th_cfgitem_t *);
+int     th_cfg_write(th_ioctx_t *, const th_cfgitem_t *);
+
+int     th_cfg_add_section(th_cfgitem_t **cfg, const char *name, th_cfgitem_t *data);
+int     th_cfg_add_comment(th_cfgitem_t **cfg, const char *comment);
 
-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_int(th_cfgitem_t **cfg, const char *name, int *data, int itemDef);
+int     th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int itemDef);
+int     th_cfg_add_string(th_cfgitem_t **cfg, const char *name, char **data, char *itemDef);
+int     th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *data, BOOL itemDef);
+int     th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float itemDef);
+int     th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, int *data, int itemDef);
+int     th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, qlist_t **list);
 
-int     th_cfg_add_string_list(cfgitem_t **cfg, char *name, qlist_t **list);
 
 #ifdef __cplusplus
 }