]> git.sur5r.net Git - cc65/blob - src/sim65/cfgdata.h
Added a warning if the result of a compare operation is constant. This should
[cc65] / src / sim65 / cfgdata.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 cfgdata.h                                 */
4 /*                                                                           */
5 /*                           Config data structure                           */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2002-2003 Ullrich von Bassewitz                                       */
10 /*               Römerstrasse 52                                             */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef CFGDATA_H
37 #define CFGDATA_H
38
39
40
41 /* common */
42 #include "coll.h"
43
44
45
46 /*****************************************************************************/
47 /*                                     Data                                  */
48 /*****************************************************************************/
49
50
51
52 typedef struct CfgData CfgData;
53 struct CfgData {
54     enum {
55         CfgDataInvalid,
56         CfgDataId,
57         CfgDataNumber,
58         CfgDataString
59     }           Type;           /* Type of the value */
60     union {
61         char*   SVal;           /* String or id value */
62         long    IVal;           /* Integer value */
63     } V;
64     unsigned    Line;           /* Line where the attribute was defined */
65     unsigned    Col;            /* Column of attribute definition */
66     char        Attr[1];        /* The attribute name */
67 };
68
69
70
71 /*****************************************************************************/
72 /*                                     Code                                  */
73 /*****************************************************************************/
74
75
76
77 CfgData* NewCfgData (void);
78 /* Create and intialize a new CfgData struct, then return it. The function
79  * uses the current output of the config scanner.
80  */
81
82 void FreeCfgData (CfgData* D);
83 /* Free a config data structure */
84
85 void CfgDataCheckType (const CfgData* D, unsigned Type);
86 /* Check the config data type and print an error message if it has the wrong
87  * type.
88  */
89
90 int CfgDataFind (const Collection* Attributes, const char* AttrName);
91 /* Find the attribute with the given name and return its index. Return -1 if
92  * the attribute was not found.
93  */
94
95 int CfgDataGetId (Collection* Attributes, const char* Name, char** Id);
96 /* Search CfgInfo for an attribute with the given name and type "id". If
97  * found, remove it from the configuration, copy it into Buf and return
98  * true. If not found, return false.
99  */
100
101 int CfgDataGetStr (Collection* Attributes, const char* Name, char** S);
102 /* Search CfgInfo for an attribute with the given name and type "string".
103  * If found, remove it from the configuration, copy it into Buf and return
104  * true. If not found, return false.
105  */
106
107 int CfgDataGetNum (Collection* Attributes, const char* Name, long* Val);
108 /* Search CfgInfo for an attribute with the given name and type "number".
109  * If found, remove it from the configuration, copy it into Val and return
110  * true. If not found, return false.
111  */
112
113
114
115 /* End of cfgdata.h */
116
117 #endif
118
119
120