X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fsp65%2Fattr.h;h=9a4f834fb161bd6e7c2518d560faf32ab034a19a;hb=35e1184901ca38bdb2e56d154ed3b71f6096eacc;hp=3d81cbf50642c2666cc094c3059b5b096a261b5a;hpb=594e446ac50faffab39159b5ffe4a68e12357db8;p=cc65 diff --git a/src/sp65/attr.h b/src/sp65/attr.h index 3d81cbf50..9a4f834fb 100644 --- a/src/sp65/attr.h +++ b/src/sp65/attr.h @@ -49,19 +49,11 @@ -/* Attribute flags */ -enum AttrFlags { - afNone, - afInt, /* Integer number */ -}; -typedef enum AttrFlags AttrFlags; - -/* */ +/* Attribute structure */ typedef struct Attr Attr; struct Attr { - AttrFlags Flags; /* Attribute flags */ - char* Name; /* Attribute name */ - char Value[1]; /* Attribute value */ + char* Name; /* Attribute name - points into Value */ + char Value[1]; /* Attribute value followed by Name */ }; @@ -75,6 +67,9 @@ struct Attr { Attr* NewAttr (const char* Name, const char* Value); /* Create a new attribute */ +void FreeAttr (Attr* A); +/* Free an attribute structure */ + void DumpAttrColl (const Collection* C); /* Dump a collection of attribute/value pairs for debugging */ @@ -85,6 +80,28 @@ int FindAttr (const Collection* C, const char* Name, unsigned* Index); * will contain the insert position. */ +const Attr* GetAttr (const Collection* C, const char* Name); +/* Search for an attribute with the given name and return it. The function + * returns NULL if the attribute wasn't found. + */ + +const Attr* NeedAttr (const Collection* C, const char* Name, const char* Op); +/* Search for an attribute with the given name and return it. If the attribute + * is not found, the function terminates with an error using Op as additional + * context in the error message. + */ + +const char* GetAttrVal (const Collection* C, const char* Name); +/* Search for an attribute with the given name and return its value. The + * function returns NULL if the attribute wasn't found. + */ + +const char* NeedAttrVal (const Collection* C, const char* Name, const char* Op); +/* Search for an attribute with the given name and return its value. If the + * attribute wasn't not found, the function terminates with an error using + * Op as additional context in the error message. + */ + void AddAttr (Collection* C, const char* Name, const char* Value); /* Add an attribute to an alphabetically sorted attribute collection */ @@ -94,6 +111,16 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name); * Name is NULL, terminate with an error. */ +Collection* ParseAttrList (const char* List, const char** NameList, unsigned NameCount); +/* Parse a list containing name/value pairs into a sorted collection. Some + * attributes may not need a name, so NameList contains these names. If there + * were no errors, the function returns a alphabetically sorted collection + * containing Attr entries. + */ + +void FreeAttrList (Collection* C); +/* Free a list of attributes */ + /* End of attr.h */