OSDN Git Service

* Added test code of the <pre> 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
2211   W_L("<select");
2212   for (attr = qs_get_attr(doc,child);
2213        attr;
2214        attr = qs_get_next_attr(doc,attr)) {
2215
2216     char *nm;
2217     char *val;
2218
2219     nm  = qs_get_attr_name(doc,attr);
2220     val = qs_get_attr_value(doc,attr);
2221
2222     switch(*nm) {
2223     case 's':
2224     case 'S':
2225       if (strcasecmp(nm, "size") == 0) {
2226         /*--------------------------------------------------------------------*/
2227         /* CHTML 1.0 version 2.0                                              */
2228         /*--------------------------------------------------------------------*/
2229         size = apr_pstrdup(doc->buf.pool, val);
2230       }
2231       break;
2232
2233     case 'n':
2234     case 'N':
2235       if (strcasecmp(nm, "name") == 0) {
2236         /*--------------------------------------------------------------------*/
2237         /* CHTML 1.0 version 2.0                                              */
2238         /*--------------------------------------------------------------------*/
2239         name = apr_pstrdup(doc->buf.pool, val);
2240       }
2241       break;
2242
2243     case 'm':
2244     case 'M':
2245       if (strcasecmp(nm, "multiple") == 0) {
2246         /*--------------------------------------------------------------------*/
2247         /* CHTML 1.0 version 2.0                                              */
2248         /*--------------------------------------------------------------------*/
2249         /* not support */
2250       }
2251       break;
2252
2253     default:
2254       break;
2255     }
2256   }
2257
2258   if (size) {
2259     W_L(" size=\"");
2260     W_V(size);
2261     W_L("\"");
2262   }
2263
2264   if (name) {
2265     W_L(" name=\"");
2266     W_V(name);
2267     W_L("\"");
2268   }
2269
2270   W_L(">\r\n");
2271   return chtml20->out;
2272 }
2273
2274
2275 /**
2276  * It is a handler who processes the SELECT tag.
2277  *
2278  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2279  *                     destination is specified.
2280  * @param node   [i]   The SELECT tag node is specified.
2281  * @return The conversion result is returned.
2282  */
2283 static char *
2284 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2285 {
2286   chtml20_t *chtml20;
2287   Doc *doc;
2288   request_rec *r;
2289
2290   chtml20 = GET_CHTML20(pdoc);
2291   doc     = chtml20->doc;
2292   r       = doc->r;
2293
2294   W_L("</select>\r\n");
2295   return chtml20->out;
2296 }
2297
2298
2299 /**
2300  * It is a handler who processes the OPTION tag.
2301  *
2302  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2303  *                     destination is specified.
2304  * @param node   [i]   The OPTION tag node is specified.
2305  * @return The conversion result is returned.
2306  */
2307 static char *
2308 s_chtml20_start_option_tag(void *pdoc, Node *child)
2309 {
2310   chtml20_t *chtml20;
2311   Doc *doc;
2312   request_rec *r;
2313   Attr *attr;
2314
2315   chtml20 = GET_CHTML20(pdoc);
2316   doc     = chtml20->doc;
2317   r       = doc->r;
2318
2319   char *selected   = NULL;
2320   char *value      = NULL;
2321
2322   W_L("<option");
2323   for (attr = qs_get_attr(doc,child);
2324        attr;
2325        attr = qs_get_next_attr(doc,attr)) {
2326
2327     char *nm;
2328     char *val;
2329
2330     nm  = qs_get_attr_name(doc,attr);
2331     val = qs_get_attr_value(doc,attr);
2332
2333     switch(*nm) {
2334     case 's':
2335     case 'S':
2336       if (strcasecmp(nm, "selected") == 0) {
2337         /*--------------------------------------------------------------------*/
2338         /* CHTML 1.0 version 2.0                                              */
2339         /*--------------------------------------------------------------------*/
2340         selected = apr_pstrdup(doc->buf.pool, val);
2341       }
2342       break;
2343
2344     case 'v':
2345     case 'V':
2346       if (strcasecmp(nm, "value") == 0) {
2347         /*--------------------------------------------------------------------*/
2348         /* CHTML 1.0 version 2.0                                              */
2349         /*--------------------------------------------------------------------*/
2350         value = apr_pstrdup(doc->buf.pool, val);
2351       }
2352       break;
2353
2354     default:
2355       break;
2356     }
2357   }
2358
2359   if (value && *value) {
2360     W_L(" value=\"");
2361     W_V(value);
2362     W_L("\"");
2363   }
2364
2365   if (selected) {
2366     W_L(" selected");
2367   }
2368   W_L(">");
2369   return chtml20->out;
2370 }
2371
2372
2373 /**
2374  * It is a handler who processes the OPTION tag.
2375  *
2376  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2377  *                     destination is specified.
2378  * @param node   [i]   The OPTION tag node is specified.
2379  * @return The conversion result is returned.
2380  */
2381 static char *
2382 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2383 {
2384   chtml20_t *chtml20;
2385   Doc *doc;
2386   request_rec *r;
2387
2388   chtml20 = GET_CHTML20(pdoc);
2389   doc     = chtml20->doc;
2390   r       = doc->r;
2391
2392   /* Don't close */
2393
2394   return chtml20->out;
2395 }
2396
2397
2398 /**
2399  * It is a handler who processes the DIV tag.
2400  *
2401  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2402  *                     destination is specified.
2403  * @param node   [i]   The DIV tag node is specified.
2404  * @return The conversion result is returned.
2405  */
2406 static char *
2407 s_chtml20_start_div_tag(void *pdoc, Node *child)
2408 {
2409   chtml20_t *chtml20;
2410   Doc *doc;
2411   request_rec *r;
2412   Attr *attr;
2413
2414   chtml20 = GET_CHTML20(pdoc);
2415   doc     = chtml20->doc;
2416   r       = doc->r;
2417
2418
2419   char* align   = NULL;
2420
2421   W_L("<div");
2422   for (attr = qs_get_attr(doc,child);
2423        attr;
2424        attr = qs_get_next_attr(doc,attr)) {
2425
2426     char *nm;
2427     char *val;
2428
2429     nm  = qs_get_attr_name(doc,attr);
2430     val = qs_get_attr_value(doc,attr);
2431
2432     if (STRCASEEQ('a','A', "align", nm)) {
2433       /*----------------------------------------------------------------------*/
2434       /* CHTML 1.0 (W3C version 3.2)                                          */
2435       /*----------------------------------------------------------------------*/
2436       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2437         align = apr_pstrdup(doc->buf.pool, val);
2438       }
2439     }
2440   }
2441
2442   if (align) {
2443     W_L(" align=\"");
2444     W_V(align);
2445     W_L("\"");
2446   }
2447
2448   W_L(">");
2449   return chtml20->out;
2450 }
2451
2452
2453 /**
2454  * It is a handler who processes the DIV tag.
2455  *
2456  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2457  *                     destination is specified.
2458  * @param node   [i]   The DIV tag node is specified.
2459  * @return The conversion result is returned.
2460  */
2461 static char *
2462 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2463 {
2464   chtml20_t *chtml20;
2465   Doc *doc;
2466   request_rec *r;
2467
2468   chtml20 = GET_CHTML20(pdoc);
2469   doc     = chtml20->doc;
2470   r       = doc->r;
2471
2472   W_L("</div>");
2473   return chtml20->out;
2474 }
2475
2476
2477 /**
2478  * It is a handler who processes the H1 tag.
2479  *
2480  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2481  *                     destination is specified.
2482  * @param node   [i]   The H1 tag node is specified.
2483  * @return The conversion result is returned.
2484  */
2485 static char *
2486 s_chtml20_start_h1_tag(void *pdoc, Node *node) 
2487 {
2488   chtml20_t *chtml20;
2489   Doc *doc;
2490   request_rec *r;
2491   Attr *attr;
2492
2493   chtml20 = GET_CHTML20(pdoc);
2494   doc     = chtml20->doc;
2495   r       = doc->r;
2496
2497   W_L("<h1");
2498   for (attr = qs_get_attr(doc,node);
2499        attr;
2500        attr = qs_get_next_attr(doc,attr)) {
2501     char* name;
2502     char* value;
2503     name  = qs_get_attr_name(doc,attr);
2504     value = qs_get_attr_value(doc,attr);
2505     if (STRCASEEQ('a','A',"align", name)) {
2506       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2507         W_L(" align=\"");
2508         W_V(value);
2509         W_L("\"");
2510         break;
2511       }
2512     }
2513   }
2514   W_L(">");
2515   return chtml20->out;
2516 }
2517
2518
2519 /**
2520  * It is a handler who processes the H1 tag.
2521  *
2522  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2523  *                     destination is specified.
2524  * @param node   [i]   The H1 tag node is specified.
2525  * @return The conversion result is returned.
2526  */
2527 static char *
2528 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2529 {
2530   chtml20_t *chtml20;
2531   Doc *doc;
2532   request_rec *r;
2533
2534   chtml20 = GET_CHTML20(pdoc);
2535   doc     = chtml20->doc;
2536   r       = doc->r;
2537
2538   W_L("</h1>");
2539   return chtml20->out;
2540 }
2541
2542
2543 /**
2544  * It is a handler who processes the H2 tag.
2545  *
2546  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2547  *                     destination is specified.
2548  * @param node   [i]   The H2 tag node is specified.
2549  * @return The conversion result is returned.
2550  */
2551 static char *
2552 s_chtml20_start_h2_tag(void *pdoc, Node *node) 
2553 {
2554   chtml20_t *chtml20;
2555   Doc *doc;
2556   request_rec *r;
2557   Attr *attr;
2558
2559   chtml20 = GET_CHTML20(pdoc);
2560   doc     = chtml20->doc;
2561   r       = doc->r;
2562
2563   W_L("<h2");
2564   for (attr = qs_get_attr(doc,node);
2565        attr;
2566        attr = qs_get_next_attr(doc,attr)) {
2567     char* name;
2568     char* value;
2569     name  = qs_get_attr_name(doc,attr);
2570     value = qs_get_attr_value(doc,attr);
2571     if (STRCASEEQ('a','A',"align", name)) {
2572       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2573         W_L(" align=\"");
2574         W_V(value);
2575         W_L("\"");
2576         break;
2577       }
2578     }
2579   }
2580   W_L(">");
2581   return chtml20->out;
2582 }
2583
2584
2585 /**
2586  * It is a handler who processes the H2 tag.
2587  *
2588  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2589  *                     destination is specified.
2590  * @param node   [i]   The H2 tag node is specified.
2591  * @return The conversion result is returned.
2592  */
2593 static char *
2594 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2595
2596   chtml20_t *chtml20;
2597   Doc *doc;
2598   request_rec *r;
2599
2600   chtml20 = GET_CHTML20(pdoc);
2601   doc     = chtml20->doc;
2602   r       = doc->r;
2603
2604   W_L("</h2>");
2605   return chtml20->out;
2606 }
2607
2608
2609 /**
2610  * It is a handler who processes the H3 tag.
2611  *
2612  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2613  *                     destination is specified.
2614  * @param node   [i]   The H3 tag node is specified.
2615  * @return The conversion result is returned.
2616  */
2617 static char *
2618 s_chtml20_start_h3_tag(void *pdoc, Node *node) 
2619 {
2620   chtml20_t *chtml20;
2621   Doc *doc;
2622   request_rec *r;
2623   Attr *attr;
2624
2625   chtml20 = GET_CHTML20(pdoc);
2626   doc     = chtml20->doc;
2627   r       = doc->r;
2628
2629   W_L("<h3");
2630   for (attr = qs_get_attr(doc,node);
2631        attr;
2632        attr = qs_get_next_attr(doc,attr)) {
2633     char* name;
2634     char* value;
2635     name  = qs_get_attr_name(doc,attr);
2636     value = qs_get_attr_value(doc,attr);
2637     if (STRCASEEQ('a','A',"align", name)) {
2638       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2639         W_L(" align=\"");
2640         W_V(value);
2641         W_L("\"");
2642         break;
2643       }
2644     }
2645   }
2646   W_L(">");
2647   return chtml20->out;
2648 }
2649
2650
2651 /**
2652  * It is a handler who processes the H3 tag.
2653  *
2654  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2655  *                     destination is specified.
2656  * @param node   [i]   The H3 tag node is specified.
2657  * @return The conversion result is returned.
2658  */
2659 static char *
2660 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2661 {
2662   chtml20_t *chtml20;
2663   Doc *doc;
2664   request_rec *r;
2665
2666   chtml20 = GET_CHTML20(pdoc);
2667   doc     = chtml20->doc;
2668   r       = doc->r;
2669
2670   W_L("</h3>");
2671   return chtml20->out;
2672 }
2673
2674
2675 /**
2676  * It is a handler who processes the H4 tag.
2677  *
2678  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2679  *                     destination is specified.
2680  * @param node   [i]   The H4 tag node is specified.
2681  * @return The conversion result is returned.
2682  */
2683 static char *
2684 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2685 {
2686   chtml20_t *chtml20;
2687   Doc *doc;
2688   request_rec *r;
2689   Attr *attr;
2690
2691   chtml20 = GET_CHTML20(pdoc);
2692   doc     = chtml20->doc;
2693   r       = doc->r;
2694
2695   W_L("<h4");
2696   for (attr = qs_get_attr(doc,node);
2697        attr;
2698        attr = qs_get_next_attr(doc,attr)) {
2699     char* name;
2700     char* value;
2701     name  = qs_get_attr_name(doc,attr);
2702     value = qs_get_attr_value(doc,attr);
2703     if (STRCASEEQ('a','A',"align", name)) {
2704       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2705         W_L(" align=\"");
2706         W_V(value);
2707         W_L("\"");
2708         break;
2709       }
2710     }
2711   }
2712   W_L(">");
2713   return chtml20->out;
2714 }
2715
2716
2717 /**
2718  * It is a handler who processes the H4 tag.
2719  *
2720  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2721  *                     destination is specified.
2722  * @param node   [i]   The H4 tag node is specified.
2723  * @return The conversion result is returned.
2724  */
2725 static char *
2726 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2727 {
2728   chtml20_t *chtml20;
2729   Doc *doc;
2730   request_rec *r;
2731
2732   chtml20 = GET_CHTML20(pdoc);
2733   doc     = chtml20->doc;
2734   r       = doc->r;
2735
2736   W_L("</h4>");
2737   return chtml20->out;
2738 }
2739
2740
2741 /**
2742  * It is a handler who processes the H5 tag.
2743  *
2744  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2745  *                     destination is specified.
2746  * @param node   [i]   The H5 tag node is specified.
2747  * @return The conversion result is returned.
2748  */
2749 static char *
2750 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2751 {
2752   chtml20_t *chtml20;
2753   Doc *doc;
2754   request_rec *r;
2755   Attr *attr;
2756
2757   chtml20 = GET_CHTML20(pdoc);
2758   doc     = chtml20->doc;
2759   r       = doc->r;
2760
2761   W_L("<h5");
2762   for (attr = qs_get_attr(doc,node);
2763        attr;
2764        attr = qs_get_next_attr(doc,attr)) {
2765     char *name;
2766     char *value;
2767     name  = qs_get_attr_name(doc,attr);
2768     value = qs_get_attr_value(doc,attr);
2769     if (STRCASEEQ('a','A',"align", name)) {
2770       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2771         W_L(" align=\"");
2772         W_V(value);
2773         W_L("\"");
2774         break;
2775       }
2776     }
2777   }
2778   W_L(">");
2779   return chtml20->out;
2780 }
2781
2782
2783 /**
2784  * It is a handler who processes the H5 tag.
2785  *
2786  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2787  *                     destination is specified.
2788  * @param node   [i]   The H5 tag node is specified.
2789  * @return The conversion result is returned.
2790  */
2791 static char *
2792 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
2793 {
2794   chtml20_t *chtml20;
2795   Doc *doc;
2796   request_rec *r;
2797
2798   chtml20 = GET_CHTML20(pdoc);
2799   doc     = chtml20->doc;
2800   r       = doc->r;
2801
2802   W_L("</h5>");
2803   return chtml20->out;
2804 }
2805
2806
2807 /**
2808  * It is a handler who processes the H6 tag.
2809  *
2810  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2811  *                     destination is specified.
2812  * @param node   [i]   The H6 tag node is specified.
2813  * @return The conversion result is returned.
2814  */
2815 static char *
2816 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2817 {
2818   chtml20_t *chtml20;
2819   Doc *doc;
2820   request_rec *r;
2821   Attr *attr;
2822
2823   chtml20 = GET_CHTML20(pdoc);
2824   doc     = chtml20->doc;
2825   r       = doc->r;
2826
2827   W_L("<h6");
2828   for (attr = qs_get_attr(doc,node);
2829        attr;
2830        attr = qs_get_next_attr(doc,attr)) {
2831     char *name;
2832     char *value;
2833     name  = qs_get_attr_name(doc,attr);
2834     value = qs_get_attr_value(doc,attr);
2835     if (STRCASEEQ('a','A',"align", name)) {
2836       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2837         W_L(" align=\"");
2838         W_V(value);
2839         W_L("\"");
2840         break;
2841       }
2842     }
2843   }
2844   W_L(">");
2845   return chtml20->out;
2846 }
2847
2848
2849 /**
2850  * It is a handler who processes the H6 tag.
2851  *
2852  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2853  *                     destination is specified.
2854  * @param node   [i]   The H6 tag node is specified.
2855  * @return The conversion result is returned.
2856  */
2857 static char *
2858 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
2859 {
2860   chtml20_t *chtml20;
2861   Doc *doc;
2862   request_rec *r;
2863
2864   chtml20 = GET_CHTML20(pdoc);
2865   doc     = chtml20->doc;
2866   r       = doc->r;
2867
2868   W_L("</h6>");
2869   return chtml20->out;
2870 }
2871
2872
2873 /**
2874  * It is a handler who processes the PRE tag.
2875  *
2876  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2877  *                     destination is specified.
2878  * @param node   [i]   The PRE tag node is specified.
2879  * @return The conversion result is returned.
2880  */
2881 static char *
2882 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
2883 {
2884   chtml20_t *chtml20;
2885   Doc *doc;
2886   request_rec *r;
2887
2888   chtml20 = GET_CHTML20(pdoc);
2889   doc     = chtml20->doc;
2890   r       = doc->r;
2891
2892   chtml20->pre_flag++;
2893   W_L("<pre>");
2894   return chtml20->out;
2895 }
2896
2897
2898 /**
2899  * It is a handler who processes the PRE tag.
2900  *
2901  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2902  *                     destination is specified.
2903  * @param node   [i]   The PRE tag node is specified.
2904  * @return The conversion result is returned.
2905  */
2906 static char *
2907 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2908 {
2909   chtml20_t *chtml20;
2910   Doc *doc;
2911   request_rec *r;
2912
2913   chtml20 = GET_CHTML20(pdoc);
2914   doc     = chtml20->doc;
2915   r       = doc->r;
2916
2917   W_L("</pre>");
2918   chtml20->pre_flag--;
2919
2920   return chtml20->out;
2921 }
2922
2923
2924 /**
2925  * It is a handler who processes the P tag.
2926  *
2927  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2928  *                     destination is specified.
2929  * @param node   [i]   The P tag node is specified.
2930  * @return The conversion result is returned.
2931  */
2932 static char *
2933 s_chtml20_start_p_tag(void *pdoc, Node *node)
2934 {
2935   chtml20_t *chtml20;
2936   Doc *doc;
2937   request_rec *r;
2938   Attr *attr;
2939   char *align = NULL;
2940
2941   chtml20 = GET_CHTML20(pdoc);
2942   doc     = chtml20->doc;
2943   r       = doc->r;
2944
2945   W_L("<p");
2946   for (attr = qs_get_attr(doc,node);
2947        attr;
2948        attr = qs_get_next_attr(doc,attr)) {
2949     char *nm  = qs_get_attr_name(doc,attr);
2950     char *val = qs_get_attr_value(doc,attr);
2951     if (STRCASEEQ('a','A',"align", nm)) {
2952       /*----------------------------------------------------------------------*/
2953       /* CHTML 1.0 (W3C version 3.2)                                          */
2954       /*----------------------------------------------------------------------*/
2955       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2956         align = apr_pstrdup(doc->buf.pool, val);
2957         break;
2958       }
2959     }
2960   }
2961   if (align) {
2962     W_L(" align=\"");
2963     W_V(align);
2964     W_L("\"");
2965   }
2966   W_L(">");
2967   return chtml20->out;
2968 }
2969
2970
2971 /**
2972  * It is a handler who processes the P tag.
2973  *
2974  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2975  *                     destination is specified.
2976  * @param node   [i]   The P tag node is specified.
2977  * @return The conversion result is returned.
2978  */
2979 static char *
2980 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child)) 
2981 {
2982   chtml20_t *chtml20;
2983   Doc *doc;
2984   request_rec *r;
2985
2986   chtml20 = GET_CHTML20(pdoc);
2987   doc     = chtml20->doc;
2988   r       = doc->r;
2989
2990   W_L("</p>");
2991   return chtml20->out;
2992 }
2993
2994
2995 static char *
2996 s_chtml20_chxjif_tag(void *pdoc, Node *node)
2997 {
2998   chtml20_t *chtml20;
2999   Doc *doc;
3000   Node *child;
3001   request_rec *r;
3002
3003   chtml20 = GET_CHTML20(pdoc);
3004   doc     = chtml20->doc;
3005   r       = doc->r;
3006
3007   for (child = qs_get_child_node(doc, node);
3008        child;
3009        child = qs_get_next_node(doc, child)) {
3010
3011     W_V(child->otext);
3012     s_chtml20_chxjif_tag(pdoc, child);
3013   }
3014
3015   return NULL;
3016 }
3017
3018
3019 /**
3020  * It is a handler who processes the TEXTARE tag.
3021  *
3022  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3023  *                     destination is specified.
3024  * @param node   [i]   The TEXTAREA tag node is specified.
3025  * @return The conversion result is returned.
3026  */
3027 static char *
3028 s_chtml20_start_textarea_tag(void *pdoc, Node *node) 
3029 {
3030   chtml20_t *chtml20;
3031   Doc *doc;
3032   request_rec *r;
3033   Attr *attr;
3034
3035   chtml20 = GET_CHTML20(pdoc);
3036   doc     = chtml20->doc;
3037   r       = doc->r;
3038
3039   chtml20->textarea_flag++;
3040   W_L("<textarea ");
3041   for (attr = qs_get_attr(doc,node);
3042        attr;
3043        attr = qs_get_next_attr(doc,attr)) {
3044
3045     char *name;
3046     char *value;
3047
3048     name  = qs_get_attr_name(doc,attr);
3049     value = qs_get_attr_value(doc,attr);
3050
3051     switch(*name) {
3052     case 'n':
3053     case 'N':
3054       if (strcasecmp(name, "name") == 0) {
3055         W_L(" name=\"");
3056         W_V(value);
3057         W_L("\"");
3058       }
3059       break;
3060
3061     case 'r':
3062     case 'R':
3063       if (strcasecmp(name, "rows") == 0) {
3064         W_L(" rows=\"");
3065         W_V(value);
3066         W_L("\"");
3067       }
3068       break;
3069
3070     case 'c':
3071     case 'C':
3072       if (strcasecmp(name, "cols") == 0) {
3073         W_L(" cols=\"");
3074         W_V(value);
3075         W_L("\"");
3076       }
3077       break;
3078
3079     default:
3080       break;
3081     }
3082   }
3083   W_L(">\r\n");
3084   return chtml20->out;
3085 }
3086
3087
3088 /**
3089  * It is a handler who processes the TEXTAREA tag.
3090  *
3091  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3092  *                     destination is specified.
3093  * @param node   [i]   The TEXTAREA tag node is specified.
3094  * @return The conversion result is returned.
3095  */
3096 static char *
3097 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
3098 {
3099   chtml20_t *chtml20;
3100   Doc *doc;
3101   request_rec *r;
3102
3103   chtml20 = GET_CHTML20(pdoc);
3104   doc     = chtml20->doc;
3105   r       = doc->r;
3106
3107   W_L("</textarea>\r\n");
3108   chtml20->textarea_flag--;
3109
3110   return chtml20->out;
3111 }
3112
3113
3114 static char *
3115 s_chtml20_text_tag(void *pdoc, Node *child)
3116 {       
3117   chtml20_t *chtml20;
3118   Doc *doc;
3119   request_rec *r;
3120   char *textval;
3121   char *tmp;
3122   char *tdst;
3123   char one_byte[2];
3124   int           ii;
3125   int           tdst_len;
3126
3127   chtml20 = GET_CHTML20(pdoc);
3128   doc     = chtml20->doc;
3129   r       = doc->r;
3130   
3131   textval = qs_get_node_value(doc,child);
3132   if (strlen(textval) == 0) {
3133     return chtml20->out;
3134   }
3135   
3136   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3137   memset(tmp, 0, qs_get_node_size(doc,child)+1);
3138   
3139   tdst     = qs_alloc_zero_byte_string(r);
3140   memset(one_byte, 0, sizeof(one_byte));
3141   tdst_len = 0;
3142   
3143   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3144     char* out;
3145     int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3146     if (rtn != 0) {
3147       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3148       ii+=(rtn - 1);
3149       continue;
3150     }
3151     if (is_sjis_kanji(textval[ii])) {
3152       one_byte[0] = textval[ii+0];
3153       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3154       one_byte[0] = textval[ii+1];
3155       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3156       ii++;
3157     }
3158     else 
3159     if (chtml20->pre_flag) {
3160       one_byte[0] = textval[ii+0];
3161       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3162     }
3163     else 
3164     if (chtml20->textarea_flag) {
3165       one_byte[0] = textval[ii+0];
3166       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3167     }
3168     else 
3169     if (textval[ii] != '\r' && textval[ii] != '\n') {
3170       one_byte[0] = textval[ii+0];
3171       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3172     }
3173   }
3174   W_V(tdst);
3175   return chtml20->out;
3176 }
3177
3178
3179 /**
3180  * It is a handler who processes the BLOCKQUOTE tag.
3181  *
3182  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3183  *                     destination is specified.
3184  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3185  * @return The conversion result is returned.
3186  */
3187 static char *
3188 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3189 {
3190   chtml20_t *chtml20;
3191   Doc *doc;
3192   chtml20 = GET_CHTML20(pdoc);
3193   doc     = chtml20->doc;
3194   W_L("<blockquote>");
3195   return chtml20->out;
3196 }
3197
3198
3199 /**
3200  * It is a handler who processes the BLOCKQUOTE tag.
3201  *
3202  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3203  *                     destination is specified.
3204  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3205  * @return The conversion result is returned.
3206  */
3207 static char *
3208 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3209 {
3210   chtml20_t *chtml20;
3211   Doc *doc;
3212
3213   chtml20 = GET_CHTML20(pdoc);
3214   doc     = chtml20->doc;
3215   W_L("</blockquote>");
3216   return chtml20->out;
3217 }
3218
3219
3220 /**
3221  * It is a handler who processes the DIR tag.
3222  *
3223  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3224  *                     destination is specified.
3225  * @param node   [i]   The DIR tag node is specified.
3226  * @return The conversion result is returned.
3227  */
3228 static char *
3229 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3230 {
3231   chtml20_t *chtml20;
3232   Doc *doc;
3233   chtml20 = GET_CHTML20(pdoc);
3234   doc     = chtml20->doc;
3235   W_L("<dir>");
3236   return chtml20->out;
3237 }
3238
3239
3240 /**
3241  * It is a handler who processes the DIR tag.
3242  *
3243  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3244  *                     destination is specified.
3245  * @param node   [i]   The DIR tag node is specified.
3246  * @return The conversion result is returned.
3247  */
3248 static char *
3249 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3250 {
3251   chtml20_t *chtml20;
3252   Doc *doc;
3253
3254   chtml20 = GET_CHTML20(pdoc);
3255   doc     = chtml20->doc;
3256   W_L("</dir>");
3257   return chtml20->out;
3258 }
3259
3260
3261 /**
3262  * It is a handler who processes the DL tag.
3263  *
3264  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3265  *                     destination is specified.
3266  * @param node   [i]   The DL tag node is specified.
3267  * @return The conversion result is returned.
3268  */
3269 static char *
3270 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3271 {
3272   chtml20_t *chtml20;
3273   Doc *doc;
3274   chtml20 = GET_CHTML20(pdoc);
3275   doc     = chtml20->doc;
3276   W_L("<dl>");
3277   return chtml20->out;
3278 }
3279
3280
3281 /**
3282  * It is a handler who processes the DL tag.
3283  *
3284  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3285  *                     destination is specified.
3286  * @param node   [i]   The DL tag node is specified.
3287  * @return The conversion result is returned.
3288  */
3289 static char *
3290 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3291 {
3292   chtml20_t *chtml20;
3293   Doc *doc;
3294   chtml20 = GET_CHTML20(pdoc);
3295   doc     = chtml20->doc;
3296   W_L("</dl>");
3297   return chtml20->out;
3298 }
3299
3300
3301 /**
3302  * It is a handter who processes the DT tag.
3303  *
3304  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3305  *                     destination is specified.
3306  * @param node   [i]   The DT tag node is specified.
3307  * @return The conversion result is returned.
3308  */
3309 static char *
3310 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3311 {
3312   chtml20_t *chtml20;
3313   Doc *doc;
3314   chtml20 = GET_CHTML20(pdoc);
3315   doc     = chtml20->doc;
3316   W_L("<dt>");
3317   return chtml20->out;
3318 }
3319
3320
3321 /**
3322  * It is a handter who processes the DT tag.
3323  *
3324  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3325  *                     destination is specified.
3326  * @param node   [i]   The DT tag node is specified.
3327  * @return The conversion result is returned.
3328  */
3329 static char *
3330 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3331 {
3332   chtml20_t *chtml20;
3333   chtml20 = GET_CHTML20(pdoc);
3334   return chtml20->out;
3335 }
3336
3337
3338 /**
3339  * It is a handder who processes the DD tag.
3340  *
3341  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3342  *                     destination is specified.
3343  * @param node   [i]   The DD tag node is specified.
3344  * @return The conversion result is returned.
3345  */
3346 static char *
3347 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3348 {
3349   chtml20_t *chtml20;
3350   Doc *doc;
3351   chtml20 = GET_CHTML20(pdoc);
3352   doc     = chtml20->doc;
3353   W_L("<dd>");
3354   return chtml20->out;
3355 }
3356
3357
3358 /**
3359  * It is a handder who processes the DD tag.
3360  *
3361  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3362  *                     destination is specified.
3363  * @param node   [i]   The DD tag node is specified.
3364  * @return The conversion result is returned.
3365  */
3366 static char *
3367 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
3368 {
3369   chtml20_t *chtml20;
3370   chtml20 = GET_CHTML20(pdoc);
3371   return chtml20->out;
3372 }
3373
3374
3375 /**
3376  * It is a hanmenuer who processes the MENU tag.
3377  *
3378  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3379  *                     destination is specified.
3380  * @param node   [i]   The MENU tag node is specified.
3381  * @return The conversion result is returned.
3382  */
3383 static char *
3384 s_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
3385 {
3386   chtml20_t *chtml20;
3387   Doc *doc;
3388   chtml20 = GET_CHTML20(pdoc);
3389   doc     = chtml20->doc;
3390   W_L("<menu>");
3391   return chtml20->out;
3392 }
3393
3394
3395 /**
3396  * It is a hanmenuer who processes the MENU tag.
3397  *
3398  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3399  *                     destination is specified.
3400  * @param node   [i]   The MENU tag node is specified.
3401  * @return The conversion result is returned.
3402  */
3403 static char *
3404 s_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
3405 {
3406   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3407   Doc *doc = chtml20->doc;
3408   W_L("</menu>");
3409   return chtml20->out;
3410 }
3411
3412
3413 /**
3414  * It is a hanplaintexter who processes the PLAINTEXT tag.
3415  *
3416  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3417  *                     destination is specified.
3418  * @param node   [i]   The PLAINTEXT tag node is specified.
3419  * @return The conversion result is returned.
3420  */
3421 static char *
3422 s_chtml20_start_plaintext_tag(void *pdoc, Node *node)
3423 {
3424   chtml20_t *chtml20;
3425   Doc *doc;
3426
3427   chtml20 = GET_CHTML20(pdoc);
3428   doc     = chtml20->doc;
3429   W_L("<plaintext>");
3430   s_chtml20_start_plaintext_tag_inner(pdoc,node);
3431   return chtml20->out;
3432 }
3433
3434 static char *
3435 s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
3436 {
3437   chtml20_t *chtml20;
3438   Doc *doc;
3439   Node *child;
3440   chtml20 = GET_CHTML20(pdoc);
3441   doc     = chtml20->doc;
3442   for (child = qs_get_child_node(doc, node);
3443        child;
3444        child = qs_get_next_node(doc, child)) {
3445     W_V(child->otext);
3446     s_chtml20_start_plaintext_tag_inner(pdoc, child);
3447   }
3448   return chtml20->out;
3449 }
3450
3451
3452 /**
3453  * It is a hanplaintexter who processes the PLAINTEXT tag.
3454  *
3455  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3456  *                     destination is specified.
3457  * @param node   [i]   The PLAINTEXT tag node is specified.
3458  * @return The conversion result is returned.
3459  */
3460 static char *
3461 s_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3462 {
3463   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3464   return chtml20->out;
3465 }
3466 /*
3467  * vim:ts=2 et
3468  */