OSDN Git Service

* merge from mastergit
[modchxj/mod_chxj.git] / src / chxj_node_convert.c
1 /*
2  * Copyright (C) 2005-2009 QSDN,Inc. All rights reserved.
3  * Copyright (C) 2005 Atsushi Konno All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include "mod_chxj.h"
18
19 tag_handlers chxj_tag_handlers[] = {
20   {
21     .type    = CHXJ_SPEC_UNKNOWN,
22     .handler = NULL,
23   },
24   {
25     .type    = CHXJ_SPEC_Chtml_1_0,
26     .handler = chtml10_handler,
27   },
28   {
29     .type    = CHXJ_SPEC_Chtml_2_0,
30     .handler = chtml20_handler,
31   },
32   {
33     .type    = CHXJ_SPEC_Chtml_3_0,
34     .handler = chtml30_handler,
35   },
36   {
37     .type    = CHXJ_SPEC_Chtml_4_0,
38     .handler = chtml40_handler,
39   },
40   {
41     .type    = CHXJ_SPEC_Chtml_5_0,
42     .handler = chtml50_handler,
43   },
44   {
45     .type    = CHXJ_SPEC_Chtml_6_0,
46     .handler = ixhtml10_handler,
47   },
48   {
49     .type    = CHXJ_SPEC_Chtml_7_0,
50     .handler = ixhtml10_handler,
51   },
52   {
53     .type    = CHXJ_SPEC_XHtml_Mobile_1_0,
54     .handler = xhtml_handler,
55   },
56   {
57     .type    = CHXJ_SPEC_Hdml,
58     .handler = hdml_handler,
59   },
60   {
61     .type    = CHXJ_SPEC_Jhtml,
62     .handler = jhtml_handler,
63   },
64   {
65     .type    = CHXJ_SPEC_Jxhtml,
66     .handler = jxhtml_handler,
67   },
68   {
69     .type    = CHXJ_SPEC_HTML,
70     .handler = NULL,
71   },
72 };
73
74
75 /**
76  * It is main processing of conversion from CHTML to XXML. 
77  *
78  * @param spec    [i]   
79  * @param r       [i]   
80  * @param pdoc    [i/o] The pointer to the XXML structure is specified. 
81  * @param doc     [i/o] The pointer to the XXML structure is specified. 
82  * @param node    [i]   The pointer to a current node is specified. 
83  * @param indent  [i]   The depth of the node processing it now is specified. 
84  *
85  * @return The character string after it converts it is returned. 
86  */
87 char *
88 chxj_node_convert(
89   device_table *spec,
90   request_rec  *r,
91   void         *pdoc, 
92   Doc          *doc, 
93   Node         *node, 
94   int          indent
95 )
96 {
97   Node         *child;
98   tag_handler  *handlers;
99
100
101   handlers = chxj_tag_handlers[spec->html_spec_type].handler;
102
103   /*--------------------------------------------------------------------------*/
104   /* It is the main loop of the conversion processing.                        */
105   /*--------------------------------------------------------------------------*/
106   for (child = qs_get_child_node(doc,node);
107        child;
108        child = qs_get_next_node(doc,child)) {
109     char *name = qs_get_node_name(doc,child);
110     switch(*name) {
111     case 'h':
112     case 'H':
113       /*----------------------------------------------------------------------*/
114       /* <HTML>                                                               */
115       /*----------------------------------------------------------------------*/
116       if (strcasecmp(name, "html") == 0) {
117         if (handlers[tagHTML].start_tag_handler) 
118           handlers[tagHTML].start_tag_handler(pdoc, child);
119
120         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
121
122         if (handlers[tagHTML].end_tag_handler)
123           handlers[tagHTML].end_tag_handler(pdoc, child);
124       }
125       /*----------------------------------------------------------------------*/
126       /* <HEAD>                                                               */
127       /*----------------------------------------------------------------------*/
128       else 
129       if (strcasecmp(name, "head") == 0) {
130         if (handlers[tagHEAD].start_tag_handler) 
131           handlers[tagHEAD].start_tag_handler(pdoc, child);
132
133         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
134
135         if (handlers[tagHEAD].end_tag_handler)
136           handlers[tagHEAD].end_tag_handler(pdoc, child);
137       }
138       /*----------------------------------------------------------------------*/
139       /* <HR>                                                                 */
140       /*----------------------------------------------------------------------*/
141       else 
142       if (strcasecmp(name, "hr") == 0) {
143         if (handlers[tagHR].start_tag_handler) 
144           handlers[tagHR].start_tag_handler(pdoc, child);
145
146         if (handlers[tagHR].end_tag_handler)
147           handlers[tagHR].end_tag_handler(pdoc, child);
148       }
149       /*----------------------------------------------------------------------*/
150       /* <H1>                                                                 */
151       /*----------------------------------------------------------------------*/
152       else
153       if (strcasecmp(name, "h1") == 0) {
154         if (handlers[tagH1].start_tag_handler) 
155           handlers[tagH1].start_tag_handler(pdoc, child);
156
157         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
158
159         if (handlers[tagH1].end_tag_handler)
160           handlers[tagH1].end_tag_handler(pdoc, child);
161       }
162       /*----------------------------------------------------------------------*/
163       /* <H2>                                                                 */
164       /*----------------------------------------------------------------------*/
165       else
166       if (strcasecmp(name, "h2") == 0) {
167         if (handlers[tagH2].start_tag_handler) 
168           handlers[tagH2].start_tag_handler(pdoc, child);
169
170         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
171
172         if (handlers[tagH2].end_tag_handler)
173           handlers[tagH2].end_tag_handler(pdoc, child);
174       }
175       /*----------------------------------------------------------------------*/
176       /* <H3>                                                                 */
177       /*----------------------------------------------------------------------*/
178       else
179       if (strcasecmp(name, "h3") == 0) {
180         if (handlers[tagH3].start_tag_handler) 
181           handlers[tagH3].start_tag_handler(pdoc, child);
182
183         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
184
185         if (handlers[tagH3].end_tag_handler)
186           handlers[tagH3].end_tag_handler(pdoc, child);
187       }
188       /*----------------------------------------------------------------------*/
189       /* <H4>                                                                 */
190       /*----------------------------------------------------------------------*/
191       else
192       if (strcasecmp(name, "h4") == 0) {
193         if (handlers[tagH4].start_tag_handler) 
194           handlers[tagH4].start_tag_handler(pdoc, child);
195
196         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
197
198         if (handlers[tagH4].end_tag_handler)
199           handlers[tagH4].end_tag_handler(pdoc, child);
200       }
201       /*----------------------------------------------------------------------*/
202       /* <H5>                                                                 */
203       /*----------------------------------------------------------------------*/
204       else
205       if (strcasecmp(name, "h5") == 0) {
206         if (handlers[tagH5].start_tag_handler) 
207           handlers[tagH5].start_tag_handler(pdoc, child);
208
209         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
210
211         if (handlers[tagH5].end_tag_handler)
212           handlers[tagH5].end_tag_handler(pdoc, child);
213       }
214       /*----------------------------------------------------------------------*/
215       /* <H6>                                                                 */
216       /*----------------------------------------------------------------------*/
217       else
218       if (strcasecmp(name, "h6") == 0) {
219         if (handlers[tagH6].start_tag_handler) 
220           handlers[tagH6].start_tag_handler(pdoc, child);
221
222         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
223
224         if (handlers[tagH6].end_tag_handler)
225           handlers[tagH6].end_tag_handler(pdoc, child);
226       }
227       else {
228         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
229       }
230       break;
231
232
233     case 'p':
234     case 'P':
235       /*----------------------------------------------------------------------*/
236       /* <P>                                                                  */
237       /*----------------------------------------------------------------------*/
238       if (strcasecmp(name, "p") == 0) {
239         if (handlers[tagP].start_tag_handler) 
240           handlers[tagP].start_tag_handler(pdoc, child);
241
242         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
243
244         if (handlers[tagP].end_tag_handler)
245           handlers[tagP].end_tag_handler(pdoc, child);
246       }
247       /*----------------------------------------------------------------------*/
248       /* <PRE>                                                                */
249       /*----------------------------------------------------------------------*/
250       else if (strcasecmp(name, "pre") == 0) {
251         if (handlers[tagPRE].start_tag_handler) 
252           handlers[tagPRE].start_tag_handler(pdoc, child);
253
254         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
255
256         if (handlers[tagPRE].end_tag_handler)
257           handlers[tagPRE].end_tag_handler(pdoc, child);
258       }
259       /*----------------------------------------------------------------------*/
260       /* <PLAINTEXT>                                                          */
261       /*----------------------------------------------------------------------*/
262       else if (strcasecmp(name, "plaintext") == 0) {
263         if (handlers[tagPLAINTEXT].start_tag_handler) 
264           handlers[tagPLAINTEXT].start_tag_handler(pdoc, child);
265
266         if (handlers[tagPLAINTEXT].end_tag_handler)
267           handlers[tagPLAINTEXT].end_tag_handler(pdoc, child);
268       }
269       /*----------------------------------------------------------------------*/
270       /* <PARAM>                                                              */
271       /*----------------------------------------------------------------------*/
272       else if (strcasecmp(name, "param") == 0) {
273         if (handlers[tagPARAM].start_tag_handler) 
274           handlers[tagPARAM].start_tag_handler(pdoc, child);
275
276         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
277
278         if (handlers[tagPARAM].end_tag_handler)
279           handlers[tagPARAM].end_tag_handler(pdoc, child);
280       }
281       else {
282         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
283       }
284       break;
285
286     case 'n':
287     case 'N':
288       /*----------------------------------------------------------------------*/
289       /* <NOBR>                                                               */
290       /*----------------------------------------------------------------------*/
291       if (strcasecmp(name, "nobr") == 0) {
292         if (handlers[tagNOBR].start_tag_handler) 
293           handlers[tagNOBR].start_tag_handler(pdoc, child);
294
295         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
296
297         if (handlers[tagNOBR].end_tag_handler)
298           handlers[tagNOBR].end_tag_handler(pdoc, child);
299       }
300       else {
301         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
302       }
303       break;
304
305     case 'u':
306     case 'U':
307       /*----------------------------------------------------------------------*/
308       /* <UL>                                                                 */
309       /*----------------------------------------------------------------------*/
310       if (strcasecmp(name, "ul") == 0) {
311         if (handlers[tagUL].start_tag_handler) 
312           handlers[tagUL].start_tag_handler(pdoc, child);
313
314         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
315
316         if (handlers[tagUL].end_tag_handler)
317           handlers[tagUL].end_tag_handler(pdoc, child);
318       }
319       else {
320         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
321       }
322       break;
323
324     case 'l':
325     case 'L':
326       /*----------------------------------------------------------------------*/
327       /* <LI>                                                                 */
328       /*----------------------------------------------------------------------*/
329       if (strcasecmp(name, "li") == 0) {
330         if (handlers[tagLI].start_tag_handler) 
331           handlers[tagLI].start_tag_handler(pdoc, child);
332
333         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
334
335         if (handlers[tagLI].end_tag_handler)
336           handlers[tagLI].end_tag_handler(pdoc, child);
337       }
338       else
339       /*----------------------------------------------------------------------*/
340       /* <LEGEND>                                                             */
341       /*----------------------------------------------------------------------*/
342       if (strcasecmp(name, "legend") == 0) {
343         if (handlers[tagLEGEND].start_tag_handler) 
344           handlers[tagLEGEND].start_tag_handler(pdoc, child);
345
346         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
347
348         if (handlers[tagLEGEND].end_tag_handler)
349           handlers[tagLEGEND].end_tag_handler(pdoc, child);
350       }
351       else
352       /*----------------------------------------------------------------------*/
353       /* <LABEL>                                                              */
354       /*----------------------------------------------------------------------*/
355       if (strcasecmp(name, "label") == 0) {
356         if (handlers[tagLABEL].start_tag_handler) 
357           handlers[tagLABEL].start_tag_handler(pdoc, child);
358
359         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
360
361         if (handlers[tagLABEL].end_tag_handler)
362           handlers[tagLABEL].end_tag_handler(pdoc, child);
363       }
364       else
365       /*----------------------------------------------------------------------*/
366       /* <LINK>                                                               */
367       /*----------------------------------------------------------------------*/
368       if (strcasecmp(name, "link") == 0) {
369         if (handlers[tagLINK].start_tag_handler) 
370           handlers[tagLINK].start_tag_handler(pdoc, child);
371
372         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
373
374         if (handlers[tagLINK].end_tag_handler)
375           handlers[tagLINK].end_tag_handler(pdoc, child);
376       }
377       else {
378         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
379       }
380       
381       break;
382
383     case 'o':
384     case 'O':
385       /*----------------------------------------------------------------------*/
386       /* <OL>                                                                 */
387       /*----------------------------------------------------------------------*/
388       if (strcasecmp(name, "ol") == 0) {
389         if (handlers[tagOL].start_tag_handler) 
390           handlers[tagOL].start_tag_handler(pdoc, child);
391
392         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
393
394         if (handlers[tagOL].end_tag_handler)
395           handlers[tagOL].end_tag_handler(pdoc, child);
396       }
397       else
398       /*----------------------------------------------------------------------*/
399       /* <OPTION>                                                             */
400       /*----------------------------------------------------------------------*/
401       if (strcasecmp(name, "option") == 0) {
402         if (handlers[tagOPTION].start_tag_handler) 
403           handlers[tagOPTION].start_tag_handler(pdoc, child);
404
405         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
406
407         if (handlers[tagOPTION].end_tag_handler)
408           handlers[tagOPTION].end_tag_handler(pdoc, child);
409       }
410       else
411       /*----------------------------------------------------------------------*/
412       /* <OBJECT>                                                             */
413       /*----------------------------------------------------------------------*/
414       if (strcasecmp(name, "object") == 0) {
415         if (handlers[tagOBJECT].start_tag_handler) 
416           handlers[tagOBJECT].start_tag_handler(pdoc, child);
417
418         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
419
420         if (handlers[tagOBJECT].end_tag_handler)
421           handlers[tagOBJECT].end_tag_handler(pdoc, child);
422       }
423       else {
424         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
425       }
426
427       break;
428
429     case 'm':
430     case 'M':
431       /*----------------------------------------------------------------------*/
432       /* <META>                                                               */
433       /*----------------------------------------------------------------------*/
434       if (strcasecmp(name, "meta") == 0) {
435         if (handlers[tagMETA].start_tag_handler) 
436           handlers[tagMETA].start_tag_handler(pdoc, child);
437
438         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
439
440         if (handlers[tagMETA].end_tag_handler)
441           handlers[tagMETA].end_tag_handler(pdoc, child);
442       }
443       /*----------------------------------------------------------------------*/
444       /* <MENU>                                                               */
445       /*----------------------------------------------------------------------*/
446       else if (strcasecmp(name, "menu") == 0) {
447         if (handlers[tagMENU].start_tag_handler) 
448           handlers[tagMENU].start_tag_handler(pdoc, child);
449
450         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
451
452         if (handlers[tagMENU].end_tag_handler)
453           handlers[tagMENU].end_tag_handler(pdoc, child);
454       }
455       /*----------------------------------------------------------------------*/
456       /* <MARQUEE>                                                            */
457       /*----------------------------------------------------------------------*/
458       else if (strcasecmp(name, "marquee") == 0) {
459         if (handlers[tagMARQUEE].start_tag_handler) 
460           handlers[tagMARQUEE].start_tag_handler(pdoc, child);
461
462         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
463
464         if (handlers[tagMARQUEE].end_tag_handler)
465           handlers[tagMARQUEE].end_tag_handler(pdoc, child);
466       }
467       else {
468         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
469       }
470       break;
471
472     case 'b':
473     case 'B':
474       /*----------------------------------------------------------------------*/
475       /* <B>                                                                  */
476       /*----------------------------------------------------------------------*/
477       if (strlen(name) == 1) {
478         if (handlers[tagB].start_tag_handler) 
479           handlers[tagB].start_tag_handler(pdoc, child);
480
481         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
482
483         if (handlers[tagB].end_tag_handler)
484           handlers[tagB].end_tag_handler(pdoc, child);
485       }
486       else
487       /*----------------------------------------------------------------------*/
488       /* <BASE>                                                               */
489       /*----------------------------------------------------------------------*/
490       if (strcasecmp(name, "base") == 0) {
491         if (handlers[tagBASE].start_tag_handler) 
492           handlers[tagBASE].start_tag_handler(pdoc, child);
493
494         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
495
496         if (handlers[tagBASE].end_tag_handler)
497           handlers[tagBASE].end_tag_handler(pdoc, child);
498       }
499       /*----------------------------------------------------------------------*/
500       /* <BODY>                                                               */
501       /*----------------------------------------------------------------------*/
502       else
503       if (strcasecmp(name, "body") == 0) {
504         if (handlers[tagBODY].start_tag_handler) 
505           handlers[tagBODY].start_tag_handler(pdoc, child);
506
507         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
508
509         if (handlers[tagBODY].end_tag_handler)
510           handlers[tagBODY].end_tag_handler(pdoc, child);
511       }
512       /*----------------------------------------------------------------------*/
513       /* <BR>                                                                 */
514       /*----------------------------------------------------------------------*/
515       else if (strcasecmp(name, "br") == 0) {
516         if (handlers[tagBR].start_tag_handler) 
517           handlers[tagBR].start_tag_handler(pdoc, child);
518
519         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
520
521         if (handlers[tagBR].end_tag_handler)
522           handlers[tagBR].end_tag_handler(pdoc, child);
523       }
524       /*----------------------------------------------------------------------*/
525       /* <BLOCKQUOTE>                                                         */
526       /*----------------------------------------------------------------------*/
527       else if (strcasecmp(name, "blockquote") == 0) {
528         if (handlers[tagBLOCKQUOTE].start_tag_handler) 
529           handlers[tagBLOCKQUOTE].start_tag_handler(pdoc, child);
530
531         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
532
533         if (handlers[tagBLOCKQUOTE].end_tag_handler)
534           handlers[tagBLOCKQUOTE].end_tag_handler(pdoc, child);
535       }
536       /*----------------------------------------------------------------------*/
537       /* <BLINK>                                                              */
538       /*----------------------------------------------------------------------*/
539       else if (strcasecmp(name, "blink") == 0) {
540         if (handlers[tagBLINK].start_tag_handler) 
541           handlers[tagBLINK].start_tag_handler(pdoc, child);
542
543         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
544
545         if (handlers[tagBLINK].end_tag_handler)
546           handlers[tagBLINK].end_tag_handler(pdoc, child);
547       }
548       else {
549         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
550       }
551       break;
552
553     case 'a':
554     case 'A':
555       /*----------------------------------------------------------------------*/
556       /* <A>                                                                  */
557       /*----------------------------------------------------------------------*/
558       if (strcasecmp(name, "a") == 0) {
559         if (handlers[tagA].start_tag_handler) 
560           handlers[tagA].start_tag_handler(pdoc, child);
561
562         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
563
564         if (handlers[tagA].end_tag_handler)
565           handlers[tagA].end_tag_handler(pdoc, child);
566       }
567       else {
568         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
569       }
570       break;
571
572     case 'f':
573     case 'F':
574       /*----------------------------------------------------------------------*/
575       /* <FONT>                                                               */
576       /*----------------------------------------------------------------------*/
577       if (strcasecmp(name, "font") == 0) {
578         if (handlers[tagFONT].start_tag_handler) 
579           handlers[tagFONT].start_tag_handler(pdoc, child);
580
581         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
582
583         if (handlers[tagFONT].end_tag_handler)
584           handlers[tagFONT].end_tag_handler(pdoc, child);
585       }
586       /*----------------------------------------------------------------------*/
587       /* <FORM>                                                               */
588       /*----------------------------------------------------------------------*/
589       else
590       if (strcasecmp(name, "form") == 0) {
591         if (handlers[tagFORM].start_tag_handler) 
592           handlers[tagFORM].start_tag_handler(pdoc, child);
593
594         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
595
596         if (handlers[tagFORM].end_tag_handler)
597           handlers[tagFORM].end_tag_handler(pdoc, child);
598       }
599       /*----------------------------------------------------------------------*/
600       /* <FIELDSET>                                                           */
601       /*----------------------------------------------------------------------*/
602       else
603       if (strcasecmp(name, "fieldset") == 0) {
604         if (handlers[tagFIELDSET].start_tag_handler) 
605           handlers[tagFIELDSET].start_tag_handler(pdoc, child);
606
607         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
608
609         if (handlers[tagFIELDSET].end_tag_handler)
610           handlers[tagFIELDSET].end_tag_handler(pdoc, child);
611       }
612       else {
613         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
614       }
615       break;
616
617     case 'i':
618     case 'I':
619       /*----------------------------------------------------------------------*/
620       /* <INPUT>                                                              */
621       /*----------------------------------------------------------------------*/
622       if (strcasecmp(name, "input") == 0) {
623         if (handlers[tagINPUT].start_tag_handler) 
624           handlers[tagINPUT].start_tag_handler(pdoc, child);
625
626         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
627
628         if (handlers[tagINPUT].end_tag_handler)
629           handlers[tagINPUT].end_tag_handler(pdoc, child);
630       }
631       /*----------------------------------------------------------------------*/
632       /* <IMG>                                                                */
633       /*----------------------------------------------------------------------*/
634       else
635       if (strcasecmp(name, "img") == 0) {
636         if (handlers[tagIMG].start_tag_handler) 
637           handlers[tagIMG].start_tag_handler(pdoc, child);
638
639         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
640
641         if (handlers[tagIMG].end_tag_handler)
642           handlers[tagIMG].end_tag_handler(pdoc, child);
643       }
644       else {
645         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
646       }
647       break;
648
649     case 's':
650     case 'S':
651       /*----------------------------------------------------------------------*/
652       /* <SELECT>                                                             */
653       /*----------------------------------------------------------------------*/
654       if (strcasecmp(name, "select") == 0) {
655         if (handlers[tagSELECT].start_tag_handler) 
656           handlers[tagSELECT].start_tag_handler(pdoc, child);
657
658         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
659
660         if (handlers[tagSELECT].end_tag_handler)
661           handlers[tagSELECT].end_tag_handler(pdoc, child);
662       }
663       /*----------------------------------------------------------------------*/
664       /* <STYLE>                                                              */
665       /*----------------------------------------------------------------------*/
666       else
667       if (strcasecmp(name, "style") == 0) {
668         if (handlers[tagSTYLE].start_tag_handler) 
669           handlers[tagSTYLE].start_tag_handler(pdoc, child);
670 #if 0
671         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
672 #endif
673
674         if (handlers[tagSTYLE].end_tag_handler)
675           handlers[tagSTYLE].end_tag_handler(pdoc, child);
676       }
677       /*----------------------------------------------------------------------*/
678       /* <SPAN>                                                               */
679       /*----------------------------------------------------------------------*/
680       else
681       if (strcasecmp(name, "span") == 0) {
682         if (handlers[tagSPAN].start_tag_handler) 
683           handlers[tagSPAN].start_tag_handler(pdoc, child);
684
685         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
686
687         if (handlers[tagSPAN].end_tag_handler)
688           handlers[tagSPAN].end_tag_handler(pdoc, child);
689       }
690       /*----------------------------------------------------------------------*/
691       /* <SMALL>                                                              */
692       /*----------------------------------------------------------------------*/
693       else
694       if (strcasecmp(name, "small") == 0) {
695         if (handlers[tagSMALL].start_tag_handler) 
696           handlers[tagSMALL].start_tag_handler(pdoc, child);
697
698         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
699
700         if (handlers[tagSMALL].end_tag_handler)
701           handlers[tagSMALL].end_tag_handler(pdoc, child);
702       }
703       /*----------------------------------------------------------------------*/
704       /* <SCRIPT>                                                             */
705       /*----------------------------------------------------------------------*/
706       else 
707       if (strcasecmp(name, "script") == 0) {
708         /* ignore script block */
709       }
710       else {
711         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
712       }
713       break;
714   
715     case 'd':
716     case 'D':
717       /*----------------------------------------------------------------------*/
718       /* <DIV>                                                                */
719       /*----------------------------------------------------------------------*/
720       if (strcasecmp(name, "div") == 0) {
721         if (handlers[tagDIV].start_tag_handler) 
722           handlers[tagDIV].start_tag_handler(pdoc, child);
723
724         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
725
726         if (handlers[tagDIV].end_tag_handler)
727           handlers[tagDIV].end_tag_handler(pdoc, child);
728       }
729       /*----------------------------------------------------------------------*/
730       /* <DIR>                                                                */
731       /*----------------------------------------------------------------------*/
732       else if (strcasecmp(name, "dir") == 0) {
733         if (handlers[tagDIR].start_tag_handler) 
734           handlers[tagDIR].start_tag_handler(pdoc, child);
735
736         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
737
738         if (handlers[tagDIR].end_tag_handler)
739           handlers[tagDIR].end_tag_handler(pdoc, child);
740       }
741       /*----------------------------------------------------------------------*/
742       /* <DL>                                                                 */
743       /*----------------------------------------------------------------------*/
744       else if (strcasecmp(name, "dl") == 0) {
745         if (handlers[tagDL].start_tag_handler) 
746           handlers[tagDL].start_tag_handler(pdoc, child);
747
748         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
749
750         if (handlers[tagDL].end_tag_handler)
751           handlers[tagDL].end_tag_handler(pdoc, child);
752       }
753       /*----------------------------------------------------------------------*/
754       /* <DT>                                                                 */
755       /*----------------------------------------------------------------------*/
756       else if (strcasecmp(name, "dt") == 0) {
757         if (handlers[tagDT].start_tag_handler) 
758           handlers[tagDT].start_tag_handler(pdoc, child);
759
760         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
761
762         if (handlers[tagDT].end_tag_handler)
763           handlers[tagDT].end_tag_handler(pdoc, child);
764       }
765       /*----------------------------------------------------------------------*/
766       /* <DD>                                                                 */
767       /*----------------------------------------------------------------------*/
768       else if (strcasecmp(name, "dd") == 0) {
769         if (handlers[tagDD].start_tag_handler) 
770           handlers[tagDD].start_tag_handler(pdoc, child);
771
772         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
773
774         if (handlers[tagDD].end_tag_handler)
775           handlers[tagDD].end_tag_handler(pdoc, child);
776       }
777       else {
778         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
779       }
780       break;
781
782     case 'c':
783     case 'C':
784       /*----------------------------------------------------------------------*/
785       /* NL (CrLf)                                                            */
786       /*----------------------------------------------------------------------*/
787       if (strcasecmp(name, QS_PARSE_NL_MARK) == 0) {
788         if (handlers[tagNLMARK].start_tag_handler) 
789           handlers[tagNLMARK].start_tag_handler(pdoc, child);
790       }
791       else
792       /*----------------------------------------------------------------------*/
793       /* <CENTER>                                                             */
794       /*----------------------------------------------------------------------*/
795       if (strcasecmp(name, "center") == 0) {
796         if (handlers[tagCENTER].start_tag_handler) 
797           handlers[tagCENTER].start_tag_handler(pdoc, child);
798
799         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
800
801         if (handlers[tagCENTER].end_tag_handler)
802           handlers[tagCENTER].end_tag_handler(pdoc, child);
803       }
804       else
805       /*----------------------------------------------------------------------*/
806       /* <CAPTION>                                                            */
807       /*----------------------------------------------------------------------*/
808       if (strcasecmp(name, "caption") == 0) {
809         if (handlers[tagCAPTION].start_tag_handler) 
810           handlers[tagCAPTION].start_tag_handler(pdoc, child);
811
812         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
813
814         if (handlers[tagCAPTION].end_tag_handler)
815           handlers[tagCAPTION].end_tag_handler(pdoc, child);
816       }
817       /*----------------------------------------------------------------------*/
818       /* <CHXJ:IF>                                                            */
819       /*----------------------------------------------------------------------*/
820       else
821       if (strcasecmp(name, "chxj:if") == 0) {
822         if (chxj_chxjif_is_mine(spec, doc, child)) {
823           char* parse_attr;
824
825           parse_attr = qs_get_parse_attr(doc, child, r->pool);
826
827           if (parse_attr && strcasecmp(parse_attr, "true") == 0) {
828             chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
829           }
830           else {
831             if (handlers[tagCHXJIF].start_tag_handler)
832               handlers[tagCHXJIF].start_tag_handler(pdoc, child);
833           }
834         }
835       }
836       /*----------------------------------------------------------------------*/
837       /* <CHXJ:RAW>                                                           */
838       /*----------------------------------------------------------------------*/
839       else
840       if (strcasecmp(name, "chxj:raw") == 0) {
841         if (handlers[tagCHXJRAW].start_tag_handler) {
842            handlers[tagCHXJRAW].start_tag_handler(pdoc, child);
843         }
844       }
845       else {
846         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
847       }
848       break;
849
850     case 't':
851     case 'T':
852       /*----------------------------------------------------------------------*/
853       /* <TEXTAREA>                                                           */
854       /*----------------------------------------------------------------------*/
855       if (strcasecmp(name, "textarea") == 0) {
856         if (handlers[tagTEXTAREA].start_tag_handler) 
857           handlers[tagTEXTAREA].start_tag_handler(pdoc, child);
858
859         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
860
861         if (handlers[tagTEXTAREA].end_tag_handler)
862           handlers[tagTEXTAREA].end_tag_handler(pdoc, child);
863       }
864       else
865       /*----------------------------------------------------------------------*/
866       /* <TITLE>                                                              */
867       /*----------------------------------------------------------------------*/
868       if (strcasecmp(name, "title") == 0) {
869         if (handlers[tagTITLE].start_tag_handler) 
870           handlers[tagTITLE].start_tag_handler(pdoc, child);
871
872         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
873
874         if (handlers[tagTITLE].end_tag_handler)
875           handlers[tagTITLE].end_tag_handler(pdoc, child);
876       }
877       /*----------------------------------------------------------------------*/
878       /* <TABLE>                                                              */
879       /*----------------------------------------------------------------------*/
880       else
881       if (strcasecmp(name, "table") == 0) {
882         if (handlers[tagTABLE].start_tag_handler) 
883           handlers[tagTABLE].start_tag_handler(pdoc, child);
884
885         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
886
887         if (handlers[tagTABLE].end_tag_handler)
888           handlers[tagTABLE].end_tag_handler(pdoc, child);
889       }
890       /*----------------------------------------------------------------------*/
891       /* <TBODY>                                                              */
892       /*----------------------------------------------------------------------*/
893       else
894       if (strcasecmp(name, "tbody") == 0) {
895         if (handlers[tagTBODY].start_tag_handler) 
896           handlers[tagTBODY].start_tag_handler(pdoc, child);
897
898         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
899
900         if (handlers[tagTBODY].end_tag_handler)
901           handlers[tagTBODY].end_tag_handler(pdoc, child);
902       }
903       /*----------------------------------------------------------------------*/
904       /* <TH>                                                                 */
905       /*----------------------------------------------------------------------*/
906       else
907       if (strcasecmp(name, "th") == 0) {
908         if (handlers[tagTH].start_tag_handler) 
909           handlers[tagTH].start_tag_handler(pdoc, child);
910
911         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
912
913         if (handlers[tagTH].end_tag_handler)
914           handlers[tagTH].end_tag_handler(pdoc, child);
915       }
916       /*----------------------------------------------------------------------*/
917       /* <TR>                                                                 */
918       /*----------------------------------------------------------------------*/
919       else
920       if (strcasecmp(name, "tr") == 0) {
921         if (handlers[tagTR].start_tag_handler) 
922           handlers[tagTR].start_tag_handler(pdoc, child);
923
924         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
925
926         if (handlers[tagTR].end_tag_handler)
927           handlers[tagTR].end_tag_handler(pdoc, child);
928       }
929       /*----------------------------------------------------------------------*/
930       /* <TD>                                                                 */
931       /*----------------------------------------------------------------------*/
932       else
933       if (strcasecmp(name, "td") == 0) {
934         if (handlers[tagTD].start_tag_handler) 
935           handlers[tagTD].start_tag_handler(pdoc, child);
936
937         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
938
939         if (handlers[tagTD].end_tag_handler)
940           handlers[tagTD].end_tag_handler(pdoc, child);
941       }
942       /*----------------------------------------------------------------------*/
943       /* NORMAL TEXT                                                          */
944       /*----------------------------------------------------------------------*/
945       else
946       if (strcasecmp(name, "text") == 0) {
947         if (handlers[tagTEXT].start_tag_handler)
948           handlers[tagTEXT].start_tag_handler(pdoc, child);
949       }
950       else {
951         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
952       }
953       break;
954
955     default:
956       chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
957     }
958   }
959
960   return NULL;
961 }
962
963
964 char *
965 chxj_node_convert_chxjif_only(
966   request_rec  *r,
967   device_table *spec,
968   const char   *src,
969   apr_size_t   *len  
970 )
971 {
972   Doc  doc;
973   char *dst;
974   int  pass = 0;
975   apr_size_t dst_pos = 0;
976   apr_size_t ii;
977
978   memset(&doc, 0, sizeof(Doc));
979
980   apr_pool_create(&doc.pool, r->pool);
981   doc.r = r;
982
983   dst = apr_palloc(doc.pool, *len + 1);
984   memset(dst, 0, *len + 1);
985
986   for (ii =0; ii<*len; ii++) {
987     if (src[ii + 0] == '<') {
988       apr_size_t endpoint = chxj_cut_tag(&src[ii + 0], *len - ii);
989       Node *node   = qs_parse_tag(&doc, &src[ii], endpoint);
990       char *name   = qs_get_node_name(&doc,node);
991       if (STRCASEEQ('c','C',"chxj:if", name)) {
992         if (! chxj_chxjif_is_mine(spec, &doc, node)) {
993           pass = 1;
994         }
995         ii += endpoint;
996       }
997       else if (STRCASEEQ('/','/', "/chxj:if", name)) {
998         pass = 0;
999         ii += endpoint;
1000       }
1001       else {
1002         if (! pass) {
1003 #if 0
1004           memcpy(&dst[dst_pos], &src[ii], endpoint + 1);
1005           dst_pos += (endpoint + 1);
1006 #else
1007           dst[dst_pos++] = src[ii];
1008 #endif
1009         }
1010 #if 0
1011         ii += endpoint;
1012 #endif
1013       }
1014     }
1015     else {
1016       if (! pass) {
1017         if (is_sjis_kanji(src[ii])) {
1018           dst[dst_pos++] = src[ii++];
1019           dst[dst_pos++] = src[ii];
1020         }
1021         else  {
1022           dst[dst_pos++] = src[ii];
1023         }
1024       }
1025     }
1026   }
1027   *len = strlen(dst);
1028   return dst;
1029 }
1030 /*
1031  * vim:ts=2 et
1032  */