File: option.h

package info (click to toggle)
polyglot 2.0.4-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster
  • size: 1,280 kB
  • sloc: ansic: 10,428; sh: 3,711; makefile: 18
file content (98 lines) | stat: -rw-r--r-- 3,052 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

// option.h

#ifndef OPTION_H
#define OPTION_H

// includes

#include "util.h"
#include "ini.h"

// defines

#define VarNb    16
#define XBOARD   (1<<0)
#define UCI      (1<<1)
#define PG       (1<<2)
#define XBSEL    (1<<3)
#define OptionNb 256

#define IS_BUTTON(str) (my_string_case_equal(str,"button") ||      \
                        my_string_case_equal(str,"save")   ||      \
                        my_string_case_equal(str,"reset"))         \

#define IS_SPIN(str)   (my_string_case_equal(str,"spin") ||        \
                        my_string_case_equal(str,"slider"))        \

#define IS_STRING(str) (my_string_case_equal(str,"string") ||      \
                        my_string_case_equal(str,"path")   ||      \
                        my_string_case_equal(str,"file"))          \

// types

typedef struct {   // TODO: put back in more logical order
    const char * name;
    const char * type;
    const char * min;
    const char * max;
    const char * default_;
    const char * value;
    int var_nb;
    const char * var[VarNb];
    int mode;
} option_t;

// all non NULL data in an option_list_t should be malloc'ed
// use "my_string_set" to fill it. 

typedef struct {
    option_t options[OptionNb];
    int option_nb;
    int iter;
} option_list_t;

// variables

extern option_list_t Option[1];

// functions


extern void         option_init         (option_list_t *option);

extern void         option_init_pg      ();

extern bool         option_set          (option_list_t *option,
                                         const char var[],
                                         const char val[]);
extern bool         option_set_default  (option_list_t *option,
                                         const char var[],
                                         const char val[]);

extern const char * option_get          (option_list_t *option, const char var[]);
extern const char * option_get_default  (option_list_t *option, const char var[]);

extern bool         option_get_bool     (option_list_t *option, const char var[]);
extern double       option_get_double   (option_list_t *option, const char var[]);
extern int          option_get_int      (option_list_t *option, const char var[]);
extern const char * option_get_string   (option_list_t *option, const char var[]);

extern void         option_from_ini     (option_list_t *option,
                                         ini_t *ini,
                                         const char *section);

extern bool         option_is_ok        (const option_list_t *option);
extern option_t *   option_find         (option_list_t *option, const char var[]);
extern void         option_clear        (option_list_t *option);
extern void         option_insert       (option_list_t *option, option_t *new_option);

extern void         option_start_iter   (option_list_t *option);
extern option_t *   option_next         (option_list_t *option);

extern void         option_free         (option_t *option);

#endif // !defined OPTION_H

// end of option.h