OSDN Git Service

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