Debian Codegraph @

ext/mktags.c

raw symbols SCIP
1 /* block-level tags for passing html blocks through the blender
2 */
3 #include <stdio.h>
4
5 #define __WITHOUT_AMALLOC 1
6 #include "config.h"
7 #include "cstring.h"
8 #include "tags.h"
9
10 STRING(struct kw) blocktags;
11
12
13 /* define a html block tag
14 */
15 static void
16 define_one_tag(char *id, int selfclose)
17 {
18 struct kw *p = &EXPAND(blocktags);
19
20 p->id = id;
21 p->size = strlen(id);
22 p->selfclose = selfclose;
23 }
24
25
26 /* case insensitive string sort (for qsort() and bsearch() of block tags)
27 */
28 static int
29 casort(struct kw *a, struct kw *b)
30 {
31 if ( a->size != b->size )
32 return a->size - b->size;
33 return strncasecmp(a->id, b->id, b->size);
34 }
35
36
37 /* stupid cast to make gcc shut up about the function types being
38 * passed into qsort() and bsearch()
39 */
40 typedef int (*stfu)(const void*,const void*);
41
42
43 /* load in the standard collection of html tags that markdown supports
44 */
45 int
46 main()
47 {
48 int i;
49
50 #define KW(x) define_one_tag(x, 0)
51 #define SC(x) define_one_tag(x, 1)
52
53 KW("STYLE");
54 KW("SCRIPT");
55 KW("ADDRESS");
56 KW("BDO");
57 KW("BLOCKQUOTE");
58 KW("CENTER");
59 KW("DFN");
60 KW("DIV");
61 KW("OBJECT");
62 KW("H1");
63 KW("H2");
64 KW("H3");
65 KW("H4");
66 KW("H5");
67 KW("H6");
68 KW("LISTING");
69 KW("NOBR");
70 KW("FORM");
71 KW("UL");
72 KW("P");
73 KW("OL");
74 KW("DL");
75 KW("PLAINTEXT");
76 KW("PRE");
77 KW("TABLE");
78 KW("WBR");
79 KW("XMP");
80 SC("HR");
81 KW("IFRAME");
82 KW("MAP");
83
84 qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort);
85
86 printf("static struct kw blocktags[] = {\n");
87 for (i=0; i < S(blocktags); i++)
88 printf(" { \"%s\", %d, %d },\n", T(blocktags)[i].id, T(blocktags)[i].size, T(blocktags)[i].selfclose );
89 printf("};\n\n");
90 printf("#define NR_blocktags %d\n", S(blocktags));
91 exit(0);
92 }