2002-11-20 17:04:29 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* */
|
|
|
|
|
/* cfgdata.h */
|
|
|
|
|
/* */
|
|
|
|
|
/* Config data structure */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
2003-04-27 11:49:53 +00:00
|
|
|
|
/* (C) 2002-2003 Ullrich von Bassewitz */
|
|
|
|
|
/* R<>merstrasse 52 */
|
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
|
/* EMail: uz@cc65.org */
|
2002-11-20 17:04:29 +00:00
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
|
/* */
|
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
|
/* */
|
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
|
/* distribution. */
|
|
|
|
|
/* */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef CFGDATA_H
|
|
|
|
|
#define CFGDATA_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-04-28 20:23:45 +00:00
|
|
|
|
/* common */
|
|
|
|
|
#include "coll.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-11-20 17:04:29 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Data */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct CfgData CfgData;
|
|
|
|
|
struct CfgData {
|
|
|
|
|
enum {
|
2003-04-27 11:49:53 +00:00
|
|
|
|
CfgDataInvalid,
|
|
|
|
|
CfgDataId,
|
|
|
|
|
CfgDataNumber,
|
2003-04-28 20:23:45 +00:00
|
|
|
|
CfgDataString
|
2002-11-20 17:04:29 +00:00
|
|
|
|
} Type; /* Type of the value */
|
|
|
|
|
union {
|
|
|
|
|
char* SVal; /* String or id value */
|
|
|
|
|
long IVal; /* Integer value */
|
|
|
|
|
} V;
|
2003-04-27 11:49:53 +00:00
|
|
|
|
unsigned Line; /* Line where the attribute was defined */
|
|
|
|
|
unsigned Col; /* Column of attribute definition */
|
|
|
|
|
char Attr[1]; /* The attribute name */
|
2002-11-20 17:04:29 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-04-28 20:23:45 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Code */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CfgData* NewCfgData (void);
|
|
|
|
|
/* Create and intialize a new CfgData struct, then return it. The function
|
|
|
|
|
* uses the current output of the config scanner.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void FreeCfgData (CfgData* D);
|
|
|
|
|
/* Free a config data structure */
|
|
|
|
|
|
|
|
|
|
int CfgDataFind (Collection* Attributes, const char* AttrName);
|
|
|
|
|
/* Find the attribute with the given name and return its index. Return -1 if
|
|
|
|
|
* the attribute was not found.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int CfgDataGetId (Collection* Attributes, const char* Name, char** Id);
|
|
|
|
|
/* Search CfgInfo for an attribute with the given name and type "id". If
|
|
|
|
|
* found, remove it from the configuration, copy it into Buf and return
|
|
|
|
|
* true. If not found, return false.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int CfgDataGetStr (Collection* Attributes, const char* Name, char** S);
|
|
|
|
|
/* Search CfgInfo for an attribute with the given name and type "string".
|
|
|
|
|
* If found, remove it from the configuration, copy it into Buf and return
|
|
|
|
|
* true. If not found, return false.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int CfgDataGetNum (Collection* Attributes, const char* Name, long* Val);
|
|
|
|
|
/* Search CfgInfo for an attribute with the given name and type "number".
|
|
|
|
|
* If found, remove it from the configuration, copy it into Val and return
|
|
|
|
|
* true. If not found, return false.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-11-20 17:04:29 +00:00
|
|
|
|
/* End of cfgdata.h */
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|