+//----------------------------------------------------------------------------
+static PyMethodDef generic_methods[] =
+{
+ {NULL, NULL, 0, NULL}
+};
+static tag_internals_t generic_tag =
+{
+ parse: 0,
+ dealloc: 0,
+ fillTAG: 0,
+ tagfunctions: generic_methods,
+ datasize: 0,
+};
+//----------------------------------------------------------------------------
+
+static struct tag_parser {
+ int id;
+ tag_internals_t*spec;
+ struct tag_parser* next;
+} tag_parsers[1024];
+static char parsers_initialized = 0;
+
+void register_tag(int id, tag_internals_t*spec)
+{
+ assert(id>=0 && id<1024);
+ if(!parsers_initialized) {
+ memset(tag_parsers, 0, sizeof(tag_parsers));
+ parsers_initialized = 1;
+ }
+ tag_parsers[id].id = id;
+ tag_parsers[id].spec = spec;
+};
+
+static tag_internals_t* get_parser(int id)
+{
+ if(parsers_initialized<2) {
+ int t;
+ struct tag_parser*last = &tag_parsers[0];
+ for(t=0;t<1024;t++) {
+ if(tag_parsers[t].spec) {
+ last->next = &tag_parsers[t];
+ last = &tag_parsers[t];
+ }
+ }
+ parsers_initialized = 2;
+ }
+ assert(id>=0 && id<1024);
+ return tag_parsers[id].spec;
+}
+
+//----------------------------------------------------------------------------