OSDN Git Service

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