OSDN Git Service

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