7354bc4da7ee280175841d31fb69b575bcd1b87f
[libfirm] / ir / libcore / lc_opts_t.h
1 /*
2   libcore: library for basic data structures and algorithms.
3   Copyright (C) 2005  IPD Goos, Universit"at Karlsruhe, Germany
4
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public
16   License along with this library; if not, write to the Free Software
17   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20
21
22 #ifndef _OPTS_T_H
23 #define _OPTS_T_H
24
25 #include <stdlib.h>
26
27 #include "lc_opts.h"
28 #include "list.h"
29
30 #include "lc_common_t.h"
31 #include "lc_defines.h"
32
33 typedef struct {
34         struct list_head opts;
35         struct list_head grps;
36 } lc_grp_special_t;
37
38 typedef struct {
39         lc_opt_type_t type;
40         lc_opt_callback_t *cb;
41         lc_opt_dump_t *dump;
42         lc_opt_dump_vals_t *dump_vals;
43         void *value;
44         size_t length;
45         unsigned is_set : 1;
46 } lc_opt_special_t;
47
48 struct _lc_opt_entry_t {
49         unsigned hash;
50         const char *name;
51         const char *desc;
52         struct _lc_opt_entry_t *parent;
53
54         unsigned is_grp : 1;
55
56         struct list_head list;
57
58         union {
59                 lc_grp_special_t grp;
60                 lc_opt_special_t opt;
61         } v;
62 };
63
64 #define lc_get_opt_special(ent) (&(ent)->v.opt)
65 #define lc_get_grp_special(ent) (&(ent)->v.grp)
66
67 int lc_opt_raise_error(const lc_opt_err_info_t *err,
68                                            lc_opt_error_handler_t *handler,
69                                            const char *fmt, ...);
70
71 #endif