4
getTok(const char **pp)
6
enum { inAtom, inString, init, inComment };
8
const char *tokStart = 0;
23
if (state != inString)
29
else if (state != inString)
70
/* key must be lowercase ASCII */
73
matchkey(const char *start, const char *end, const char *key)
77
for (; start != end; start++, key++)
78
if (*start != *key && *start != 'A' + (*key - 'a'))
84
getXMLCharset(const char *buf, char *charset)
91
if (matchkey(p, next, "text"))
92
strcpy(charset, "us-ascii");
93
else if (!matchkey(p, next, "application"))
99
if (matchkey(p, next, "xml"))
105
if (matchkey(p, next, "charset")) {
107
if (p && *p == '=') {
112
while (++p != next - 1) {
115
if (s == charset + CHARSET_MAX - 1) {
124
if (next - p > CHARSET_MAX - 1)
141
main(int argc, char **argv)
143
char buf[CHARSET_MAX];
144
getXMLCharset(argv[1], buf);
145
printf("charset = \"%s\"\n", buf);