OSDN Git Service

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