#include "tag.h" #define HASHSIZE 161 static OptInfo *hashtab[HASHSIZE]; #define OPTINFO(tag) #tag,OPT_ ## tag, static OptInfo optinfo_table[] = { { OPTINFO(background) }, { OPTINFO(bgcolor) }, { OPTINFO(text) }, { OPTINFO(alink) }, { OPTINFO(link) }, { OPTINFO(vlink) }, { OPTINFO(name) }, { OPTINFO(type) }, { OPTINFO(start) }, { OPTINFO(size) }, { OPTINFO(color) }, { OPTINFO(noshade) }, { OPTINFO(width) }, { OPTINFO(height) }, { OPTINFO(compact) }, { OPTINFO(href) }, { OPTINFO(src) }, { OPTINFO(lowsrc) }, { OPTINFO(alt) }, { OPTINFO(border) }, { OPTINFO(hspace) }, { OPTINFO(vspace) }, { OPTINFO(align) }, { OPTINFO(valign) }, { OPTINFO(method) }, { OPTINFO(action) }, { OPTINFO(value) }, { OPTINFO(maxlength) }, { OPTINFO(checked) }, { OPTINFO(multiple) }, { OPTINFO(selected) }, { OPTINFO(rows) }, { OPTINFO(cols) }, { OPTINFO(cellpadding) }, { OPTINFO(cellspacing) }, { OPTINFO(nowrap) }, { OPTINFO(rowspan) }, { OPTINFO(colspan) }, { OPTINFO(left) }, { OPTINFO(center) }, { OPTINFO(right) }, { OPTINFO(top) }, { OPTINFO(bottom) }, { OPTINFO(middle) }, { OPTINFO(absmiddle) }, { OPTINFO(clear) }, { OPTINFO(all) }, { OPTINFO(none) }, { OPTINFO(disc) }, { OPTINFO(square) }, { OPTINFO(circle) }, { OPTINFO(id) }, { OPTINFO(class) }, { NULL, 0, NULL, } }; static u_int hash(char *s) { u_int hashval; for (hashval = 0; *s != '\0'; s++) hashval = *s + 31*hashval; return hashval % HASHSIZE; } OptInfo* GetOptInfo(char *s) { OptInfo *p; for (p = hashtab[hash(s)]; p != NULL; p = p->next) if (strcmp(s, p->name) == 0) return p; return NULL; } void InitOptInfo(void) { OptInfo *p; u_int hashval; for (p = optinfo_table; p->name != NULL; p++) { hashval = hash(p->name); p->next = hashtab[hashval]; hashtab[hashval] = p; } }