OSDN Git Service

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