OSDN Git Service

* strcasecmp -> STRCASEEQ
[modchxj/mod_chxj.git] / src / chxj_chtml10.c
1 /*
2  * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. 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 "chxj_chtml10.h"
18 #include "chxj_hdml.h"
19 #include "chxj_dump.h"
20 #include "chxj_img_conv.h"
21 #include "chxj_qr_code.h"
22 #include "chxj_cookie.h"
23 #include "chxj_encoding.h"
24
25 #define GET_CHTML10(X) ((chtml10_t *)(X))
26
27 static char *s_chtml10_start_html_tag     (void *pdoc, Node *node);
28 static char *s_chtml10_end_html_tag       (void *pdoc, Node *node);
29 static char *s_chtml10_start_meta_tag     (void *pdoc, Node *node);
30 static char *s_chtml10_end_meta_tag       (void *pdoc, Node *node);
31 static char *s_chtml10_start_textarea_tag (void *pdoc, Node *node);
32 static char *s_chtml10_end_textarea_tag   (void *pdoc, Node *node);
33 static char *s_chtml10_start_p_tag        (void *pdoc, Node *node);
34 static char *s_chtml10_end_p_tag          (void *pdoc, Node *node);
35 static char *s_chtml10_start_pre_tag      (void *pdoc, Node *node);
36 static char *s_chtml10_end_pre_tag        (void *pdoc, Node *node);
37 static char *s_chtml10_start_ul_tag       (void *pdoc, Node *node);
38 static char *s_chtml10_end_ul_tag         (void *pdoc, Node *node);
39 static char *s_chtml10_start_li_tag       (void *pdoc, Node *node);
40 static char *s_chtml10_end_li_tag         (void *pdoc, Node *node);
41 static char *s_chtml10_start_ol_tag       (void *pdoc, Node *node);
42 static char *s_chtml10_end_ol_tag         (void *pdoc, Node *node);
43 static char *s_chtml10_start_h1_tag       (void *pdoc, Node *node);
44 static char *s_chtml10_end_h1_tag         (void *pdoc, Node *node);
45 static char *s_chtml10_start_h2_tag       (void *pdoc, Node *node);
46 static char *s_chtml10_end_h2_tag         (void *pdoc, Node *node);
47 static char *s_chtml10_start_h3_tag       (void *pdoc, Node *node);
48 static char *s_chtml10_end_h3_tag         (void *pdoc, Node *node);
49 static char *s_chtml10_start_h4_tag       (void *pdoc, Node *node);
50 static char *s_chtml10_end_h4_tag         (void *pdoc, Node *node);
51 static char *s_chtml10_start_h5_tag       (void *pdoc, Node *node);
52 static char *s_chtml10_end_h5_tag         (void *pdoc, Node *node);
53 static char *s_chtml10_start_h6_tag       (void *pdoc, Node *node);
54 static char *s_chtml10_end_h6_tag         (void *pdoc, Node *node);
55 static char *s_chtml10_start_head_tag     (void *pdoc, Node *node);
56 static char *s_chtml10_end_head_tag       (void *pdoc, Node *node);
57 static char *s_chtml10_start_title_tag    (void *pdoc, Node *node);
58 static char *s_chtml10_end_title_tag      (void *pdoc, Node *node);
59 static char *s_chtml10_start_base_tag     (void *pdoc, Node *node);
60 static char *s_chtml10_end_base_tag       (void *pdoc, Node *node);
61 static char *s_chtml10_start_body_tag     (void *pdoc, Node *node);
62 static char *s_chtml10_end_body_tag       (void *pdoc, Node *node);
63 static char *s_chtml10_start_a_tag        (void *pdoc, Node *node);
64 static char *s_chtml10_end_a_tag          (void *pdoc, Node *node);
65 static char *s_chtml10_start_br_tag       (void *pdoc, Node *node);
66 static char *s_chtml10_end_br_tag         (void *pdoc, Node *node);
67 static char *s_chtml10_start_tr_tag       (void *pdoc, Node *node);
68 static char *s_chtml10_end_tr_tag         (void *pdoc, Node *node);
69 static char *s_chtml10_start_font_tag     (void *pdoc, Node *node);
70 static char *s_chtml10_end_font_tag       (void *pdoc, Node *node);
71 static char *s_chtml10_start_input_tag    (void *pdoc, Node *node);
72 static char *s_chtml10_end_input_tag      (void *pdoc, Node *node);
73 static char *s_chtml10_start_form_tag     (void *pdoc, Node *node);
74 static char *s_chtml10_end_form_tag       (void *pdoc, Node *node);
75 static char *s_chtml10_start_center_tag   (void *pdoc, Node *node);
76 static char *s_chtml10_end_center_tag     (void *pdoc, Node *node);
77 static char *s_chtml10_start_hr_tag       (void *pdoc, Node *node);
78 static char *s_chtml10_end_hr_tag         (void *pdoc, Node *node);
79 static char *s_chtml10_start_img_tag      (void *pdoc, Node *node);
80 static char *s_chtml10_end_img_tag        (void *pdoc, Node *node);
81 static char *s_chtml10_start_select_tag   (void *pdoc, Node *node);
82 static char *s_chtml10_end_select_tag     (void *pdoc, Node *node);
83 static char *s_chtml10_start_option_tag   (void *pdoc, Node *node);
84 static char *s_chtml10_end_option_tag     (void *pdoc, Node *node);
85 static char *s_chtml10_start_div_tag      (void *pdoc, Node *node);
86 static char *s_chtml10_end_div_tag        (void *pdoc, Node *node);
87
88 static void  s_init_chtml10(chtml10_t *chtml, Doc *doc, request_rec *r, device_table *spec);
89
90 static char *s_chtml10_chxjif_tag        (void *pdoc, Node *node);
91 static char *s_chtml10_text              (void *pdoc, Node *node);
92
93 tag_handler chtml10_handler[] = {
94   /* tagHTML */
95   {
96     s_chtml10_start_html_tag,
97     s_chtml10_end_html_tag,
98   },
99   /* tagMETA */
100   {
101     s_chtml10_start_meta_tag,
102     s_chtml10_end_meta_tag,
103   },
104   /* tagTEXTAREA */
105   {
106     s_chtml10_start_textarea_tag,
107     s_chtml10_end_textarea_tag,
108   },
109   /* tagP */
110   {
111     s_chtml10_start_p_tag,
112     s_chtml10_end_p_tag,
113   },
114   /* tagPRE */
115   {
116     s_chtml10_start_pre_tag,
117     s_chtml10_end_pre_tag,
118   },
119   /* tagUL */
120   {
121     s_chtml10_start_ul_tag,
122     s_chtml10_end_ul_tag,
123   },
124   /* tagLI */
125   {
126     s_chtml10_start_li_tag,
127     s_chtml10_end_li_tag,
128   },
129   /* tagOL */
130   {
131     s_chtml10_start_ol_tag,
132     s_chtml10_end_ol_tag,
133   },
134   /* tagH1 */
135   {
136     s_chtml10_start_h1_tag,
137     s_chtml10_end_h1_tag,
138   },
139   /* tagH2 */
140   {
141     s_chtml10_start_h2_tag,
142     s_chtml10_end_h2_tag,
143   },
144   /* tagH3 */
145   {
146     s_chtml10_start_h3_tag,
147     s_chtml10_end_h3_tag,
148   },
149   /* tagH4 */
150   {
151     s_chtml10_start_h4_tag,
152     s_chtml10_end_h4_tag,
153   },
154   /* tagH5 */
155   {
156     s_chtml10_start_h5_tag,
157     s_chtml10_end_h5_tag,
158   },
159   /* tagH6 */
160   {
161     s_chtml10_start_h6_tag,
162     s_chtml10_end_h6_tag,
163   },
164   /* tagHEAD */
165   {
166     s_chtml10_start_head_tag,
167     s_chtml10_end_head_tag,
168   },
169   /* tagTITLE */
170   {
171     s_chtml10_start_title_tag,
172     s_chtml10_end_title_tag,
173   },
174   /* tagBASE */
175   {
176     s_chtml10_start_base_tag,
177     s_chtml10_end_base_tag,
178   },
179   /* tagBODY */
180   {
181     s_chtml10_start_body_tag,
182     s_chtml10_end_body_tag,
183   },
184   /* tagA */
185   {
186     s_chtml10_start_a_tag,
187     s_chtml10_end_a_tag,
188   },
189   /* tagBR */
190   {
191     s_chtml10_start_br_tag,
192     s_chtml10_end_br_tag,
193   },
194   /* tagTABLE */
195   {
196     NULL,
197     NULL,
198   },
199   /* tagTR */
200   {
201     s_chtml10_start_tr_tag,
202     s_chtml10_end_tr_tag,
203   },
204   /* tagTD */
205   {
206     NULL,
207     NULL,
208   },
209   /* tagTBODY */
210   {
211     NULL,
212     NULL,
213   },
214   /* tagFONT */
215   {
216     s_chtml10_start_font_tag,
217     s_chtml10_end_font_tag,
218   },
219   /* tagFORM */
220   {
221     s_chtml10_start_form_tag,
222     s_chtml10_end_form_tag,
223   },
224   /* tagINPUT */
225   {
226     s_chtml10_start_input_tag,
227     s_chtml10_end_input_tag,
228   },
229   /* tagCENTER */
230   {
231     s_chtml10_start_center_tag,
232     s_chtml10_end_center_tag,
233   },
234   /* tagHR */
235   {
236     s_chtml10_start_hr_tag,
237     s_chtml10_end_hr_tag,
238   },
239   /* tagIMG */
240   {
241     s_chtml10_start_img_tag,
242     s_chtml10_end_img_tag,
243   },
244   /* tagSELECT */
245   {
246     s_chtml10_start_select_tag,
247     s_chtml10_end_select_tag,
248   },
249   /* tagOPTION */
250   {
251     s_chtml10_start_option_tag,
252     s_chtml10_end_option_tag,
253   },
254   /* tagDIV */
255   {
256     s_chtml10_start_div_tag,
257     s_chtml10_end_div_tag,
258   },
259   /* tagCHXJIF */
260   {
261     s_chtml10_chxjif_tag,
262     NULL,
263   },
264   /* tagNOBR */
265   {
266     NULL,
267     NULL,
268   },
269   /* tagSMALL */
270   {
271     NULL,
272     NULL,
273   },
274   /* tagSTYLE */
275   {
276     NULL,
277     NULL,
278   },
279   /* tagSPAN */
280   {
281     NULL,
282     NULL,
283   },
284   /* tagTEXT */
285   {
286     s_chtml10_text,
287     NULL,
288   },
289   /* tagTH */
290   {
291     NULL,
292     NULL,
293   },
294   /* tagB */
295   {
296     NULL,
297     NULL,
298   },
299   /* tagFIELDSET */
300   {
301     NULL,
302     NULL,
303   },
304   /* tagDT */
305   {
306     NULL,
307     NULL,
308   },
309   /* tagLEGEND */
310   {
311     NULL,
312     NULL,
313   },
314   /* tagLABEL */
315   {
316     NULL,
317     NULL,
318   },
319 };
320
321
322 /**
323  * converts from CHTML5.0 to CHTML1.0.
324  *
325  * @param r     [i]   Requet_rec is appointed.
326  * @param spec  [i]   The result of the device specification processing which 
327  *                    was done in advance is appointed.
328  * @param src   [i]   The character string before the converting is appointed.
329  * @return The character string after the converting is returned.
330  */
331 char *
332 chxj_exchange_chtml10(
333   request_rec        *r,
334   device_table       *spec,
335   const char         *src,
336   apr_size_t         srclen,
337   apr_size_t         *dstlen,
338   chxjconvrule_entry *entryp,
339   cookie_t           *cookie
340 )
341 {
342   char      *dst;
343   char      *ss;
344   chtml10_t chtml10;
345   Doc       doc;
346
347   dst = NULL;
348
349   DBG(r, "start chxj_exchange_chtml10() cookie_id=[%s]", (cookie) ? cookie->cookie_id : "");
350
351   /*--------------------------------------------------------------------------*/
352   /* If qrcode xml                                                            */
353   /*--------------------------------------------------------------------------*/
354   *dstlen = srclen;
355   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
356   if (dst) {
357     DBG(r,"i found qrcode xml");
358     return dst;
359   }
360   DBG(r,"not found qrcode xml");
361
362   /*--------------------------------------------------------------------------*/
363   /* The CHTML structure is initialized.                                      */
364   /*--------------------------------------------------------------------------*/
365   s_init_chtml10(&chtml10, &doc, r, spec);
366   chtml10.entryp    = entryp;
367   chtml10.cookie    = cookie;
368
369   if (IS_SJIS_STRING(GET_SPEC_CHARSET(spec))) {
370     ap_set_content_type(r, "text/html; charset=Windows-31J");
371   }
372   else {
373     ap_set_content_type(r, "text/html; charset=UTF-8");
374   }
375
376   /*--------------------------------------------------------------------------*/
377   /* The character string of the input is analyzed.                           */
378   /*--------------------------------------------------------------------------*/
379   qs_init_malloc(&doc);
380   qs_init_root_node(&doc);
381
382   ss = apr_pcalloc(r->pool, srclen + 1);
383   memset(ss, 0,   srclen + 1);
384   memcpy(ss, src, srclen);
385
386 #ifdef DUMP_LOG
387   chxj_dump_out("[src] CHTML -> CHTML1.0", ss, srclen);
388 #endif
389
390   qs_parse_string(&doc,ss, strlen(ss));
391
392   /*--------------------------------------------------------------------------*/
393   /* It converts it from CHTML to CHTML.                                      */
394   /*--------------------------------------------------------------------------*/
395   chxj_node_exchange(spec,r,(void *)&chtml10, &doc, qs_get_root(&doc), 0);
396   dst = chtml10.out;
397
398
399   qs_all_free(&doc,QX_LOGMARK);
400
401   if (!dst)
402     return apr_pstrdup(r->pool,ss);
403
404   if (strlen(dst) == 0) {
405     dst = apr_psprintf(r->pool, "\n");
406   }
407   *dstlen = strlen(dst);
408
409 #ifdef DUMP_LOG
410   chxj_dump_out("[dst] CHTML -> CHTML1.0", dst, *dstlen);
411 #endif
412
413   DBG(r, "end   chxj_exchange_chtml10() cookie_id=[%s]", (cookie) ? cookie->cookie_id : "");
414
415   return dst;
416 }
417
418
419 /**
420  * The CHTML structure is initialized.
421  *
422  * @param chtml10 [i/o] The pointer to the HDML structure that wants to be
423  *                   initialized is specified.
424  * @param doc   [i]   The Doc structure that should be set to the initialized
425  *                   HDML structure is specified.
426  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
427  * @param spec  [i]   The pointer to the device_table
428  */
429 static void
430 s_init_chtml10(
431   chtml10_t     *chtml10, 
432   Doc           *doc, 
433   request_rec   *r, 
434   device_table  *spec)
435 {
436   memset(doc,     0, sizeof(Doc));
437   memset(chtml10, 0, sizeof(chtml10_t));
438
439   doc->r      = r;
440   chtml10->doc  = doc;
441   chtml10->spec = spec;
442   chtml10->out  = qs_alloc_zero_byte_string(r);
443   chtml10->conf = ap_get_module_config(r->per_dir_config, &chxj_module);
444   chtml10->doc->parse_mode = PARSE_MODE_CHTML;
445 }
446
447
448 /**
449  * It is a handler who processes the HTML tag.
450  *
451  * @param chtml10  [i/o] The pointer to the CHTML structure at the output
452  *                     destination is specified.
453  * @param node   [i]   The HTML tag node is specified.
454  * @return The conversion result is returned.
455  */
456 static char *
457 s_chtml10_start_html_tag(void *pdoc, Node *UNUSED(node)) 
458 {
459   Doc           *doc;
460   request_rec   *r;
461   chtml10_t     *chtml10;
462
463   chtml10 = GET_CHTML10(pdoc);
464   doc     = chtml10->doc;
465   r       = doc->r;
466
467   /*--------------------------------------------------------------------------*/
468   /* start HTML tag                                                           */
469   /*--------------------------------------------------------------------------*/
470   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<html>\n", NULL);
471
472   return chtml10->out;
473 }
474
475
476 /**
477  * It is a handler who processes the HTML tag.
478  *
479  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
480  *                     destination is specified.
481  * @param node   [i]   The HTML tag node is specified.
482  * @return The conversion result is returned.
483  */
484 static char *
485 s_chtml10_end_html_tag(void *pdoc, Node *UNUSED(child)) 
486 {
487   Doc           *doc;
488   request_rec   *r;
489   chtml10_t     *chtml10;
490
491   
492   chtml10 = GET_CHTML10(pdoc);
493   doc     = chtml10->doc;
494   r       = doc->r;
495
496   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</html>\n", NULL);
497
498   return chtml10->out;
499 }
500
501
502 /**
503  * It is a handler who processes the META tag.
504  *
505  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
506  *                     destination is specified.
507  * @param node   [i]   The META tag node is specified.
508  * @return The conversion result is returned.
509  */
510 static char *
511 s_chtml10_start_meta_tag(void *pdoc, Node *UNUSED(node)) 
512 {
513   chtml10_t *chtml10;
514
515   chtml10 = GET_CHTML10(pdoc);
516
517   /* ignore */
518
519   return chtml10->out;
520 }
521
522
523 /**
524  * It is a handler who processes the META tag.
525  *
526  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
527  *                     destination is specified.
528  * @param node   [i]   The META tag node is specified.
529  * @return The conversion result is returned.
530  */
531 static char *
532 s_chtml10_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
533 {
534   chtml10_t *chtml10;
535
536   chtml10 = GET_CHTML10(pdoc);
537
538   return chtml10->out;
539 }
540
541
542 /**
543  * It is a handler who processes the HEAD tag.
544  *
545  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
546  *                     destination is specified.
547  * @param node   [i]   The HEAD tag node is specified.
548  * @return The conversion result is returned.
549  */
550 static char *
551 s_chtml10_start_head_tag(void *pdoc, Node *UNUSED(node)) 
552 {
553   Doc           *doc;
554   request_rec   *r;
555   chtml10_t     *chtml10;
556
557   chtml10 = GET_CHTML10(pdoc);
558   doc     = chtml10->doc;
559   r       = doc->r;
560
561   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<head>\r\n", NULL);
562
563   return chtml10->out;
564 }
565
566
567 /**
568  * It is a handler who processes the HEAD tag.
569  *
570  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
571  *                     destination is specified.
572  * @param node   [i]   The HEAD tag node is specified.
573  * @return The conversion result is returned.
574  */
575 static char *
576 s_chtml10_end_head_tag(void *pdoc, Node *UNUSED(child)) 
577 {
578   Doc           *doc;
579   request_rec   *r;
580   chtml10_t     *chtml10;
581
582   chtml10 = GET_CHTML10(pdoc);
583   doc     = chtml10->doc;
584   r       = doc->r;
585
586   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</head>\r\n", NULL);
587
588   return chtml10->out;
589 }
590
591
592 /**
593  * It is a handler who processes the OL tag.
594  *
595  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
596  *                     destination is specified.
597  * @param node   [i]   The OL tag node is specified.
598  * @return The conversion result is returned.
599  */
600 static char *
601 s_chtml10_start_ol_tag(void *pdoc, Node *UNUSED(node)) 
602 {
603   Doc           *doc;
604   request_rec   *r;
605   chtml10_t     *chtml10;
606
607   chtml10 = GET_CHTML10(pdoc);
608   doc     = chtml10->doc;
609   r       = doc->r;
610
611   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<ol>\r\n", NULL);
612
613   return chtml10->out;
614 }
615
616
617 /**
618  * It is a handler who processes the OL tag.
619  *
620  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
621  *                     destination is specified.
622  * @param node   [i]   The OL tag node is specified.
623  * @return The conversion result is returned.
624  */
625 static char *
626 s_chtml10_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
627 {
628   Doc           *doc;
629   request_rec   *r;
630   chtml10_t     *chtml10;
631
632   chtml10 = GET_CHTML10(pdoc);
633   doc     = chtml10->doc;
634   r       = doc->r;
635
636   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</ol>\r\n", NULL);
637
638   return chtml10->out;
639 }
640
641
642 /**
643  * It is a handler who processes the UL tag.
644  *
645  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
646  *                     destination is specified.
647  * @param node   [i]   The UL tag node is specified.
648  * @return The conversion result is returned.
649  */
650 static char *
651 s_chtml10_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
652 {
653   Doc           *doc;
654   request_rec   *r;
655   chtml10_t     *chtml10;
656
657   chtml10    = GET_CHTML10(pdoc);
658   doc        = chtml10->doc;
659   r          = doc->r;
660
661   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<ul>\r\n", NULL);
662
663   return chtml10->out;
664 }
665
666
667 /**
668  * It is a handler who processes the UL tag.
669  *
670  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
671  *                     destination is specified.
672  * @param node   [i]   The UL tag node is specified.
673  * @return The conversion result is returned.
674  */
675 static char*
676 s_chtml10_end_ul_tag(void* pdoc, Node* UNUSED(child)) 
677 {
678   Doc           *doc;
679   request_rec   *r;
680   chtml10_t     *chtml10;
681
682   chtml10 = GET_CHTML10(pdoc);
683   doc     = chtml10->doc;
684   r       = doc->r;
685
686   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</ul>\r\n", NULL);
687
688   return chtml10->out;
689 }
690
691
692 /**
693  * It is a handler who processes the LI tag.
694  *
695  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
696  *                     destination is specified.
697  * @param node   [i]   The LI tag node is specified.
698  * @return The conversion result is returned.
699  */
700 static char *
701 s_chtml10_start_li_tag(void *pdoc, Node *UNUSED(node)) 
702 {
703   Doc           *doc;
704   request_rec   *r;
705   chtml10_t     *chtml10;
706
707   chtml10 = GET_CHTML10(pdoc);
708   doc     = chtml10->doc;
709   r       = doc->r;
710
711   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<li>\r\n", NULL);
712
713   return chtml10->out;
714 }
715
716
717 /**
718  * It is a handler who processes the LI tag.
719  *
720  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
721  *                     destination is specified.
722  * @param node   [i]   The LI tag node is specified.
723  * @return The conversion result is returned.
724  */
725 static char *
726 s_chtml10_end_li_tag(void *pdoc, Node *UNUSED(child)) 
727 {
728   chtml10_t     *chtml10;
729   Doc           *doc;
730   request_rec   *r;
731
732   chtml10 = GET_CHTML10(pdoc);
733   doc     = chtml10->doc;
734   r       = doc->r;
735
736   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</li>\r\n", NULL);
737
738   return chtml10->out;
739 }
740
741
742 /**
743  * It is a handler who processes the H1 tag.
744  *
745  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
746  *                     destination is specified.
747  * @param node   [i]   The H1 tag node is specified.
748  * @return The conversion result is returned.
749  */
750 static char *
751 s_chtml10_start_h1_tag(void *pdoc, Node *UNUSED(node)) 
752 {
753   Doc           *doc;
754   request_rec   *r;
755   chtml10_t     *chtml10;
756
757   chtml10 = GET_CHTML10(pdoc);
758   doc     = chtml10->doc;
759   r       = doc->r;
760
761   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h1>\r\n", NULL);
762
763   return chtml10->out;
764 }
765
766
767 /**
768  * It is a handler who processes the H1 tag.
769  *
770  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
771  *                     destination is specified.
772  * @param node   [i]   The H1 tag node is specified.
773  * @return The conversion result is returned.
774  */
775 static char *
776 s_chtml10_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
777 {
778   Doc           *doc;
779   request_rec   *r;
780   chtml10_t     *chtml10;
781
782   chtml10 = GET_CHTML10(pdoc);
783   doc     = chtml10->doc;
784   r       = doc->r;
785
786   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h1>\r\n", NULL);
787
788   return chtml10->out;
789 }
790
791
792 /**
793  * It is a handler who processes the H2 tag.
794  *
795  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
796  *                     destination is specified.
797  * @param node   [i]   The H2 tag node is specified.
798  * @return The conversion result is returned.
799  */
800 static char *
801 s_chtml10_start_h2_tag(void *pdoc, Node *UNUSED(node)) 
802 {
803   Doc           *doc;
804   request_rec   *r;
805   chtml10_t     *chtml10;
806
807   chtml10 = GET_CHTML10(pdoc);
808   doc     = chtml10->doc;
809   r       = doc->r;
810
811   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h2>\r\n", NULL);
812
813   return chtml10->out;
814 }
815
816
817 /**
818  * It is a handler who processes the H2 tag.
819  *
820  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
821  *                     destination is specified.
822  * @param node   [i]   The H2 tag node is specified.
823  * @return The conversion result is returned.
824  */
825 static char *
826 s_chtml10_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
827 {
828   Doc           *doc;
829   request_rec   *r;
830   chtml10_t     *chtml10;
831
832   chtml10 = GET_CHTML10(pdoc);
833   doc     = chtml10->doc;
834   r       = doc->r;
835
836   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h2>\r\n", NULL);
837
838   return chtml10->out;
839 }
840
841
842 /**
843  * It is a handler who processes the H3 tag.
844  *
845  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
846  *                     destination is specified.
847  * @param node   [i]   The H3 tag node is specified.
848  * @return The conversion result is returned.
849  */
850 static char *
851 s_chtml10_start_h3_tag(void *pdoc, Node *UNUSED(node)) 
852 {
853   Doc           *doc;
854   request_rec   *r;
855   chtml10_t     *chtml10;
856
857   chtml10 = GET_CHTML10(pdoc);
858   doc     = chtml10->doc;
859   r       = doc->r;
860
861   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h3>\r\n", NULL);
862
863   return chtml10->out;
864 }
865
866
867 /**
868  * It is a handler who processes the H3 tag.
869  *
870  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
871  *                     destination is specified.
872  * @param node   [i]   The H3 tag node is specified.
873  * @return The conversion result is returned.
874  */
875 static char *
876 s_chtml10_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
877 {
878   chtml10_t     *chtml10;
879   Doc           *doc;
880   request_rec   *r;
881
882   chtml10 = GET_CHTML10(pdoc);
883   doc     = chtml10->doc;
884   r       = doc->r;
885
886   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h3>\r\n", NULL);
887
888   return chtml10->out;
889 }
890
891
892 /**
893  * It is a handler who processes the H4 tag.
894  *
895  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
896  *                     destination is specified.
897  * @param node   [i]   The H4 tag node is specified.
898  * @return The conversion result is returned.
899  */
900 static char *
901 s_chtml10_start_h4_tag(void *pdoc, Node *UNUSED(node)) 
902 {
903   chtml10_t     *chtml10;
904   Doc           *doc;
905   request_rec   *r;
906
907   chtml10 = GET_CHTML10(pdoc);
908   doc     = chtml10->doc;
909   r       = doc->r;
910
911   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h4>\r\n", NULL);
912
913   return chtml10->out;
914 }
915
916
917 /**
918  * It is a handler who processes the H4 tag.
919  *
920  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
921  *                     destination is specified.
922  * @param node   [i]   The H4 tag node is specified.
923  * @return The conversion result is returned.
924  */
925 static char *
926 s_chtml10_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
927 {
928   Doc           *doc;
929   request_rec   *r;
930   chtml10_t     *chtml10;
931
932   chtml10  = GET_CHTML10(pdoc);
933   doc      = chtml10->doc;
934   r        = doc->r;
935
936   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h4>\r\n", NULL);
937
938   return chtml10->out;
939 }
940
941
942 /**
943  * It is a handler who processes the H5 tag.
944  *
945  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
946  *                     destination is specified.
947  * @param node   [i]   The H5 tag node is specified.
948  * @return The conversion result is returned.
949  */
950 static char *
951 s_chtml10_start_h5_tag(void *pdoc, Node *UNUSED(node)) 
952 {
953   Doc           *doc;
954   request_rec   *r;
955   chtml10_t     *chtml10;
956
957   chtml10 = GET_CHTML10(pdoc);
958   doc     = chtml10->doc;
959   r       = doc->r;
960
961   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h5>\r\n", NULL);
962
963   return chtml10->out;
964 }
965
966
967 /**
968  * It is a handler who processes the H5 tag.
969  *
970  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
971  *                     destination is specified.
972  * @param node   [i]   The H5 tag node is specified.
973  * @return The conversion result is returned.
974  */
975 static char *
976 s_chtml10_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
977 {
978   Doc           *doc;
979   request_rec   *r;
980   chtml10_t     *chtml10;
981
982   chtml10 = GET_CHTML10(pdoc);
983   doc     = chtml10->doc;
984   r       = doc->r;
985
986   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h5>\r\n", NULL);
987
988   return chtml10->out;
989 }
990
991
992 /**
993  * It is a handler who processes the H6 tag.
994  *
995  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
996  *                     destination is specified.
997  * @param node   [i]   The H6 tag node is specified.
998  * @return The conversion result is returned.
999  */
1000 static char *
1001 s_chtml10_start_h6_tag(void *pdoc, Node *UNUSED(node)) 
1002 {
1003   Doc           *doc;
1004   request_rec   *r;
1005   chtml10_t     *chtml10;
1006
1007   chtml10 = GET_CHTML10(pdoc);
1008   doc     = chtml10->doc;
1009   r       = doc->r;
1010
1011   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h6>\r\n", NULL);
1012
1013   return chtml10->out;
1014 }
1015
1016
1017 /**
1018  * It is a handler who processes the H6 tag.
1019  *
1020  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1021  *                     destination is specified.
1022  * @param node   [i]   The H6 tag node is specified.
1023  * @return The conversion result is returned.
1024  */
1025 static char *
1026 s_chtml10_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
1027 {
1028   Doc           *doc;
1029   request_rec   *r;
1030   chtml10_t     *chtml10;
1031
1032   chtml10 = GET_CHTML10(pdoc);
1033   doc     = chtml10->doc;
1034   r       = doc->r;
1035
1036   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h6>\r\n", NULL);
1037
1038   return chtml10->out;
1039 }
1040
1041
1042 /**
1043  * It is a handler who processes the TITLE tag.
1044  *
1045  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1046  *                     destination is specified.
1047  * @param node   [i]   The TITLE tag node is specified.
1048  * @return The conversion result is returned.
1049  */
1050 static char *
1051 s_chtml10_start_title_tag(void *pdoc, Node *UNUSED(node)) 
1052 {
1053   Doc          *doc;
1054   request_rec  *r;
1055   chtml10_t    *chtml10;
1056
1057   chtml10 = GET_CHTML10(pdoc);
1058   doc     = chtml10->doc;
1059   r       = doc->r;
1060
1061   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<title>", NULL);
1062
1063   return chtml10->out;
1064 }
1065
1066
1067 /**
1068  * It is a handler who processes the TITLE tag.
1069  *
1070  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1071  *                     destination is specified.
1072  * @param node   [i]   The TITLE tag node is specified.
1073  * @return The conversion result is returned.
1074  */
1075 static char *
1076 s_chtml10_end_title_tag(void *pdoc, Node *UNUSED(child)) 
1077 {
1078   Doc           *doc;
1079   request_rec   *r;
1080   chtml10_t     *chtml10;
1081
1082   chtml10 = GET_CHTML10(pdoc);
1083   doc     = chtml10->doc;
1084   r       = doc->r;
1085
1086   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</title>\r\n", NULL);
1087
1088   return chtml10->out;
1089 }
1090
1091
1092 /**
1093  * It is a handler who processes the BASE tag.
1094  *
1095  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1096  *                     destination is specified.
1097  * @param node   [i]   The BASE tag node is specified.
1098  * @return The conversion result is returned.
1099  */
1100 static char *
1101 s_chtml10_start_base_tag(void *pdoc, Node *node) 
1102 {
1103   Attr          *attr;
1104   chtml10_t     *chtml10;
1105   Doc           *doc;
1106   request_rec   *r;
1107
1108   chtml10 = GET_CHTML10(pdoc);
1109   doc     = chtml10->doc;
1110   r       = doc->r;
1111   
1112
1113   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<base", NULL);
1114
1115   /*--------------------------------------------------------------------------*/
1116   /* Get Attributes                                                           */
1117   /*--------------------------------------------------------------------------*/
1118   for (attr = qs_get_attr(doc,node);
1119        attr;
1120        attr = qs_get_next_attr(doc,attr)) {
1121     char *name;
1122     char *value;
1123
1124     name  = qs_get_attr_name(doc,attr);
1125     value = qs_get_attr_value(doc,attr);
1126
1127     if (STRCASEEQ('h','H',"href", name)) {
1128       chtml10->out = apr_pstrcat(r->pool, 
1129                       chtml10->out, 
1130                       " href=\"", 
1131                       value, 
1132                       "\"", 
1133                       NULL);
1134     }
1135   }
1136
1137   chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >\r\n", NULL);
1138
1139   return chtml10->out;
1140 }
1141
1142
1143 /**
1144  * It is a handler who processes the BASE tag.
1145  *
1146  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1147  *                     destination is specified.
1148  * @param node   [i]   The BASE tag node is specified.
1149  * @return The conversion result is returned.
1150  */
1151 static char *
1152 s_chtml10_end_base_tag(void *pdoc, Node *UNUSED(child)) 
1153 {
1154   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1155
1156   return chtml10->out;
1157 }
1158
1159
1160 /**
1161  * It is a handler who processes the BODY tag.
1162  *
1163  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1164  *                     destination is specified.
1165  * @param node   [i]   The BODY tag node is specified.
1166  * @return The conversion result is returned.
1167  */
1168 static char *
1169 s_chtml10_start_body_tag(void *pdoc, Node *node) 
1170 {
1171   chtml10_t    *chtml10;
1172   Doc          *doc;
1173   request_rec  *r;
1174   Attr         *attr;
1175
1176   chtml10 = GET_CHTML10(pdoc);
1177   doc     = chtml10->doc;
1178   r       = doc->r;
1179
1180   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<body", NULL);
1181
1182   /*--------------------------------------------------------------------------*/
1183   /* Get Attributes                                                           */
1184   /*--------------------------------------------------------------------------*/
1185   for (attr = qs_get_attr(doc,node);
1186        attr;
1187        attr = qs_get_next_attr(doc,attr)) {
1188
1189     char *name;
1190
1191     name  = qs_get_attr_name(doc,attr);
1192
1193     switch(*name) {
1194     case 'a':
1195     case 'A':
1196       if (strcasecmp(name, "alink") == 0) {
1197         /*----------------------------------------------------------------------*/
1198         /* CHTML 4.0                                                            */
1199         /*----------------------------------------------------------------------*/
1200         /* ignore */
1201       }
1202       break;
1203
1204     case 'b':
1205     case 'B':
1206       if (strcasecmp(name, "bgcolor") == 0) {
1207         /*----------------------------------------------------------------------*/
1208         /* CHTML 2.0                                                            */
1209         /*----------------------------------------------------------------------*/
1210         /* ignore */
1211       }
1212       break;
1213
1214     case 't':
1215     case 'T':
1216       if (strcasecmp(name, "text") == 0) {
1217         /*----------------------------------------------------------------------*/
1218         /* CHTML 2.0                                                            */
1219         /*----------------------------------------------------------------------*/
1220         /* ignore */
1221       }
1222       break;
1223
1224     case 'l':
1225     case 'L':
1226       if (strcasecmp(name, "link") == 0) {
1227         /*----------------------------------------------------------------------*/
1228         /* CHTML 2.0                                                            */
1229         /*----------------------------------------------------------------------*/
1230         /* ignore */
1231       }
1232       break;
1233
1234     case 'v':
1235     case 'V':
1236       if (strcasecmp(name, "vlink") == 0) {
1237         /*----------------------------------------------------------------------*/
1238         /* CHTML 4.0                                                            */
1239         /*----------------------------------------------------------------------*/
1240         /* ignore */
1241       }
1242       break;
1243
1244     default:
1245       break;
1246     }
1247   }
1248
1249   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\r\n", NULL);
1250
1251   return chtml10->out;
1252 }
1253
1254
1255 /**
1256  * It is a handler who processes the BODY tag.
1257  *
1258  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1259  *                     destination is specified.
1260  * @param node   [i]   The BODY tag node is specified.
1261  * @return The conversion result is returned.
1262  */
1263 static char *
1264 s_chtml10_end_body_tag(void *pdoc, Node *UNUSED(child)) 
1265 {
1266   Doc           *doc;
1267   request_rec   *r;
1268   chtml10_t     *chtml10;
1269
1270   chtml10 = GET_CHTML10(pdoc);
1271   doc     = chtml10->doc;
1272   r       = doc->r;
1273
1274   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</body>\r\n", NULL);
1275
1276   return chtml10->out;
1277 }
1278
1279
1280 /**
1281  * It is a handler who processes the A tag.
1282  *
1283  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1284  *                     destination is specified.
1285  * @param node   [i]   The A tag node is specified.
1286  * @return The conversion result is returned.
1287  */
1288 static char *
1289 s_chtml10_start_a_tag(void *pdoc, Node *node) 
1290 {
1291   chtml10_t     *chtml10;
1292   Doc           *doc;
1293   request_rec   *r;
1294   Attr          *attr;
1295
1296   chtml10 = GET_CHTML10(pdoc);
1297   doc     = chtml10->doc;
1298   r       = doc->r;
1299
1300   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<a", NULL);
1301
1302   /*--------------------------------------------------------------------------*/
1303   /* Get Attributes                                                           */
1304   /*--------------------------------------------------------------------------*/
1305   for (attr = qs_get_attr(doc,node);
1306        attr; 
1307        attr = qs_get_next_attr(doc,attr)) {
1308
1309     char *name;
1310     char *value;
1311
1312     name  = qs_get_attr_name(doc,attr);
1313     value = qs_get_attr_value(doc,attr);
1314
1315     switch(*name) {
1316     case 'n':
1317     case 'N':
1318       if (strcasecmp(name, "name") == 0) {
1319         /*--------------------------------------------------------------------*/
1320         /* CHTML1.0                                                           */
1321         /*--------------------------------------------------------------------*/
1322         chtml10->out = apr_pstrcat(r->pool, 
1323                         chtml10->out, 
1324                         " name=\"", 
1325                         value, 
1326                         "\"", 
1327                         NULL);
1328       }
1329       break;
1330
1331     case 'h':
1332     case 'H':
1333       if (strcasecmp(name, "href") == 0) {
1334         /*--------------------------------------------------------------------*/
1335         /* CHTML1.0                                                           */
1336         /*--------------------------------------------------------------------*/
1337         value = chxj_encoding_parameter(r, value);
1338         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
1339         
1340         chtml10->out = apr_pstrcat(r->pool, 
1341                         chtml10->out, 
1342                         " href=\"", 
1343                         value, 
1344                         "\"", 
1345                         NULL);
1346       }
1347       break;
1348
1349     case 'a':
1350     case 'A':
1351       if (strcasecmp(name, "accesskey") == 0) {
1352         /*--------------------------------------------------------------------*/
1353         /* CHTML1.0                                                           */
1354         /*--------------------------------------------------------------------*/
1355         chtml10->out = apr_pstrcat(r->pool, 
1356                         chtml10->out, 
1357                         " accesskey=\"", 
1358                         value, 
1359                         "\"", 
1360                         NULL);
1361       }
1362       break;
1363
1364     case 'c':
1365     case 'C':
1366       if (strcasecmp(name, "cti") == 0) {
1367         /*--------------------------------------------------------------------*/
1368         /* CHTML 2.0                                                          */
1369         /*--------------------------------------------------------------------*/
1370         /* ignore */
1371       }
1372       break;
1373
1374     case 'u':
1375     case 'U':
1376       if (strcasecmp(name, "utn") == 0) {
1377         /*--------------------------------------------------------------------*/
1378         /* CHTML 3.0                                                          */
1379         /*--------------------------------------------------------------------*/
1380         /* ignore */
1381       }
1382       break;
1383
1384     case 't':
1385     case 'T':
1386       if (strcasecmp(name, "telbook") == 0) {
1387         /*--------------------------------------------------------------------*/
1388         /* CHTML 3.0                                                          */
1389         /*--------------------------------------------------------------------*/
1390         /* ignore */
1391       }
1392       break;
1393
1394     case 'k':
1395     case 'K':
1396       if (strcasecmp(name, "kana") == 0) {
1397         /*--------------------------------------------------------------------*/
1398         /* CHTML 3.0                                                          */
1399         /*--------------------------------------------------------------------*/
1400         /* ignore */
1401       }
1402       break;
1403
1404     case 'e':
1405     case 'E':
1406       if (strcasecmp(name, "email") == 0) {
1407         /*--------------------------------------------------------------------*/
1408         /* CHTML 3.0                                                          */
1409         /*--------------------------------------------------------------------*/
1410         /* ignore */
1411       }
1412       break;
1413
1414     case 'i':
1415     case 'I':
1416       if (strcasecmp(name, "ista") == 0) {
1417         /*--------------------------------------------------------------------*/
1418         /* CHTML 4.0                                                          */
1419         /*--------------------------------------------------------------------*/
1420         /* ignore */
1421       }
1422       else
1423       if (strcasecmp(name, "ilet") == 0) {
1424         /*--------------------------------------------------------------------*/
1425         /* CHTML 5.0                                                          */
1426         /*--------------------------------------------------------------------*/
1427         /* ignore */
1428       }
1429       else
1430       if (strcasecmp(name, "iswf") == 0) {
1431         /*--------------------------------------------------------------------*/
1432         /* CHTML 5.0                                                          */
1433         /*--------------------------------------------------------------------*/
1434         /* ignore */
1435       }
1436       else
1437       if (strcasecmp(name, "irst") == 0) {
1438         /*--------------------------------------------------------------------*/
1439         /* CHTML 5.0                                                          */
1440         /*--------------------------------------------------------------------*/
1441         /* ignore */
1442       }
1443       else
1444       if (strcasecmp(name, "ijam") == 0) {
1445         /*--------------------------------------------------------------------*/
1446         /* CHTML 3.0                                                          */
1447         /*--------------------------------------------------------------------*/
1448         /* ignore */
1449       }
1450       break;
1451
1452     default:
1453       break;
1454     }
1455   }
1456
1457   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
1458
1459   return chtml10->out;
1460 }
1461
1462
1463 /**
1464  * It is a handler who processes the A tag.
1465  *
1466  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1467  *                     destination is specified.
1468  * @param node   [i]   The A tag node is specified.
1469  * @return The conversion result is returned.
1470  */
1471 static char *
1472 s_chtml10_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1473 {
1474   chtml10_t    *chtml10;
1475   Doc          *doc;
1476   request_rec  *r;
1477
1478   chtml10 = GET_CHTML10(pdoc);
1479   doc     = chtml10->doc;
1480   r       = doc->r;
1481
1482   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</a>", NULL);
1483
1484   return chtml10->out;
1485 }
1486
1487
1488 /**
1489  * It is a handler who processes the BR tag.
1490  *
1491  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1492  *                     destination is specified.
1493  * @param node   [i]   The BR tag node is specified.
1494  * @return The conversion result is returned.
1495  */
1496 static char *
1497 s_chtml10_start_br_tag(void *pdoc, Node *UNUSED(node)) 
1498 {
1499   chtml10_t    *chtml10;
1500   Doc          *doc;
1501   request_rec  *r;
1502
1503   chtml10 = GET_CHTML10(pdoc);
1504   doc     = chtml10->doc;
1505   r       = doc->r;
1506
1507   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<br>\r\n", NULL);
1508
1509   return chtml10->out;
1510 }
1511
1512
1513 /**
1514  * It is a handler who processes the BR tag.
1515  *
1516  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1517  *                     destination is specified.
1518  * @param node   [i]   The BR tag node is specified.
1519  * @return The conversion result is returned.
1520  */
1521 static char *
1522 s_chtml10_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1523 {
1524   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1525
1526   return chtml10->out;
1527 }
1528
1529
1530 /**
1531  * It is a handler who processes the TR tag.
1532  *
1533  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1534  *                     destination is specified.
1535  * @param node   [i]   The TR tag node is specified.
1536  * @return The conversion result is returned.
1537  */
1538 static char *
1539 s_chtml10_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1540 {
1541   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1542
1543   return chtml10->out;
1544 }
1545
1546
1547 /**
1548  * It is a handler who processes the TR tag.
1549  *
1550  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1551  *                     destination is specified.
1552  * @param node   [i]   The TR tag node is specified.
1553  * @return The conversion result is returned.
1554  */
1555 static char *
1556 s_chtml10_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1557 {
1558   chtml10_t    *chtml10;
1559   Doc          *doc;
1560   request_rec  *r;
1561
1562   chtml10 = GET_CHTML10(pdoc);
1563   doc     = chtml10->doc;
1564   r       = doc->r;
1565
1566   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<br>\r\n", NULL);
1567
1568   return chtml10->out;
1569 }
1570
1571
1572 /**
1573  * It is a handler who processes the FONT tag.
1574  *
1575  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1576  *                     destination is specified.
1577  * @param node   [i]   The FONT tag node is specified.
1578  * @return The conversion result is returned.
1579  */
1580 static char *
1581 s_chtml10_start_font_tag(void *pdoc, Node *UNUSED(node)) 
1582 {
1583   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1584
1585   /* Ignore */
1586
1587   return chtml10->out;
1588 }
1589
1590
1591 /**
1592  * It is a handler who processes the FONT tag.
1593  *
1594  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1595  *                     destination is specified.
1596  * @param node   [i]   The FONT tag node is specified.
1597  * @return The conversion result is returned.
1598  */
1599 static char *
1600 s_chtml10_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1601 {
1602   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1603
1604   /* ignore */
1605
1606   return chtml10->out;
1607 }
1608
1609
1610 /**
1611  * It is a handler who processes the FORM tag.
1612  *
1613  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1614  *                     destination is specified.
1615  * @param node   [i]   The FORM tag node is specified.
1616  * @return The conversion result is returned.
1617  */
1618 static char *
1619 s_chtml10_start_form_tag(void *pdoc, Node *node) 
1620 {
1621   chtml10_t    *chtml10;
1622   Doc          *doc;
1623   request_rec  *r;
1624   Attr         *attr;
1625
1626   chtml10 = GET_CHTML10(pdoc);
1627   doc     = chtml10->doc;
1628   r       = doc->r;
1629
1630   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<form", NULL);
1631
1632   /*--------------------------------------------------------------------------*/
1633   /* Get Attributes                                                           */
1634   /*--------------------------------------------------------------------------*/
1635   for (attr = qs_get_attr(doc,node);
1636        attr;
1637        attr = qs_get_next_attr(doc,attr)) {
1638     char *name;
1639     char *value;
1640
1641     name  = qs_get_attr_name(doc,attr);
1642     value = qs_get_attr_value(doc,attr);
1643
1644     switch(*name) {
1645     case 'a':
1646     case 'A':
1647       if (strcasecmp(name, "action") == 0) {
1648         /*--------------------------------------------------------------------*/
1649         /* CHTML 1.0                                                          */
1650         /*--------------------------------------------------------------------*/
1651         value = chxj_encoding_parameter(r, value);
1652         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
1653   
1654         chtml10->out = apr_pstrcat(r->pool, 
1655                         chtml10->out, 
1656                         " action=\"",
1657                         value,
1658                         "\"", 
1659                         NULL);
1660       }
1661       break;
1662
1663     case 'm':
1664     case 'M':
1665       if (strcasecmp(name, "method") == 0) {
1666         /*--------------------------------------------------------------------*/
1667         /* CHTML 1.0                                                          */
1668         /*--------------------------------------------------------------------*/
1669         chtml10->out = apr_pstrcat(r->pool, 
1670                         chtml10->out, 
1671                         " method=\"",
1672                         value,
1673                         "\"", 
1674                         NULL);
1675       }
1676       break;
1677
1678     case 'u':
1679     case 'U':
1680       if (strcasecmp(name, "utn") == 0) {
1681         /*--------------------------------------------------------------------*/
1682         /* CHTML 3.0                                                          */
1683         /*--------------------------------------------------------------------*/
1684         /* ignore */
1685       }
1686       break;
1687
1688     default:
1689       break;
1690     }
1691   }
1692
1693   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
1694
1695   return chtml10->out;
1696 }
1697
1698
1699 /**
1700  * It is a handler who processes the FORM tag.
1701  *
1702  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1703  *                     destination is specified.
1704  * @param node   [i]   The FORM tag node is specified.
1705  * @return The conversion result is returned.
1706  */
1707 static char *
1708 s_chtml10_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1709 {
1710   chtml10_t    *chtml10;
1711   Doc          *doc;
1712   request_rec  *r;
1713
1714   chtml10 = GET_CHTML10(pdoc);
1715   doc     = chtml10->doc;
1716   r       = doc->r;
1717
1718   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</form>", NULL);
1719
1720   return chtml10->out;
1721 }
1722
1723
1724 /**
1725  * It is a handler who processes the INPUT tag.
1726  *
1727  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1728  *                     destination is specified.
1729  * @param node   [i]   The INPUT tag node is specified.
1730  * @return The conversion result is returned.
1731  */
1732 static char *
1733 s_chtml10_start_input_tag(void *pdoc, Node *node) 
1734 {
1735   chtml10_t     *chtml10;
1736   Doc           *doc;
1737   request_rec   *r;
1738   char          *max_length;
1739   char          *type;
1740   char          *name;
1741   char          *value;
1742   char          *istyle;
1743   char          *size;
1744   char          *checked;
1745   char          *accesskey;
1746
1747   chtml10     = GET_CHTML10(pdoc);
1748   doc         = chtml10->doc;
1749   r           = doc->r;
1750
1751   max_length  = NULL;
1752   type        = NULL;
1753   name        = NULL;
1754   value       = NULL;
1755   istyle      = NULL;
1756   size        = NULL;
1757   checked     = NULL;
1758   accesskey   = NULL;
1759
1760   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<input", NULL);
1761
1762   /*--------------------------------------------------------------------------*/
1763   /* Get Attributes                                                           */
1764   /*--------------------------------------------------------------------------*/
1765
1766   type       = qs_get_type_attr(doc, node, r);
1767   name       = qs_get_name_attr(doc, node, r);
1768   value      = qs_get_value_attr(doc,node,r);
1769   istyle     = qs_get_istyle_attr(doc,node,r);
1770   max_length = qs_get_maxlength_attr(doc,node,r);
1771   checked    = qs_get_checked_attr(doc,node,r);
1772   accesskey  = qs_get_accesskey_attr(doc, node, r);
1773   size       = qs_get_size_attr(doc, node, r);
1774
1775   if (type)
1776     chtml10->out = apr_pstrcat(r->pool,
1777                     chtml10->out, 
1778                     " type=\"", 
1779                     type, 
1780                     "\" ", 
1781                     NULL);
1782
1783   if (size) 
1784     chtml10->out = apr_pstrcat(r->pool, 
1785                     chtml10->out, 
1786                     " size=\"", 
1787                     size, 
1788                     "\" ", 
1789                     NULL);
1790
1791   if (name)
1792     chtml10->out = apr_pstrcat(r->pool, 
1793                     chtml10->out, 
1794                     " name=\"", 
1795                     name, 
1796                     "\" ", 
1797                     NULL);
1798
1799   if (value)
1800     chtml10->out = apr_pstrcat(r->pool, 
1801                     chtml10->out, 
1802                     " value=\"", 
1803                     value, 
1804                     "\" ", 
1805                     NULL);
1806
1807   if (accesskey)
1808     chtml10->out = apr_pstrcat(r->pool, 
1809                     chtml10->out, 
1810                     " accesskey=\"", 
1811                     accesskey, "\" ", 
1812                     NULL);
1813
1814   if (istyle) {
1815     /*------------------------------------------------------------------------*/
1816     /* CHTML 2.0                                                              */
1817     /*------------------------------------------------------------------------*/
1818     /* ignore */
1819   }
1820   /*--------------------------------------------------------------------------*/
1821   /* The figure is default for the password.                                  */
1822   /*--------------------------------------------------------------------------*/
1823   if (max_length)
1824     chtml10->out = apr_pstrcat(r->pool, 
1825                       chtml10->out, 
1826                       " maxlength=\"", 
1827                       max_length, 
1828                       "\"", 
1829                       NULL);
1830
1831   if (checked)
1832     chtml10->out = apr_pstrcat(r->pool, 
1833                     chtml10->out, " checked ", NULL);
1834
1835   chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >", NULL);
1836
1837   return chtml10->out;
1838 }
1839
1840
1841 /**
1842  * It is a handler who processes the INPUT tag.
1843  *
1844  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1845  *                     destination is specified.
1846  * @param node   [i]   The INPUT tag node is specified.
1847  * @return The conversion result is returned.
1848  */
1849 static char *
1850 s_chtml10_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1851 {
1852   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1853
1854   return chtml10->out;
1855 }
1856
1857
1858 /**
1859  * It is a handler who processes the CENTER tag.
1860  *
1861  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1862  *                     destination is specified.
1863  * @param node   [i]   The CENTER tag node is specified.
1864  * @return The conversion result is returned.
1865  */
1866 static char *
1867 s_chtml10_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1868 {
1869   chtml10_t    *chtml10;
1870   Doc          *doc;
1871   request_rec  *r;
1872
1873   chtml10 = GET_CHTML10(pdoc);
1874   doc     = chtml10->doc;
1875   r       = doc->r;
1876
1877   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<center>", NULL);
1878
1879   return chtml10->out;
1880 }
1881
1882
1883 /**
1884  * It is a handler who processes the CENTER tag.
1885  *
1886  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1887  *                     destination is specified.
1888  * @param node   [i]   The CENTER tag node is specified.
1889  * @return The conversion result is returned.
1890  */
1891 static char *
1892 s_chtml10_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1893 {
1894   chtml10_t     *chtml10;
1895   Doc           *doc;
1896   request_rec   *r;
1897
1898   chtml10 = GET_CHTML10(pdoc);
1899   doc     = chtml10->doc;
1900   r       = doc->r;
1901
1902   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</center>", NULL);
1903
1904   return chtml10->out;
1905 }
1906
1907
1908 /**
1909  * It is a handler who processes the HR tag.
1910  *
1911  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1912  *                     destination is specified.
1913  * @param node   [i]   The HR tag node is specified.
1914  * @return The conversion result is returned.
1915  */
1916 static char *
1917 s_chtml10_start_hr_tag(void *pdoc, Node *node) 
1918 {
1919   chtml10_t    *chtml10;
1920   Doc          *doc;
1921   request_rec  *r;
1922   Attr         *attr;
1923
1924   chtml10 = GET_CHTML10(pdoc);
1925   doc     = chtml10->doc;
1926   r       = doc->r;
1927
1928   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<hr ", NULL);
1929  
1930   for (attr = qs_get_attr(doc,node);
1931        attr; 
1932        attr = qs_get_next_attr(doc,attr)) {
1933
1934     char *name;
1935     char *value;
1936
1937     name  = qs_get_attr_name (doc,attr);
1938     value = qs_get_attr_value(doc,attr);
1939
1940     switch(*name) {
1941     case 'a':
1942     case 'A':
1943       if (strcasecmp(name, "align") == 0) {
1944         /*--------------------------------------------------------------------*/
1945         /* CHTML 1.0                                                          */
1946         /*--------------------------------------------------------------------*/
1947         chtml10->out = apr_pstrcat(r->pool,
1948                           chtml10->out, 
1949                           " align=\"", value, "\" ", NULL);
1950       }
1951       break;
1952
1953     case 's':
1954     case 'S':
1955       if (strcasecmp(name, "size") == 0) {
1956         /*--------------------------------------------------------------------*/
1957         /* CHTML 1.0                                                          */
1958         /*--------------------------------------------------------------------*/
1959         chtml10->out = apr_pstrcat(r->pool,
1960                           chtml10->out, 
1961                           " size=\"", value, "\" ", NULL);
1962       }
1963       break;
1964
1965     case 'w':
1966     case 'W':
1967       if (strcasecmp(name, "width") == 0) {
1968         /*--------------------------------------------------------------------*/
1969         /* CHTML 1.0                                                          */
1970         /*--------------------------------------------------------------------*/
1971         chtml10->out = apr_pstrcat(r->pool,
1972                           chtml10->out, 
1973                           " width=\"", value, "\" ", NULL);
1974       }
1975       break;
1976
1977     case 'n':
1978     case 'N':
1979       if (strcasecmp(name, "noshade") == 0) {
1980         /*--------------------------------------------------------------------*/
1981         /* CHTML 1.0                                                          */
1982         /*--------------------------------------------------------------------*/
1983         chtml10->out = apr_pstrcat(r->pool,
1984                           chtml10->out, 
1985                           " noshade ", NULL);
1986       }
1987       break;
1988
1989     case 'c':
1990     case 'C':
1991       if (strcasecmp(name, "color") == 0) {
1992         /*--------------------------------------------------------------------*/
1993         /* CHTML 4.0                                                          */
1994         /*--------------------------------------------------------------------*/
1995         /* ignore */
1996       }
1997       break;
1998
1999     default:
2000       break;
2001     }
2002   }
2003
2004   chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >", NULL);
2005
2006   return chtml10->out;
2007 }
2008
2009
2010 /**
2011  * It is a handler who processes the HR tag.
2012  *
2013  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2014  *                     destination is specified.
2015  * @param node   [i]   The HR tag node is specified.
2016  * @return The conversion result is returned.
2017  */
2018 static char *
2019 s_chtml10_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
2020 {
2021   chtml10_t *chtml10;
2022
2023   chtml10 = GET_CHTML10(pdoc);
2024
2025   return chtml10->out;
2026 }
2027
2028
2029 /**
2030  * It is a handler who processes the IMG tag.
2031  *
2032  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2033  *                     destination is specified.
2034  * @param node   [i]   The IMG tag node is specified.
2035  * @return The conversion result is returned.
2036  */
2037 static char *
2038 s_chtml10_start_img_tag(void *pdoc, Node *node) 
2039 {
2040   chtml10_t    *chtml10;
2041   Doc          *doc;
2042   request_rec  *r;
2043   Attr         *attr;
2044 #ifndef IMG_NOT_CONVERT_FILENAME
2045   device_table *spec;
2046 #endif
2047
2048   chtml10 = GET_CHTML10(pdoc);
2049 #ifndef IMG_NOT_CONVERT_FILENAME
2050   spec    = chtml10->spec;
2051 #endif
2052   doc     = chtml10->doc;
2053   r       = doc->r;
2054
2055   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<img", NULL);
2056  
2057
2058   /*--------------------------------------------------------------------------*/
2059   /* Get Attributes                                                           */
2060   /*--------------------------------------------------------------------------*/
2061   for (attr = qs_get_attr(doc,node);
2062        attr;
2063        attr = qs_get_next_attr(doc,attr)) {
2064
2065     char *name;
2066     char *value;
2067
2068     name  = qs_get_attr_name (doc,attr);
2069     value = qs_get_attr_value(doc,attr);
2070
2071     switch(*name) {
2072     case 's':
2073     case 'S':
2074       if (strcasecmp(name, "src") == 0) {
2075         /*--------------------------------------------------------------------*/
2076         /* CHTML 1.0                                                          */
2077         /*--------------------------------------------------------------------*/
2078 #ifdef IMG_NOT_CONVERT_FILENAME
2079         value = chxj_encoding_parameter(r, value);
2080         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
2081         if (value) {
2082           value = apr_psprintf(r->pool, 
2083                                "%s%c%s=true", 
2084                                value, 
2085                                (strchr(value, '?')) ? '&' : '?',
2086                                CHXJ_COOKIE_NOUPDATE_PARAM);
2087         }
2088         chtml10->out = apr_pstrcat(r->pool, 
2089                         chtml10->out, " src=\"",value,"\"", NULL);
2090 #else
2091         value = chxj_img_conv(r, spec, value);
2092         value = chxj_encoding_parameter(r, value);
2093         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
2094         if (value) {
2095           value = apr_psprintf(r->pool,
2096                                "%s%c%s=true",
2097                                value,
2098                                (strchr(value, '?')) ? '&' : '?',
2099                                CHXJ_COOKIE_NOUPDATE_PARAM);
2100         }
2101         chtml10->out = apr_pstrcat(r->pool, 
2102                         chtml10->out, " src=\"", 
2103                         value, 
2104                         NULL);
2105         chtml10->out = apr_pstrcat(r->pool, chtml10->out, "\"", NULL);
2106 #endif
2107       }
2108       break;
2109
2110     case 'a':
2111     case 'A':
2112       if (strcasecmp(name, "align" ) == 0) {
2113         /*--------------------------------------------------------------------*/
2114         /* CHTML 1.0                                                          */
2115         /*--------------------------------------------------------------------*/
2116         /*--------------------------------------------------------------------*/
2117         /* CHTML 4.0                                                          */
2118         /*--------------------------------------------------------------------*/
2119         chtml10->out = apr_pstrcat(r->pool, 
2120                         chtml10->out, " align=\"",value,"\"", NULL);
2121       }
2122       else
2123       if (strcasecmp(name, "alt"   ) == 0) {
2124         /*--------------------------------------------------------------------*/
2125         /* CHTML 1.0                                                          */
2126         /*--------------------------------------------------------------------*/
2127         chtml10->out = apr_pstrcat(r->pool, 
2128                         chtml10->out, " alt=\"",value,"\"", NULL);
2129       }
2130       break;
2131
2132     case 'w':
2133     case 'W':
2134       if (strcasecmp(name, "width" ) == 0) {
2135         /*--------------------------------------------------------------------*/
2136         /* CHTML 1.0                                                          */
2137         /*--------------------------------------------------------------------*/
2138         chtml10->out = apr_pstrcat(r->pool, 
2139                         chtml10->out, " width=\"",value,"\"", NULL);
2140       }
2141       break;
2142
2143     case 'h':
2144     case 'H':
2145       if (strcasecmp(name, "height") == 0) {
2146         /*--------------------------------------------------------------------*/
2147         /* CHTML 1.0                                                          */
2148         /*--------------------------------------------------------------------*/
2149         chtml10->out = apr_pstrcat(r->pool, 
2150                         chtml10->out, " height=\"",value,"\"", NULL);
2151       }
2152       else
2153       if (strcasecmp(name, "hspace") == 0) {
2154         /*--------------------------------------------------------------------*/
2155         /* CHTML 1.0                                                          */
2156         /*--------------------------------------------------------------------*/
2157         chtml10->out = apr_pstrcat(r->pool, 
2158                         chtml10->out, " hspace=\"",value,"\"", NULL);
2159       }
2160       break;
2161
2162     case 'v':
2163     case 'V':
2164       if (strcasecmp(name, "vspace") == 0) {
2165         /*--------------------------------------------------------------------*/
2166         /* CHTML 1.0                                                          */
2167         /*--------------------------------------------------------------------*/
2168         chtml10->out = apr_pstrcat(r->pool, 
2169                         chtml10->out, " vspace=\"",value,"\"", NULL);
2170       }
2171       break;
2172
2173     default:
2174       break;
2175     }
2176   }
2177
2178   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2179
2180   return chtml10->out;
2181 }
2182
2183
2184 /**
2185  * It is a handler who processes the IMG tag.
2186  *
2187  * @param chtml10  [i/o] The pointer to the CHTML structure at the output
2188  *                     destination is specified.
2189  * @param node   [i]   The IMG tag node is specified.
2190  * @return The conversion result is returned.
2191  */
2192 static char *
2193 s_chtml10_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2194 {
2195   chtml10_t *chtml10;
2196
2197   chtml10 = GET_CHTML10(pdoc);
2198
2199   return chtml10->out;
2200 }
2201
2202
2203 /**
2204  * It is a handler who processes the SELECT tag.
2205  *
2206  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2207  *                     destination is specified.
2208  * @param node   [i]   The SELECT tag node is specified.
2209  * @return The conversion result is returned.
2210  */
2211 static char *
2212 s_chtml10_start_select_tag(void *pdoc, Node *child)
2213 {
2214   chtml10_t    *chtml10;
2215   Doc          *doc;
2216   request_rec  *r;
2217   Attr         *attr;
2218
2219   char         *size;
2220   char         *name;
2221
2222   chtml10 = GET_CHTML10(pdoc);
2223   doc     = chtml10->doc;
2224   r       = doc->r;
2225
2226   size    = NULL;
2227   name    = NULL;
2228
2229   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<select", NULL);
2230   for (attr = qs_get_attr(doc,child);
2231        attr;
2232        attr = qs_get_next_attr(doc,attr)) {
2233     char *nm;
2234     char *val;
2235
2236     nm  = qs_get_attr_name (doc,attr);
2237     val = qs_get_attr_value(doc,attr);
2238
2239     switch(*nm) {
2240     case 's':
2241     case 'S':
2242       if (strcasecmp(nm, "size") == 0) {
2243         /*--------------------------------------------------------------------*/
2244         /* CHTML 1.0 version 2.0                                              */
2245         /*--------------------------------------------------------------------*/
2246         size = apr_pstrdup(r->pool, val);
2247       }
2248       break;
2249
2250     case 'n':
2251     case 'N':
2252       if (strcasecmp(nm, "name") == 0) {
2253         /*--------------------------------------------------------------------*/
2254         /* CHTML 1.0 version 2.0                                              */
2255         /*--------------------------------------------------------------------*/
2256         name = apr_pstrdup(r->pool, val);
2257       }
2258       break;
2259
2260     case 'm':
2261     case 'M':
2262       if (strcasecmp(nm, "multiple") == 0) {
2263         /*--------------------------------------------------------------------*/
2264         /* CHTML 1.0 version 2.0                                              */
2265         /*--------------------------------------------------------------------*/
2266         /* Ignore */
2267       }
2268       break;
2269
2270     default:
2271       break;
2272     }
2273   }
2274
2275   if (size)
2276     chtml10->out = apr_pstrcat(r->pool, 
2277                                chtml10->out, 
2278                                " size=\"",
2279                                size,
2280                                "\"", 
2281                                NULL);
2282
2283   if (name) 
2284     chtml10->out = apr_pstrcat(r->pool, 
2285                                chtml10->out, 
2286                                " name=\"",
2287                                name,
2288                                "\"", 
2289                                NULL);
2290
2291   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\n", NULL);
2292
2293   return chtml10->out;
2294 }
2295
2296
2297 /**
2298  * It is a handler who processes the SELECT tag.
2299  *
2300  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2301  *                     destination is specified.
2302  * @param node   [i]   The SELECT tag node is specified.
2303  * @return The conversion result is returned.
2304  */
2305 static char *
2306 s_chtml10_end_select_tag(void *pdoc, Node *UNUSED(child))
2307 {
2308   chtml10_t    *chtml10;
2309   Doc          *doc;
2310   request_rec  *r;
2311
2312   chtml10 = GET_CHTML10(pdoc);
2313   doc     = chtml10->doc;
2314   r       = doc->r;
2315
2316   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</select>\n", NULL);
2317
2318   return chtml10->out;
2319 }
2320
2321
2322 /**
2323  * It is a handler who processes the OPTION tag.
2324  *
2325  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2326  *                     destination is specified.
2327  * @param node   [i]   The OPTION tag node is specified.
2328  * @return The conversion result is returned.
2329  */
2330 static char *
2331 s_chtml10_start_option_tag(void *pdoc, Node *child)
2332 {
2333   chtml10_t    *chtml10;
2334   Doc          *doc;
2335   request_rec  *r;
2336   Attr         *attr;
2337
2338   char         *selected;
2339   char         *value;
2340
2341   chtml10   = GET_CHTML10(pdoc);
2342   doc       = chtml10->doc;
2343   r         = doc->r;
2344
2345   selected  = NULL;
2346   value     = NULL;
2347
2348   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<option", NULL);
2349   for (attr = qs_get_attr(doc,child);
2350        attr;
2351        attr = qs_get_next_attr(doc,attr)) {
2352     char *nm;
2353     char *val;
2354
2355     nm  = qs_get_attr_name (doc,attr);
2356     val = qs_get_attr_value(doc,attr);
2357
2358     switch(*nm) {
2359     case 's':
2360     case 'S':
2361       if (strcasecmp(nm, "selected") == 0) {
2362         /*--------------------------------------------------------------------*/
2363         /* CHTML 1.0 version 2.0                                              */
2364         /*--------------------------------------------------------------------*/
2365         selected = apr_pstrdup(r->pool, val);
2366       }
2367       break;
2368
2369     case 'v':
2370     case 'V':
2371       if (strcasecmp(nm, "value") == 0) {
2372         /*--------------------------------------------------------------------*/
2373         /* CHTML 1.0 version 2.0                                              */
2374         /*--------------------------------------------------------------------*/
2375         value = apr_pstrdup(r->pool, val);
2376       }
2377       break;
2378
2379     default:
2380       break;
2381     }
2382   }
2383
2384   if (value)
2385     chtml10->out = apr_pstrcat(r->pool, 
2386                                chtml10->out, 
2387                                " value=\"",
2388                                value,
2389                                "\"", 
2390                                NULL);
2391   else
2392     chtml10->out = apr_pstrcat(r->pool, 
2393                                chtml10->out, 
2394                                " value=\"\"", 
2395                                NULL);
2396
2397   if (selected)
2398     chtml10->out = apr_pstrcat(r->pool, 
2399                                chtml10->out, 
2400                                " selected ", 
2401                                NULL);
2402
2403   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2404
2405   return chtml10->out;
2406 }
2407
2408
2409 /**
2410  * It is a handler who processes the OPTION tag.
2411  *
2412  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2413  *                     destination is specified.
2414  * @param node   [i]   The OPTION tag node is specified.
2415  * @return The conversion result is returned.
2416  */
2417 static char *
2418 s_chtml10_end_option_tag(void *pdoc, Node *UNUSED(child))
2419 {
2420   chtml10_t *chtml10;
2421  
2422   chtml10 = GET_CHTML10(pdoc);
2423
2424   /* Don't close */
2425
2426   return chtml10->out;
2427 }
2428
2429
2430 /**
2431  * It is a handler who processes the DIV tag.
2432  *
2433  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2434  *                     destination is specified.
2435  * @param node   [i]   The DIV tag node is specified.
2436  * @return The conversion result is returned.
2437  */
2438 static char *
2439 s_chtml10_start_div_tag(void *pdoc, Node *child)
2440 {
2441   chtml10_t    *chtml10;
2442   Doc          *doc;
2443   request_rec  *r;
2444   Attr         *attr;
2445   char         *align;
2446
2447   chtml10 = GET_CHTML10(pdoc);
2448   doc     = chtml10->doc;
2449   r       = doc->r;
2450
2451   align   = NULL;
2452
2453   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<div", NULL);
2454   for (attr = qs_get_attr(doc,child);
2455        attr;
2456        attr = qs_get_next_attr(doc,attr)) {
2457
2458     char *nm;
2459     char *val;
2460
2461     nm  = qs_get_attr_name(doc,attr);
2462     val = qs_get_attr_value(doc,attr);
2463
2464     if ((*nm == 'a' || *nm == 'A') && strcasecmp(nm, "align") == 0) {
2465       /*----------------------------------------------------------------------*/
2466       /* CHTML 1.0 (W3C version 3.2)                                          */
2467       /*----------------------------------------------------------------------*/
2468       align = apr_pstrdup(r->pool, val);
2469     }
2470   }
2471
2472   if (align)
2473     chtml10->out = apr_pstrcat(r->pool, 
2474                     chtml10->out, " align=\"", align, "\"", NULL);
2475
2476   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2477
2478   return chtml10->out;
2479 }
2480
2481
2482 /**
2483  * It is a handler who processes the DIV tag.
2484  *
2485  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2486  *                     destination is specified.
2487  * @param node   [i]   The DIV tag node is specified.
2488  * @return The conversion result is returned.
2489  */
2490 static char *
2491 s_chtml10_end_div_tag(void *pdoc, Node *UNUSED(child))
2492 {
2493   chtml10_t    *chtml10;
2494   Doc          *doc;
2495   request_rec  *r;
2496
2497   chtml10 = GET_CHTML10(pdoc);
2498   doc     = chtml10->doc;
2499   r       = doc->r;
2500
2501   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</div>\n", NULL);
2502
2503   return chtml10->out;
2504 }
2505
2506
2507 /**
2508  * It is a handler who processes the CHXJ:IF tag.
2509  *
2510  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2511  *                     destination is specified.
2512  * @param node   [i]   The CHXJ:IF tag node is specified.
2513  * @return The conversion result is returned.
2514  */
2515 static char *
2516 s_chtml10_chxjif_tag(void *pdoc, Node *node)
2517 {
2518   chtml10_t    *chtml10;
2519   Doc          *doc;
2520   Node         *child;
2521   request_rec  *r;
2522
2523   chtml10 = GET_CHTML10(pdoc);
2524   doc     = chtml10->doc;
2525   r       = doc->r;
2526
2527   for (child = qs_get_child_node(doc, node);
2528        child;
2529        child = qs_get_next_node(doc, child)) {
2530     chtml10->out = apr_pstrcat(r->pool, chtml10->out, child->otext, NULL);
2531     s_chtml10_chxjif_tag(chtml10, child);
2532   }
2533
2534   return chtml10->out;
2535 }
2536
2537
2538 /**
2539  * It is a handler who processes the PRE tag.
2540  *
2541  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2542  *                     destination is specified.
2543  * @param node   [i]   The PRE tag node is specified.
2544  * @return The conversion result is returned.
2545  */
2546 static char *
2547 s_chtml10_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
2548 {
2549   Doc           *doc;
2550   request_rec   *r;
2551   chtml10_t     *chtml10;
2552
2553   chtml10 = GET_CHTML10(pdoc);
2554   doc     = chtml10->doc;
2555   r       = doc->r;
2556
2557   chtml10->pre_flag++;
2558   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<pre>", NULL);
2559
2560   return chtml10->out;
2561 }
2562
2563
2564 /**
2565  * It is a handler who processes the PRE tag.
2566  *
2567  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2568  *                     destination is specified.
2569  * @param node   [i]   The PRE tag node is specified.
2570  * @return The conversion result is returned.
2571  */
2572 static char *
2573 s_chtml10_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2574 {
2575   chtml10_t     *chtml10;
2576   Doc           *doc;
2577   request_rec   *r;
2578
2579   chtml10 = GET_CHTML10(pdoc);
2580   doc     = chtml10->doc;
2581   r       = doc->r;
2582
2583   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</pre>", NULL);
2584   chtml10->pre_flag--;
2585
2586   return chtml10->out;
2587 }
2588
2589
2590 /**
2591  * It is a handler who processes the P tag.
2592  *
2593  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2594  *                     destination is specified.
2595  * @param node   [i]   The P tag node is specified.
2596  * @return The conversion result is returned.
2597  */
2598 static char *
2599 s_chtml10_start_p_tag(void *pdoc, Node *UNUSED(node)) 
2600 {
2601   Doc           *doc;
2602   request_rec   *r;
2603   chtml10_t     *chtml10;
2604
2605   chtml10 = GET_CHTML10(pdoc);
2606   doc     = chtml10->doc;
2607   r       = doc->r;
2608
2609   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<p>", NULL);
2610
2611   return chtml10->out;
2612 }
2613
2614
2615 /**
2616  * It is a handler who processes the P tag.
2617  *
2618  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2619  *                     destination is specified.
2620  * @param node   [i]   The P tag node is specified.
2621  * @return The conversion result is returned.
2622  */
2623 static char *
2624 s_chtml10_end_p_tag(void *pdoc, Node *UNUSED(child)) 
2625 {
2626   Doc           *doc;
2627   request_rec   *r;
2628   chtml10_t     *chtml10;
2629
2630   chtml10 = GET_CHTML10(pdoc);
2631   doc     = chtml10->doc;
2632   r       = doc->r;
2633
2634   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</p>", NULL);
2635
2636   return chtml10->out;
2637 }
2638
2639
2640 /**
2641  * It is a handler who processes the TEXTARE tag.
2642  *
2643  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2644  *                     destination is specified.
2645  * @param node   [i]   The TEXTAREA tag node is specified.
2646  * @return The conversion result is returned.
2647  */
2648 static char *
2649 s_chtml10_start_textarea_tag(void *pdoc, Node *node) 
2650 {
2651   Doc           *doc;
2652   request_rec   *r;
2653   chtml10_t     *chtml10;
2654   Attr          *attr;
2655
2656   chtml10 = GET_CHTML10(pdoc);
2657   doc     = chtml10->doc;
2658   r       = doc->r;
2659
2660
2661   chtml10->textarea_flag++;
2662   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<textarea ", NULL);
2663
2664   for (attr = qs_get_attr(doc,node);
2665        attr;
2666        attr = qs_get_next_attr(doc,attr)) {
2667
2668     char *name;
2669     char *value;
2670
2671     name  = qs_get_attr_name (doc,attr);
2672     value = qs_get_attr_value(doc,attr);
2673
2674     switch(*name) {
2675     case 'n':
2676     case 'N':
2677       if (strcasecmp(name, "name") == 0) {
2678         chtml10->out = apr_pstrcat(r->pool, 
2679                                    chtml10->out, 
2680                                    " name=\"",
2681                                    value,
2682                                    "\"", 
2683                                    NULL);
2684       }
2685       break;
2686
2687     case 'r':
2688     case 'R':
2689       if (strcasecmp(name, "rows") == 0) {
2690         chtml10->out = apr_pstrcat(r->pool, 
2691                                    chtml10->out, 
2692                                    " rows=\"",
2693                                      value,
2694                                      "\"",
2695                                      NULL);
2696       }
2697       break;
2698
2699     case 'c':
2700     case 'C':
2701       if (strcasecmp(name, "cols") == 0) {
2702         chtml10->out = apr_pstrcat(r->pool, 
2703                                    chtml10->out, 
2704                                    " cols=\"",
2705                                    value,
2706                                    "\"", 
2707                                    NULL);
2708       }
2709       break;
2710     
2711     default:
2712       break;
2713     }
2714   }
2715
2716   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\r\n", NULL);
2717
2718   return chtml10->out;
2719 }
2720
2721
2722 /**
2723  * It is a handler who processes the TEXTAREA tag.
2724  *
2725  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2726  *                     destination is specified.
2727  * @param node   [i]   The TEXTAREA tag node is specified.
2728  * @return The conversion result is returned.
2729  */
2730 static char *
2731 s_chtml10_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
2732 {
2733   Doc           *doc;
2734   request_rec   *r;
2735   chtml10_t     *chtml10;
2736
2737   chtml10 = GET_CHTML10(pdoc);
2738   doc     = chtml10->doc;
2739   r       = doc->r;
2740
2741   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</textarea>\r\n", NULL);
2742   chtml10->textarea_flag--;
2743
2744   return chtml10->out;
2745 }
2746
2747
2748 static char *
2749 s_chtml10_text(void *pdoc, Node *child)
2750 {
2751   char         *textval;
2752   char         *tmp;
2753   char         *tdst;
2754   char         one_byte[2];
2755   int          ii;
2756   int          tdst_len;
2757   chtml10_t    *chtml10;
2758   Doc          *doc;
2759   request_rec* r;
2760
2761   chtml10 = GET_CHTML10(pdoc);
2762   doc     = chtml10->doc;
2763   r       = doc->r;
2764   
2765   textval = qs_get_node_value(doc,child);
2766   textval = qs_trim_string(r->pool, textval);
2767
2768   if (strlen(textval) == 0)
2769     return chtml10->out;
2770   
2771   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2772   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2773   
2774   tdst     = qs_alloc_zero_byte_string(r);
2775   memset(one_byte, 0, sizeof(one_byte));
2776   tdst_len = 0;
2777   
2778   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2779     if (is_sjis_kanji(textval[ii])) {
2780       one_byte[0] = textval[ii+0];
2781       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2782       one_byte[0] = textval[ii+1];
2783       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2784       ii++;
2785     }
2786     else 
2787     if (chtml10->pre_flag) {
2788       one_byte[0] = textval[ii+0];
2789       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2790     }
2791     else 
2792     if (chtml10->textarea_flag) {
2793       one_byte[0] = textval[ii+0];
2794       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2795     }
2796     else 
2797     if (textval[ii] != '\r' && textval[ii] != '\n') {
2798       one_byte[0] = textval[ii+0];
2799       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2800     }
2801   }
2802
2803   chtml10->out = apr_pstrcat(r->pool, chtml10->out, tdst, NULL);
2804
2805   return chtml10->out;
2806 }
2807 /*
2808  * vim:ts=2 et
2809  */