loaders: PNG: Handle gamma on 16bpp conversion
[gfxprim.git] / demos / spiv / cfg.h
blob49107b7d1cf01f96eaec5aeab07f1b751c16c11a
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
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. *
8 * *
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. *
13 * *
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 *
18 * *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
20 * *
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.
32 #ifndef __CFG_H__
33 #define __CFG_H__
35 struct cfg_opt {
36 /* Could be NULL for global values */
37 const char *name_space;
38 /* Must be set */
39 const char *key;
40 /* Short command line option, i.e. -f */
41 const char opt;
42 /* Long command option, i.e. --foo */
43 const char *opt_long;
44 /* set to 1 if option has parameter */
45 int opt_has_value;
46 /* help string */
47 const char *help;
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 */
51 const char *val;
55 * Loads configuration from a file.
57 * Returns zero on success, non-zero on failure (and prints error message into
58 * stderr).
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__ */