no preallocating if there's no state file
[syren.git] / src / syren_cfg.h
blob8709ac1de283908f1357504e7fd9ef2b4f22917b
1 /*
2 Syren -- a lightweight downloader for Linux/BSD/MacOSX
3 inspired by Axel Copyright 2001-2002 Wilmer van der Gaast
4 version 0.0.6 (atomic alien)
5 coded by Ketmar // Avalon Group
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License with
18 the Debian GNU/Linux distribution in file /usr/doc/copyright/GPL;
19 if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 Suite 330, Boston, MA 02111-1307 USA
23 Syren config engine
25 #ifndef _SYREN_CFG_H
26 #define _SYREN_CFG_H
29 #include "syren_common.h"
30 #include "syren_str.h"
31 #include "syren_msg.h"
34 #define SY_CI_ERROR -1
35 #define SY_CI_STRING 0
36 #define SY_CI_INT 1 /* only positive */
37 #define SY_CI_BOOL 2
40 typedef struct {
41 TSyKVList *opts;
42 } TSyCfg;
46 TSyCfg *SyCfgNew (void);
47 void SyCfgFree (TSyCfg *cfg);
48 void SyCfgClear (TSyCfg *cfg);
50 TSyResult SyCfgAddStrKey (TSyCfg *cfg, const char *kname, const char *kdescr, char **var);
51 TSyResult SyCfgAddBoolKey (TSyCfg *cfg, const char *kname, const char *kdescr, TSyBool *var);
52 TSyResult SyCfgAddIntKey (TSyCfg *cfg, const char *kname, const char *kdescr, int *var);
54 int SyCfgGetKeyType (const TSyCfg *cfg, const char *kname);
56 /* converts any key value to string */
57 char *SyCfgGetKeyValue (const TSyCfg *cfg, const char *kname);
58 /* converts string to any key value */
59 TSyResult SyCfgSetKeyValue (TSyCfg *cfg, const char *kname, const char *value);
62 TSyResult SyCfgSet (TSyCfg *cfg, const char *optline);
63 TSyResult SyCfgLoad (TSyCfg *cfg, const char *filename, const TSyPrintStr *pfn);
64 TSyResult SyCfgSave (const TSyCfg *cfg, const char *filename, const TSyPrintStr *pfn);
67 #endif