1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
25 Configuration loader/storage.
27 Configuration is simple namespace,key -> value storage, the configuration
28 could either be loaded from config file and/or overriden by argumant parser.
36 /* Could be NULL for global values */
37 const char *name_space
;
40 /* Short command line option, i.e. -f */
42 /* Long command option, i.e. --foo */
44 /* set to 1 if option has parameter */
48 /* setter function, called for each parset key = val pair */
49 int (*set
)(struct cfg_opt
*self
, unsigned int lineno
);
50 /* pointer to pass value from parser */
55 * Loads configuration from a file.
57 * Returns zero on success, non-zero on failure (and prints error message into
60 int cfg_load(struct cfg_opt
*opts
, const char *path
);
63 * Parses configuration options from command line parameters.
65 * Returns number of used strings from argv on success, -1 on failure.
67 int cfg_getopt(struct cfg_opt
*opts
, int argc
, char *argv
[]);
70 * Prints help for switches.
72 void cfg_print_help(struct cfg_opt
*opts
);
75 * Prints man-page formatted options + config.
77 void cfg_print_man(struct cfg_opt
*opts
);
79 #endif /* __CFG_H__ */