#include "tag.h" static Rectype rtypetab[] = { {"COMM", Rcomment}, {"TXXX", Runimplemented}, {"COM", Rcomment}, {"TXX", Runimplemented}, }; static Recfields rfieldstab[] = { {Rcomment, pcomment, {Fenc, Flang, Fstring, Fstrings}}, {Rtext, ptext, {Fenc, Fstrings}}, }; Enc enctab[] = { [E8859] {"8859-1", 1, 0x00}, [Eutf16le] {"utf-16le", 2, 0x00, 0x00}, [Eutf16be] {"utf-16be", 2, 0x00, 0x00}, [Eutf] {"utf", 1, 0x00}, }; int rectype(char *id) { Rectype *rt; for(rt=rtypetab; rt < rtypetab + nelem(rtypetab); rt++) { if(cistrcmp(id, rt->id) == 0) return rt->type; } if(id[0] == 'T') return Rtext; return -1; } Recpacker recpacker(int rtype) { Recfields *rf; for(rf=rfieldstab; rf < rfieldstab + nelem(rfieldstab); rf++) { if(rf->type == rtype) return rf->pack; } abort(); return nil; } Recfields * recfields(int rtype) { Recfields *rf; for(rf=rfieldstab; rf < rfieldstab + nelem(rfieldstab); rf++) { if(rf->type == rtype) return rf; } abort(); return nil; } int encnum(char *s) { int i; for(i=0; i < nelem(enctab); i++) { if(strcmp(s, enctab[i].str) == 0) return i; } return -1; }