Warning, file /education/cantor/thirdparty/discount-2.2.6-patched/mktags.c was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* block-level tags for passing html blocks through the blender
0002  */
0003 #include <stdio.h>
0004 
0005 #define __WITHOUT_AMALLOC 1
0006 #include "config.h"
0007 #include "cstring.h"
0008 #include "tags.h"
0009 
0010 STRING(struct kw) blocktags;
0011 
0012 
0013 /* define a html block tag
0014  */
0015 static void
0016 define_one_tag(char *id, int selfclose)
0017 {
0018     struct kw *p = &EXPAND(blocktags);
0019 
0020     p->id = id;
0021     p->size = strlen(id);
0022     p->selfclose = selfclose;
0023 }
0024 
0025 
0026 /* case insensitive string sort (for qsort() and bsearch() of block tags)
0027  */
0028 static int
0029 casort(struct kw *a, struct kw *b)
0030 {
0031     if ( a->size != b->size )
0032     return a->size - b->size;
0033     return strncasecmp(a->id, b->id, b->size);
0034 }
0035 
0036 
0037 /* stupid cast to make gcc shut up about the function types being
0038  * passed into qsort() and bsearch()
0039  */
0040 typedef int (*stfu)(const void*,const void*);
0041 
0042 
0043 /* load in the standard collection of html tags that markdown supports
0044  */
0045 int
0046 main()
0047 {
0048     int i;
0049 
0050 #define KW(x)   define_one_tag(x, 0)
0051 #define SC(x)   define_one_tag(x, 1)
0052 
0053     KW("STYLE");
0054     KW("SCRIPT");
0055     KW("ADDRESS");
0056     KW("BDO");
0057     KW("BLOCKQUOTE");
0058     KW("CENTER");
0059     KW("DFN");
0060     KW("DIV");
0061     KW("OBJECT");
0062     KW("H1");
0063     KW("H2");
0064     KW("H3");
0065     KW("H4");
0066     KW("H5");
0067     KW("H6");
0068     KW("LISTING");
0069     KW("NOBR");
0070     KW("FORM");
0071     KW("UL");
0072     KW("P");
0073     KW("OL");
0074     KW("DL");
0075     KW("PLAINTEXT");
0076     KW("PRE");
0077     KW("TABLE");
0078     KW("WBR");
0079     KW("XMP");
0080     SC("HR");
0081     KW("IFRAME");
0082     KW("MAP");
0083 
0084     qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort);
0085 
0086     printf("static struct kw blocktags[] = {\n");
0087     for (i=0; i < S(blocktags); i++)
0088     printf("   { \"%s\", %d, %d },\n", T(blocktags)[i].id, T(blocktags)[i].size, T(blocktags)[i].selfclose );
0089     printf("};\n\n");
0090     printf("#define NR_blocktags %d\n", S(blocktags));
0091     exit(0);
0092 }