1 /*
2   Copyright (c) 2002-2005, Miguel Mendez. All rights reserved.
3   * Copyright (c) 2015, Chris Hutchinson. All rights reserved.
4 
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions are met:
7 
8   * Redistributions of source code must retain the above copyright notice,
9   this list of conditions and the following disclaimer.
10   * Redistributions in binary form must reproduce the above copyright notice,
11   this list of conditions and the following disclaimer in the documentation
12   and/or other materials provided with the distribution.
13 
14   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25   $Id: parser.h 46 2015-11-09 11:42:33Z chrish $
26 
27 */
28 
29 #ifndef PARSER_H
30 #define PARSER_H
31 
32 typedef struct rc_node {
33 
34   char name[255];
35   char value[255];
36   char orig[255];
37   char comment[255];
38   int user_comment;
39   int user_added;
40   int modified;
41   int knob;
42   int knob_val;
43   int knob_orig;
44   struct rc_node *next;
45 
46 } RC_NODE;
47 
48 typedef struct rc_conf {
49 
50   RC_NODE *knobs_ptr;
51   int      knobs_size;
52   RC_NODE *string_ptr;
53   int      string_size;
54 
55 } RC_CONF;
56 
57 
58 #if defined(__FreeBSD__) || defined(__DragonFly__)
59 #define KNOB_YES "\"YES\""
60 #define KNOB_NO "\"NO\""
61 #elif defined(__NetBSD__)
62 #define KNOB_YES "YES"
63 #define KNOB_NO "NO"
64 #endif
65 
66 #define KNOB_IS_YES 1
67 #define KNOB_IS_NO 0
68 #define IS_KNOB 1
69 #define NOT_KNOB 0
70 #define MODIFIED_NO 0
71 #define MODIFIED_YES 1
72 
73 #define USER_ADDED_YES 0xEE
74 #define USER_ADDED_NO 0
75 
76 int build_list(char *, RC_CONF *);
77 int merge_lists(RC_CONF *, RC_CONF *);
78 
79 void list_sort(RC_NODE *, int);
80 
81 #endif
82