OSDN Git Service

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