OSDN Git Service

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