-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
bools.h
62 lines (44 loc) · 1.71 KB
/
bools.h
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
/* $Id: bools.h,v 1.2 2006-03-31 01:29:02 megastep Exp $ */
/*
Manage global installer booleans.
Author: Stephane Peter
*/
#ifndef __LOKI_BOOLS_H__
#define __LOKI_BOOLS_H__
/* Type definitions */
typedef struct _setup_bool {
char *name; /* Symbolic name */
char *script; /* A script to be run to determine the value, or NULL */
char *envvar; /* An environment variable to set with the value, if any */
unsigned value : 1; /* Boolean value */
unsigned once : 1; /* Whether the script has to be run every time the bool is evaluated, or just upon init */
unsigned inited : 1; /* Value was filled in */
struct _setup_bool *next;
} setup_bool;
/* Private type */
struct _setup_expression;
typedef struct _setup_expression setup_expression;
/* Exported list of booleans */
extern setup_bool *setup_booleans;
/**** API functions *******/
/* Fill up with standard booleans */
void setup_init_bools(install_info *);
/* Create and free booleans */
setup_bool *setup_new_bool(const char *name);
void setup_free_bool(setup_bool *);
/* Easy add of simple new bools */
setup_bool *setup_add_bool(const char *name, unsigned value);
/* Manipulate booleans */
setup_bool *setup_find_bool(const char *name);
int setup_get_bool(setup_bool *b);
void setup_set_bool(setup_bool *b, unsigned value);
/* Handle expressions */
setup_expression *setup_parse_expression(const char *expr);
void setup_free_expression(setup_expression *);
/* Evaluate the expression - returns TRUE or FALSE */
int setup_evaluate(setup_expression *);
/* Easy shortcut to evaluate an expression string */
int match_condition(const char *expr);
/* Free up all memory */
void setup_exit_bools(void);
#endif