OSDN Git Service

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