FIX: lutil_quvi_init: Pass handle value to quvi_errmsg
[quvi-tool.git] / src / opts / lopts.h
blob187e01ca644a8be00e9d44633c7f8acea3ce4a7d
1 /* quvi
2 * Copyright (C) 2012,2013 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of quvi <http://quvi.sourceforge.net/>.
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #ifndef lopts_h
22 #define lopts_h
24 /* callback */
26 typedef void (*lopts_cb_parse_keyfile_values)(GKeyFile*,const gchar*);
27 typedef gchar *(*lopts_cb_get_config_fpath)();
29 typedef gint (*lopts_cb_cmdline_validate_values)();
30 typedef void (*lopts_cb_set_post_parse_defaults)();
32 typedef gint (*lopts_cb_chk_ok_strv)(const gchar*,
33 const gchar*,
34 const gchar**,
35 const gchar**);
37 typedef gint (*lopts_cb_chk_ok_re)(const gchar*,
38 const gchar*,
39 const gchar**);
41 typedef gint (*lopts_cb_chk_ok_str)(const gchar*,
42 const gchar*,
43 const gchar*,
44 const gchar**);
46 typedef gint (*lopts_cb_chk_ok_int)(const gchar*,
47 const gchar*,
48 const gint);
50 /* struct */
52 struct lopts_s
54 const GOptionEntry *entries;
55 gchar **argv;
56 gint argc;
57 struct
59 lopts_cb_cmdline_validate_values cmdline_validate_values;
60 lopts_cb_set_post_parse_defaults set_post_parse_defaults;
61 lopts_cb_parse_keyfile_values parse_keyfile_values;
62 lopts_cb_get_config_fpath get_config_fpath;
63 } cb;
66 typedef struct lopts_s *lopts_t;
68 /* function */
70 gint lopts_new(lopts_t);
72 gint lopts_chk_strv(const gchar**, const gchar**, gchar**);
73 gint lopts_chk_str(const gchar*, const gchar**, gchar**);
74 gint lopts_chk_re(const gchar**, gchar**);
76 gchar *lopts_keyfile_get_str(GKeyFile*,
77 lopts_cb_chk_ok_str,
78 const gchar*,
79 const gchar*,
80 const gchar**,
81 const gchar*,
82 gchar **dst);
84 gchar **lopts_keyfile_get_strv(GKeyFile*,
85 lopts_cb_chk_ok_strv,
86 const gchar*,
87 const gchar*,
88 const gchar**,
89 const gchar*,
90 gchar***);
92 gchar **lopts_keyfile_get_re(GKeyFile*,
93 lopts_cb_chk_ok_re,
94 const gchar*,
95 const gchar*,
96 const gchar**,
97 const gchar*,
98 gchar***);
100 gboolean lopts_keyfile_get_bool(GKeyFile*,
101 const gchar*,
102 const gchar*,
103 const gchar*,
104 gboolean*);
106 gint lopts_keyfile_get_double(GKeyFile*,
107 lopts_cb_chk_ok_int,
108 const gchar*,
109 const gchar*,
110 const gchar*,
111 gdouble*);
113 gint lopts_keyfile_get_int(GKeyFile*,
114 lopts_cb_chk_ok_int,
115 const gchar*,
116 const gchar*,
117 const gchar*,
118 gint*);
120 gint lopts_invalid_value(const gchar*, const gchar*,
121 const gchar*, const gchar**);
123 void lopts_print_config_values(lopts_t);
124 void lopts_print_config_paths(lopts_t);
126 #endif /* lopts_h */
128 /* vim: set ts=2 sw=2 tw=72 expandtab: */