OSDN Git Service

* Added test code of the <plaintext> tag for au HDML converter.
[modchxj/mod_chxj.git] / src / chxj_chtml20.c
1 /*
2  * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include "chxj_chtml20.h"
18 #include "chxj_hdml.h"
19 #include "chxj_str_util.h"
20 #include "chxj_dump.h"
21 #include "chxj_img_conv.h"
22 #include "chxj_qr_code.h"
23 #include "chxj_encoding.h"
24 #include "chxj_buffered_write.h"
25
26
27 #define GET_CHTML20(X) ((chtml20_t*)(X))
28 #define W_L(X)          do { chtml20->out = BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, (X)); } while(0)
29 #define W_V(X)          do { chtml20->out = (X) ? BUFFERED_WRITE_VALUE(chtml20->out, &doc->buf, (X))  \
30                                                   : BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, ""); } while(0)
31
32 static char *s_chtml20_start_html_tag    (void *pdoc, Node *node);
33 static char *s_chtml20_end_html_tag      (void *pdoc, Node *node);
34 static char *s_chtml20_start_meta_tag    (void *pdoc, Node *node);
35 static char *s_chtml20_end_meta_tag      (void *pdoc, Node *node);
36 static char *s_chtml20_start_textarea_tag(void *pdoc, Node *node);
37 static char *s_chtml20_end_textarea_tag  (void *pdoc, Node *node);
38 static char *s_chtml20_start_p_tag       (void *pdoc, Node *node);
39 static char *s_chtml20_end_p_tag         (void *pdoc, Node *node);
40 static char *s_chtml20_start_pre_tag     (void *pdoc, Node *node);
41 static char *s_chtml20_end_pre_tag       (void *pdoc, Node *node);
42 static char *s_chtml20_start_h1_tag      (void *pdoc, Node *node);
43 static char *s_chtml20_end_h1_tag        (void *pdoc, Node *node);
44 static char *s_chtml20_start_h2_tag      (void *pdoc, Node *node);
45 static char *s_chtml20_end_h2_tag        (void *pdoc, Node *node);
46 static char *s_chtml20_start_h3_tag      (void *pdoc, Node *node);
47 static char *s_chtml20_end_h3_tag        (void *pdoc, Node *node);
48 static char *s_chtml20_start_h4_tag      (void *pdoc, Node *node);
49 static char *s_chtml20_end_h4_tag        (void *pdoc, Node *node);
50 static char *s_chtml20_start_h5_tag      (void *pdoc, Node *node);
51 static char *s_chtml20_end_h5_tag        (void *pdoc, Node *node);
52 static char *s_chtml20_start_h6_tag      (void *pdoc, Node *node);
53 static char *s_chtml20_end_h6_tag        (void *pdoc, Node *node);
54 static char *s_chtml20_start_ul_tag      (void *pdoc, Node *node);
55 static char *s_chtml20_end_ul_tag        (void *pdoc, Node *node);
56 static char *s_chtml20_start_ol_tag      (void *pdoc, Node *node);
57 static char *s_chtml20_end_ol_tag        (void *pdoc, Node *node);
58 static char *s_chtml20_start_li_tag      (void *pdoc, Node *node);
59 static char *s_chtml20_end_li_tag        (void *pdoc, Node *node);
60 static char *s_chtml20_start_head_tag    (void *pdoc, Node *node);
61 static char *s_chtml20_end_head_tag      (void *pdoc, Node *node);
62 static char *s_chtml20_start_title_tag   (void *pdoc, Node *node);
63 static char *s_chtml20_end_title_tag     (void *pdoc, Node *node);
64 static char *s_chtml20_start_base_tag    (void *pdoc, Node *node);
65 static char *s_chtml20_end_base_tag      (void *pdoc, Node *node);
66 static char *s_chtml20_start_body_tag    (void *pdoc, Node *node);
67 static char *s_chtml20_end_body_tag      (void *pdoc, Node *node);
68 static char *s_chtml20_start_a_tag       (void *pdoc, Node *node);
69 static char *s_chtml20_end_a_tag         (void *pdoc, Node *node);
70 static char *s_chtml20_start_br_tag      (void *pdoc, Node *node);
71 static char *s_chtml20_end_br_tag        (void *pdoc, Node *node);
72 static char *s_chtml20_start_tr_tag      (void *pdoc, Node *node);
73 static char *s_chtml20_end_tr_tag        (void *pdoc, Node *node);
74 static char *s_chtml20_start_font_tag    (void *pdoc, Node *node);
75 static char *s_chtml20_end_font_tag      (void *pdoc, Node *node);
76 static char *s_chtml20_start_form_tag    (void *pdoc, Node *node);
77 static char *s_chtml20_end_form_tag      (void *pdoc, Node *node);
78 static char *s_chtml20_start_input_tag   (void *pdoc, Node *node);
79 static char *s_chtml20_end_input_tag     (void *pdoc, Node *node);
80 static char *s_chtml20_start_center_tag  (void *pdoc, Node *node);
81 static char *s_chtml20_end_center_tag    (void *pdoc, Node *node);
82 static char *s_chtml20_start_hr_tag      (void *pdoc, Node *node);
83 static char *s_chtml20_end_hr_tag        (void *pdoc, Node *node);
84 static char *s_chtml20_start_img_tag     (void *pdoc, Node *node);
85 static char *s_chtml20_end_img_tag       (void *pdoc, Node *node);
86 static char *s_chtml20_start_select_tag  (void *pdoc, Node *node);
87 static char *s_chtml20_end_select_tag    (void *pdoc, Node *node);
88 static char *s_chtml20_start_option_tag  (void *pdoc, Node *node);
89 static char *s_chtml20_end_option_tag    (void *pdoc, Node *node);
90 static char *s_chtml20_start_div_tag     (void *pdoc, Node *node);
91 static char *s_chtml20_end_div_tag       (void *pdoc, Node *node);
92 static char *s_chtml20_start_blockquote_tag(void *pdoc, Node *node);
93 static char *s_chtml20_end_blockquote_tag  (void *pdoc, Node *node);
94 static char *s_chtml20_start_dir_tag     (void *pdoc, Node *node);
95 static char *s_chtml20_end_dir_tag       (void *pdoc, Node *node);
96 static char *s_chtml20_start_dl_tag      (void *pdoc, Node *node);
97 static char *s_chtml20_end_dl_tag        (void *pdoc, Node *node);
98 static char *s_chtml20_start_dt_tag      (void *pdoc, Node *node);
99 static char *s_chtml20_end_dt_tag        (void *pdoc, Node *node);
100 static char *s_chtml20_start_dd_tag      (void *pdoc, Node *node);
101 static char *s_chtml20_end_dd_tag        (void *pdoc, Node *node);
102 static char *s_chtml20_start_menu_tag    (void *pdoc, Node *node);
103 static char *s_chtml20_end_menu_tag      (void *pdoc, Node *node);
104 static char *s_chtml20_start_plaintext_tag       (void *pdoc, Node *node);
105 static char *s_chtml20_start_plaintext_tag_inner (void *pdoc, Node *node);
106 static char *s_chtml20_end_plaintext_tag         (void *pdoc, Node *node);
107 static char *s_chtml20_start_blink_tag   (void *pdoc, Node *node);
108 static char *s_chtml20_end_blink_tag     (void *pdoc, Node *node);
109 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
1046     char *name;
1047     char *value;
1048
1049     name  = qs_get_attr_name(doc,attr);
1050     value = qs_get_attr_value(doc,attr);
1051
1052     switch(*name) {
1053     case 'n':
1054     case 'N':
1055       if (strcasecmp(name, "name") == 0) {
1056         /*--------------------------------------------------------------------*/
1057         /* CHTML1.0                                                           */
1058         /*--------------------------------------------------------------------*/
1059         W_L(" name=\"");
1060         W_V(value);
1061         W_L("\"");
1062       }
1063       break;
1064
1065     case 'h':
1066     case 'H':
1067       if (strcasecmp(name, "href") == 0) {
1068         /*--------------------------------------------------------------------*/
1069         /* CHTML1.0                                                           */
1070         /*--------------------------------------------------------------------*/
1071         value = chxj_encoding_parameter(r, value);
1072         value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1073         W_L(" href=\"");
1074         W_V(value);
1075         W_L("\"");
1076       }
1077       break;
1078
1079     case 'a':
1080     case 'A':
1081       if (strcasecmp(name, "accesskey") == 0) {
1082         /*--------------------------------------------------------------------*/
1083         /* CHTML1.0                                                           */
1084         /*--------------------------------------------------------------------*/
1085         W_L(" accesskey=\"");
1086         W_V(value);
1087         W_L("\"");
1088       }
1089       break;
1090
1091     case 'c':
1092     case 'C':
1093       if (strcasecmp(name, "cti") == 0) {
1094         /*--------------------------------------------------------------------*/
1095         /* CHTML 2.0                                                          */
1096         /*--------------------------------------------------------------------*/
1097         W_L(" cti=\"");
1098         W_V(value);
1099         W_L("\"");
1100       }
1101       break;
1102
1103     case 'i':
1104     case 'I':
1105       if (strcasecmp(name, "ijam") == 0) {
1106         /*--------------------------------------------------------------------*/
1107         /* CHTML 3.0                                                          */
1108         /*--------------------------------------------------------------------*/
1109         /* ignore */
1110       }
1111       else
1112       if (strcasecmp(name, "ista") == 0) {
1113         /*--------------------------------------------------------------------*/
1114         /* CHTML 4.0                                                          */
1115         /*--------------------------------------------------------------------*/
1116         /* ignore */
1117       }
1118       else
1119       if (strcasecmp(name, "ilet") == 0) {
1120         /*--------------------------------------------------------------------*/
1121         /* CHTML 5.0                                                          */
1122         /*--------------------------------------------------------------------*/
1123         /* ignore */
1124       }
1125       else
1126       if (strcasecmp(name, "iswf") == 0) {
1127         /*--------------------------------------------------------------------*/
1128         /* CHTML 5.0                                                          */
1129         /*--------------------------------------------------------------------*/
1130         /* ignore */
1131       }
1132       else
1133       if (strcasecmp(name, "irst") == 0) {
1134         /*--------------------------------------------------------------------*/
1135         /* CHTML 5.0                                                          */
1136         /*--------------------------------------------------------------------*/
1137         /* ignore */
1138       }
1139       break;
1140
1141     case 'u':
1142     case 'U':
1143       if (strcasecmp(name, "utn") == 0) {
1144         /*--------------------------------------------------------------------*/
1145         /* CHTML 3.0                                                          */
1146         /*--------------------------------------------------------------------*/
1147         /* ignore */
1148       }
1149       break;
1150
1151     case 't':
1152     case 'T':
1153       if (strcasecmp(name, "telbook") == 0) {
1154         /*--------------------------------------------------------------------*/
1155         /* CHTML 3.0                                                          */
1156         /*--------------------------------------------------------------------*/
1157         /* ignore */
1158       }
1159       break;
1160
1161     case 'k':
1162     case 'K':
1163       if (strcasecmp(name, "kana") == 0) {
1164         /*--------------------------------------------------------------------*/
1165         /* CHTML 3.0                                                          */
1166         /*--------------------------------------------------------------------*/
1167         /* ignore */
1168       }
1169       break;
1170
1171     case 'e':
1172     case 'E':
1173       if (strcasecmp(name, "email") == 0) {
1174         /*--------------------------------------------------------------------*/
1175         /* CHTML 3.0                                                          */
1176         /*--------------------------------------------------------------------*/
1177         /* ignore */
1178       }
1179       break;
1180
1181     default:
1182       break;
1183     }
1184   }
1185   W_L(">");
1186   return chtml20->out;
1187 }
1188
1189
1190 /**
1191  * It is a handler who processes the A tag.
1192  *
1193  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1194  *                     destination is specified.
1195  * @param node   [i]   The A tag node is specified.
1196  * @return The conversion result is returned.
1197  */
1198 static char *
1199 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1200 {
1201   chtml20_t *chtml20;
1202   Doc *doc;
1203   request_rec *r;
1204
1205   chtml20 = GET_CHTML20(pdoc);
1206   doc     = chtml20->doc;
1207   r       = doc->r;
1208
1209   W_L("</a>");
1210   return chtml20->out;
1211 }
1212
1213
1214 /**
1215  * It is a handler who processes the BR tag.
1216  *
1217  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1218  *                     destination is specified.
1219  * @param node   [i]   The BR tag node is specified.
1220  * @return The conversion result is returned.
1221  */
1222 static char *
1223 s_chtml20_start_br_tag(void *pdoc, Node *node) 
1224 {
1225   chtml20_t *chtml20;
1226   Doc *doc;
1227   request_rec *r;
1228   Attr *attr;
1229
1230   chtml20 = GET_CHTML20(pdoc);
1231   doc     = chtml20->doc;
1232   r       = doc->r;
1233
1234   W_L("<br");
1235   /*--------------------------------------------------------------------------*/
1236   /* Get Attributes                                                           */
1237   /*--------------------------------------------------------------------------*/
1238   for (attr = qs_get_attr(doc,node);
1239        attr;
1240        attr = qs_get_next_attr(doc,attr)) {
1241     char *name;
1242     char *value;
1243
1244     name  = qs_get_attr_name(doc,attr);
1245     value = qs_get_attr_value(doc,attr);
1246
1247     if (STRCASEEQ('c','C',"clear",name)) {
1248       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1249         W_L(" clear=\"");
1250         W_V(value);
1251         W_L("\"");
1252       }
1253     }
1254   }
1255   W_L(">");
1256   return chtml20->out;
1257 }
1258
1259
1260 /**
1261  * It is a handler who processes the BR tag.
1262  *
1263  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1264  *                     destination is specified.
1265  * @param node   [i]   The BR tag node is specified.
1266  * @return The conversion result is returned.
1267  */
1268 static char *
1269 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1270 {
1271   chtml20_t *chtml20;
1272   Doc *doc;
1273   request_rec *r;
1274
1275   chtml20 = GET_CHTML20(pdoc);
1276   doc     = chtml20->doc;
1277   r       = doc->r;
1278
1279   return chtml20->out;
1280 }
1281
1282
1283 /**
1284  * It is a handler who processes the TR tag.
1285  *
1286  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1287  *                     destination is specified.
1288  * @param node   [i]   The TR tag node is specified.
1289  * @return The conversion result is returned.
1290  */
1291 static char *
1292 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1293 {
1294   chtml20_t *chtml20;
1295   Doc *doc;
1296   request_rec *r;
1297
1298   chtml20 = GET_CHTML20(pdoc);
1299   doc     = chtml20->doc;
1300   r       = doc->r;
1301
1302   return chtml20->out;
1303 }
1304
1305
1306 /**
1307  * It is a handler who processes the TR tag.
1308  *
1309  * @param chtml20  [i/o] The pointer to the CHTML structure at the output
1310  *                     destination is specified.
1311  * @param node   [i]   The TR tag node is specified.
1312  * @return The conversion result is returned.
1313  */
1314 static char *
1315 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1316 {
1317   chtml20_t *chtml20;
1318   Doc *doc;
1319   request_rec *r;
1320
1321   chtml20 = GET_CHTML20(pdoc);
1322   doc     = chtml20->doc;
1323   r       = doc->r;
1324
1325   W_L("<br>\r\n");
1326   return chtml20->out;
1327 }
1328
1329
1330 /**
1331  * It is a handler who processes the FONT tag.
1332  *
1333  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1334  *                     destination is specified.
1335  * @param node   [i]   The FONT tag node is specified.
1336  * @return The conversion result is returned.
1337  */
1338 static char *
1339 s_chtml20_start_font_tag(void *pdoc, Node *node) 
1340 {
1341   chtml20_t *chtml20;
1342   Doc *doc;
1343   request_rec *r;
1344   Attr *attr;
1345
1346   chtml20 = GET_CHTML20(pdoc);
1347   doc     = chtml20->doc;
1348   r       = doc->r;
1349
1350
1351   W_L("<font");
1352   /*--------------------------------------------------------------------------*/
1353   /* Get Attributes                                                           */
1354   /*--------------------------------------------------------------------------*/
1355   for (attr = qs_get_attr(doc,node);
1356        attr; 
1357        attr = qs_get_next_attr(doc,attr)) {
1358
1359     char *name;
1360     char *value;
1361
1362     name  = qs_get_attr_name(doc,attr);
1363     value = qs_get_attr_value(doc,attr);
1364
1365     switch(*name) {
1366     case 'c':
1367     case 'C':
1368       if (strcasecmp(name, "color") == 0) {
1369         W_L(" color=\"");
1370         W_V(value);
1371         W_L("\"");
1372       }
1373       break;
1374
1375     case 's':
1376     case 'S':
1377       if (strcasecmp(name, "size") == 0) {
1378         /*--------------------------------------------------------------------*/
1379         /* CHTML 5.0                                                          */
1380         /*--------------------------------------------------------------------*/
1381         /* ignore */
1382       }
1383       break;
1384
1385     default:
1386       break;
1387     }
1388   }
1389   W_L(">");
1390   return chtml20->out;
1391 }
1392
1393
1394 /**
1395  * It is a handler who processes the FONT tag.
1396  *
1397  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1398  *                     destination is specified.
1399  * @param node   [i]   The FONT tag node is specified.
1400  * @return The conversion result is returned.
1401  */
1402 static char *
1403 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1404 {
1405   chtml20_t *chtml20;
1406   Doc *doc;
1407   request_rec *r;
1408
1409   chtml20 = GET_CHTML20(pdoc);
1410   doc     = chtml20->doc;
1411   r       = doc->r;
1412
1413   W_L("</font>");
1414   return chtml20->out;
1415 }
1416
1417
1418 /**
1419  * It is a handler who processes the FORM tag.
1420  *
1421  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1422  *                     destination is specified.
1423  * @param node   [i]   The FORM tag node is specified.
1424  * @return The conversion result is returned.
1425  */
1426 static char *
1427 s_chtml20_start_form_tag(void *pdoc, Node *node) 
1428 {
1429   chtml20_t *chtml20;
1430   Doc *doc;
1431   request_rec *r;
1432   Attr *attr;
1433
1434   chtml20 = GET_CHTML20(pdoc);
1435   doc     = chtml20->doc;
1436   r       = doc->r;
1437
1438   W_L("<form");
1439   /*--------------------------------------------------------------------------*/
1440   /* Get Attributes                                                           */
1441   /*--------------------------------------------------------------------------*/
1442   for (attr = qs_get_attr(doc,node);
1443        attr;
1444        attr = qs_get_next_attr(doc,attr)) {
1445
1446     char *name;
1447     char *value;
1448
1449     name  = qs_get_attr_name(doc,attr);
1450     value = qs_get_attr_value(doc,attr);
1451
1452     switch(*name) {
1453     case 'a':
1454     case 'A':
1455       if (strcasecmp(name, "action") == 0) {
1456         /*--------------------------------------------------------------------*/
1457         /* CHTML 1.0                                                          */
1458         /*--------------------------------------------------------------------*/
1459         value = chxj_encoding_parameter(r, value);
1460         value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1461
1462         W_L(" action=\"");
1463         W_V(value);
1464         W_L("\"");
1465       }
1466       break;
1467
1468     case 'm':
1469     case 'M':
1470       if (strcasecmp(name, "method") == 0) {
1471         /*--------------------------------------------------------------------*/
1472         /* CHTML 1.0                                                          */
1473         /*--------------------------------------------------------------------*/
1474         W_L(" method=\"");
1475         W_V(value);
1476         W_L("\"");
1477       }
1478       break;
1479
1480     case 'u':
1481     case 'U':
1482       if (strcasecmp(name, "utn") == 0) {
1483         /*--------------------------------------------------------------------*/
1484         /* CHTML 3.0                                                          */
1485         /*--------------------------------------------------------------------*/
1486         /* ignore */
1487       }
1488       break;
1489
1490     default:
1491       break;
1492     }
1493   }
1494   W_L(">");
1495   return chtml20->out;
1496 }
1497
1498
1499 /**
1500  * It is a handler who processes the FORM tag.
1501  *
1502  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1503  *                     destination is specified.
1504  * @param node   [i]   The FORM tag node is specified.
1505  * @return The conversion result is returned.
1506  */
1507 static char *
1508 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1509 {
1510   chtml20_t *chtml20;
1511   Doc *doc;
1512   request_rec *r;
1513
1514   chtml20 = GET_CHTML20(pdoc);
1515   doc     = chtml20->doc;
1516   r       = doc->r;
1517
1518   W_L("</form>");
1519   return chtml20->out;
1520 }
1521
1522
1523 /**
1524  * It is a handler who processes the INPUT tag.
1525  *
1526  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1527  *                     destination is specified.
1528  * @param node   [i]   The INPUT tag node is specified.
1529  * @return The conversion result is returned.
1530  */
1531 static char *
1532 s_chtml20_start_input_tag(void *pdoc, Node *node) 
1533 {
1534   chtml20_t *chtml20;
1535   Doc *doc;
1536   request_rec *r;
1537   char *max_length  = NULL;
1538   char *type        = NULL;
1539   char *name        = NULL;
1540   char *value       = NULL;
1541   char *istyle      = NULL;
1542   char *size        = NULL;
1543   char *checked     = NULL;
1544   char *accesskey   = NULL;
1545
1546   chtml20 = GET_CHTML20(pdoc);
1547   doc     = chtml20->doc;
1548   r       = doc->r;
1549
1550
1551   W_L("<input");
1552   /*--------------------------------------------------------------------------*/
1553   /* Get Attributes                                                           */
1554   /*--------------------------------------------------------------------------*/
1555
1556   type       = qs_get_type_attr(doc, node, r);
1557   name       = qs_get_name_attr(doc, node, r);
1558   value      = qs_get_value_attr(doc,node,r);
1559   istyle     = qs_get_istyle_attr(doc,node,r);
1560   max_length = qs_get_maxlength_attr(doc,node,r);
1561   checked    = qs_get_checked_attr(doc,node,r);
1562   accesskey  = qs_get_accesskey_attr(doc, node, r);
1563   size       = qs_get_size_attr(doc, node, r);
1564
1565   if (type) {
1566     type = qs_trim_string(doc->buf.pool, type);
1567     if (type && (STRCASEEQ('t','T',"text",    type) ||
1568                  STRCASEEQ('p','P',"password",type) ||
1569                  STRCASEEQ('c','C',"checkbox",type) ||
1570                  STRCASEEQ('r','R',"radio",   type) ||
1571                  STRCASEEQ('h','H',"hidden",  type) ||
1572                  STRCASEEQ('s','S',"submit",  type) ||
1573                  STRCASEEQ('r','R',"reset",   type))) {
1574       W_L(" type=\"");
1575       W_V(type);
1576       W_L("\"");
1577     }
1578   }
1579   if (size && *size) {
1580     W_L(" size=\"");
1581     W_V(size);
1582     W_L("\"");
1583   }
1584   if (name && *name) {
1585     W_L(" name=\"");
1586     W_V(name);
1587     W_L("\"");
1588   }
1589   if (value && *value) {
1590     W_L(" value=\"");
1591     W_V(value);
1592     W_L("\"");
1593   }
1594   if (accesskey && *accesskey) {
1595     W_L(" accesskey=\"");
1596     W_V(accesskey);
1597     W_L("\"");
1598   }
1599   if (istyle) {
1600     /*------------------------------------------------------------------------*/
1601     /* CHTML 2.0                                                              */
1602     /*------------------------------------------------------------------------*/
1603     if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1604       W_L(" istyle=\"");
1605       W_V(istyle);
1606       W_L("\"");
1607     }
1608   }
1609
1610   /*--------------------------------------------------------------------------*/
1611   /* The figure is default for the password.                                  */
1612   /*--------------------------------------------------------------------------*/
1613   if (max_length && *max_length) {
1614     if (chxj_chk_numeric(max_length) != 0) {
1615       max_length = apr_psprintf(doc->buf.pool, "0");
1616     }
1617     if (istyle && *istyle == '1') {
1618       char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1619       W_V(vv);
1620     }
1621     else {
1622       char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1623       W_V(vv);
1624     }
1625   }
1626
1627   if (checked) {
1628     W_L(" checked");
1629   }
1630   W_L(">");
1631   return chtml20->out;
1632 }
1633
1634
1635 /**
1636  * It is a handler who processes the INPUT tag.
1637  *
1638  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1639  *                     destination is specified.
1640  * @param node   [i]   The INPUT tag node is specified.
1641  * @return The conversion result is returned.
1642  */
1643 static char *
1644 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1645 {
1646   chtml20_t *chtml20;
1647   Doc *doc;
1648   request_rec *r;
1649
1650   chtml20 = GET_CHTML20(pdoc);
1651   doc     = chtml20->doc;
1652   r       = doc->r;
1653
1654   return chtml20->out;
1655 }
1656
1657
1658 /**
1659  * It is a handler who processes the CENTER tag.
1660  *
1661  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1662  *                     destination is specified.
1663  * @param node   [i]   The CENTER tag node is specified.
1664  * @return The conversion result is returned.
1665  */
1666 static char *
1667 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1668 {
1669   chtml20_t *chtml20;
1670   Doc *doc;
1671   request_rec *r;
1672
1673   chtml20 = GET_CHTML20(pdoc);
1674   doc     = chtml20->doc;
1675   r       = doc->r;
1676
1677   W_L("<center>");
1678   return chtml20->out;
1679 }
1680
1681
1682 /**
1683  * It is a handler who processes the CENTER tag.
1684  *
1685  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1686  *                     destination is specified.
1687  * @param node   [i]   The CENTER tag node is specified.
1688  * @return The conversion result is returned.
1689  */
1690 static char *
1691 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1692 {
1693   chtml20_t *chtml20;
1694   Doc *doc;
1695   request_rec *r;
1696
1697   chtml20 = GET_CHTML20(pdoc);
1698   doc     = chtml20->doc;
1699   r       = doc->r;
1700
1701   W_L("</center>");
1702   return chtml20->out;
1703 }
1704
1705
1706 /**
1707  * It is a handler who processes the UL tag.
1708  *
1709  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1710  *                     destination is specified.
1711  * @param node   [i]   The UL tag node is specified.
1712  * @return The conversion result is returned.
1713  */
1714 static char *
1715 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
1716 {
1717   chtml20_t *chtml20;
1718   Doc *doc;
1719   request_rec *r;
1720
1721   chtml20 = GET_CHTML20(pdoc);
1722   doc     = chtml20->doc;
1723   r       = doc->r;
1724
1725   W_L("<ul>");
1726   return chtml20->out;
1727 }
1728
1729
1730 /**
1731  * It is a handler who processes the UL tag.
1732  *
1733  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1734  *                     destination is specified.
1735  * @param node   [i]   The UL tag node is specified.
1736  * @return The conversion result is returned.
1737  */
1738 static char *
1739 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1740 {
1741   chtml20_t*    chtml20;
1742   Doc*          doc;
1743   request_rec*  r;
1744
1745   chtml20 = GET_CHTML20(pdoc);
1746   doc     = chtml20->doc;
1747   r       = doc->r;
1748
1749   W_L("</ul>");
1750   return chtml20->out;
1751 }
1752
1753
1754 /**
1755  * It is a handler who processes the OL tag.
1756  *
1757  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1758  *                     destination is specified.
1759  * @param node   [i]   The OL tag node is specified.
1760  * @return The conversion result is returned.
1761  */
1762 static char *
1763 s_chtml20_start_ol_tag(void *pdoc, Node *node) 
1764 {
1765   chtml20_t *chtml20;
1766   Doc *doc;
1767   request_rec *r;
1768   Attr *attr;
1769
1770   chtml20 = GET_CHTML20(pdoc);
1771   doc     = chtml20->doc;
1772   r       = doc->r;
1773
1774   W_L("<ol");
1775   /*--------------------------------------------------------------------------*/
1776   /* Get Attributes                                                           */
1777   /*--------------------------------------------------------------------------*/
1778   for (attr = qs_get_attr(doc,node);
1779        attr;
1780        attr = qs_get_next_attr(doc,attr)) {
1781     char *name = qs_get_attr_name(doc,attr);
1782     char *value = qs_get_attr_value(doc,attr);
1783     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1784       W_L(" type=\"");
1785       W_V(value);
1786       W_L("\"");
1787     }
1788     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1789       W_L(" start=\"");
1790       W_V(value);
1791       W_L("\"");
1792     }
1793   }
1794   W_L(">");
1795   return chtml20->out;
1796 }
1797
1798
1799 /**
1800  * It is a handler who processes the OL tag.
1801  *
1802  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1803  *                     destination is specified.
1804  * @param node   [i]   The OL tag node is specified.
1805  * @return The conversion result is returned.
1806  */
1807 static char *
1808 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
1809 {
1810   chtml20_t *chtml20;
1811   Doc *doc;
1812   request_rec *r;
1813
1814   chtml20 = GET_CHTML20(pdoc);
1815   doc     = chtml20->doc;
1816   r       = doc->r;
1817
1818   W_L("</ol>");
1819   return chtml20->out;
1820 }
1821
1822
1823 /**
1824  * It is a handler who processes the LI tag.
1825  *
1826  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1827  *                     destination is specified.
1828  * @param node   [i]   The LI tag node is specified.
1829  * @return The conversion result is returned.
1830  */
1831 static char *
1832 s_chtml20_start_li_tag(void *pdoc, Node *node) 
1833 {
1834   chtml20_t *chtml20;
1835   Doc *doc;
1836   request_rec *r;
1837   Attr *attr;
1838
1839   chtml20 = GET_CHTML20(pdoc);
1840   doc     = chtml20->doc;
1841   r       = doc->r;
1842
1843   W_L("<li");
1844   /*--------------------------------------------------------------------------*/
1845   /* Get Attributes                                                           */
1846   /*--------------------------------------------------------------------------*/
1847   for (attr = qs_get_attr(doc,node);
1848        attr;
1849        attr = qs_get_next_attr(doc,attr)) {
1850     char *name = qs_get_attr_name(doc,attr);
1851     char *value = qs_get_attr_value(doc,attr);
1852     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1853       W_L(" type=\"");
1854       W_V(value);
1855       W_L("\"");
1856     }
1857     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1858       W_L(" value=\"");
1859       W_V(value);
1860       W_L("\"");
1861     }
1862   }
1863   W_L(">");
1864   return chtml20->out;
1865 }
1866
1867
1868 /**
1869  * It is a handler who processes the LI tag.
1870  *
1871  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1872  *                     destination is specified.
1873  * @param node   [i]   The LI tag node is specified.
1874  * @return The conversion result is returned.
1875  */
1876 static char *
1877 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child)) 
1878 {
1879   chtml20_t *chtml20 = GET_CHTML20(pdoc);
1880   return chtml20->out;
1881 }
1882
1883
1884 /**
1885  * It is a handler who processes the HR tag.
1886  *
1887  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1888  *                     destination is specified.
1889  * @param node   [i]   The HR tag node is specified.
1890  * @return The conversion result is returned.
1891  */
1892 static char *
1893 s_chtml20_start_hr_tag(void *pdoc, Node *node) 
1894 {
1895   chtml20_t *chtml20;
1896   Doc *doc;
1897   request_rec *r;
1898   Attr *attr;
1899
1900   chtml20 = GET_CHTML20(pdoc);
1901   doc     = chtml20->doc;
1902   r       = doc->r;
1903
1904
1905   W_L("<hr");
1906   for (attr = qs_get_attr(doc,node);
1907        attr; 
1908        attr = qs_get_next_attr(doc,attr)) {
1909
1910     char *name;
1911     char *value;
1912
1913     name  = qs_get_attr_name(doc,attr);
1914     value = qs_get_attr_value(doc,attr);
1915
1916     switch(*name) {
1917     case 'a':
1918     case 'A':
1919       if (strcasecmp(name, "align") == 0) {
1920         /*--------------------------------------------------------------------*/
1921         /* CHTML 1.0                                                          */
1922         /*--------------------------------------------------------------------*/
1923         if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1924           W_L(" align=\"");
1925           W_V(value);
1926           W_L("\"");
1927         }
1928       }
1929       break;
1930
1931     case 's':
1932     case 'S':
1933       if (strcasecmp(name, "size") == 0) {
1934         /*--------------------------------------------------------------------*/
1935         /* CHTML 1.0                                                          */
1936         /*--------------------------------------------------------------------*/
1937         if (value && value[0] != '\0') {
1938           W_L(" size=\"");
1939           W_V(value);
1940           W_L("\"");
1941         }
1942       }
1943       break;
1944
1945     case 'w':
1946     case 'W':
1947       if (strcasecmp(name, "width") == 0) {
1948         /*--------------------------------------------------------------------*/
1949         /* CHTML 1.0                                                          */
1950         /*--------------------------------------------------------------------*/
1951         if (value && value[0] != '\0') {
1952           W_L(" width=\"");
1953           W_V(value);
1954           W_L("\"");
1955         }
1956       }
1957       break;
1958
1959     case 'n':
1960     case 'N':
1961       if (strcasecmp(name, "noshade") == 0) {
1962         /*--------------------------------------------------------------------*/
1963         /* CHTML 1.0                                                          */
1964         /*--------------------------------------------------------------------*/
1965         W_L(" noshade");
1966       }
1967       break;
1968
1969     case 'c':
1970     case 'C':
1971       if (strcasecmp(name, "color") == 0) {
1972         /*--------------------------------------------------------------------*/
1973         /* CHTML 4.0                                                          */
1974         /*--------------------------------------------------------------------*/
1975         /* ignore */
1976       }
1977       break;
1978
1979     default:
1980       break;
1981     }
1982   }
1983   W_L(">");
1984   return chtml20->out;
1985 }
1986
1987
1988 /**
1989  * It is a handler who processes the HR tag.
1990  *
1991  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1992  *                     destination is specified.
1993  * @param node   [i]   The HR tag node is specified.
1994  * @return The conversion result is returned.
1995  */
1996 static char *
1997 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1998 {
1999   chtml20_t *chtml20;
2000   Doc *doc;
2001   request_rec *r;
2002
2003   chtml20 = GET_CHTML20(pdoc);
2004   doc     = chtml20->doc;
2005   r       = doc->r;
2006
2007   return chtml20->out;
2008 }
2009
2010
2011 /**
2012  * It is a handler who processes the IMG tag.
2013  *
2014  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2015  *                     destination is specified.
2016  * @param node   [i]   The IMG tag node is specified.
2017  * @return The conversion result is returned.
2018  */
2019 static char *
2020 s_chtml20_start_img_tag(void *pdoc, Node *node) 
2021 {
2022   chtml20_t *chtml20;
2023   Doc *doc;
2024   request_rec *r;
2025   Attr *attr;
2026 #ifndef IMG_NOT_CONVERT_FILENAME
2027   device_table *spec;
2028 #endif
2029
2030   chtml20 = GET_CHTML20(pdoc);
2031   doc     = chtml20->doc;
2032   r       = doc->r;
2033
2034 #ifndef IMG_NOT_CONVERT_FILENAME
2035   spec = chtml20->spec;
2036 #endif
2037
2038   W_L("<img");
2039   /*-------------------------------------------------------------------------*/
2040   /* Get Attributes                                                          */
2041   /*-------------------------------------------------------------------------*/
2042   for (attr = qs_get_attr(doc,node);
2043        attr;
2044        attr = qs_get_next_attr(doc,attr)) {
2045     char *name  = qs_get_attr_name(doc,attr);
2046     char *value = qs_get_attr_value(doc,attr);
2047     switch(*name) {
2048     case 's':
2049     case 'S':
2050       if (strcasecmp(name, "src") == 0) {
2051         /*-------------------------------------------------------------------*/
2052         /* CHTML 1.0                                                         */
2053         /*-------------------------------------------------------------------*/
2054 #ifdef IMG_NOT_CONVERT_FILENAME
2055         value = chxj_encoding_parameter(r, value);
2056         value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2057         if (value) {
2058           value = apr_psprintf(doc->buf.pool,
2059                                "%s%c%s=true",
2060                                value,
2061                                (strchr(value, '?')) ? '&' : '?',
2062                                CHXJ_COOKIE_NOUPDATE_PARAM);
2063         }
2064         W_L(" src=\"");
2065         W_V(value);
2066         W_L("\"");
2067 #else
2068         value = chxj_img_conv(r, spec, value);
2069         value = chxj_encoding_parameter(r, value);
2070         value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2071         if (value) {
2072           value = apr_psprintf(doc->buf.pool,
2073                                "%s%c%s=true",
2074                                value,
2075                                (strchr(value, '?')) ? '&' : '?',
2076                                CHXJ_COOKIE_NOUPDATE_PARAM);
2077         }
2078         W_L(" src=\"");
2079         W_V(value);
2080         W_L("\"");
2081 #endif
2082       }
2083       break;
2084
2085     case 'a':
2086     case 'A':
2087       if (strcasecmp(name, "align" ) == 0) {
2088         /*--------------------------------------------------------------------*/
2089         /* CHTML 1.0                                                          */
2090         /*--------------------------------------------------------------------*/
2091         if (value && (STRCASEEQ('t','T',"top",   value) ||
2092                       STRCASEEQ('m','M',"middle",value) ||
2093                       STRCASEEQ('b','B',"bottom",value) ||
2094                       STRCASEEQ('l','L',"left",  value) ||
2095                       STRCASEEQ('r','R',"right", value))) {
2096           W_L(" align=\"");
2097           W_V(value);
2098           W_L("\"");
2099         }
2100       }
2101       else if (strcasecmp(name, "alt"   ) == 0 && value && *value) {
2102         /*--------------------------------------------------------------------*/
2103         /* CHTML 1.0                                                          */
2104         /*--------------------------------------------------------------------*/
2105         W_L(" alt=\"");
2106         W_V(value);
2107         W_L("\"");
2108       }
2109       break;
2110
2111     case 'w':
2112     case 'W':
2113       if (strcasecmp(name, "width" ) == 0 && value && *value) {
2114         /*--------------------------------------------------------------------*/
2115         /* CHTML 1.0                                                          */
2116         /*--------------------------------------------------------------------*/
2117         W_L(" width=\"");
2118         W_V(value);
2119         W_L("\"");
2120       }
2121       break;
2122
2123     case 'h':
2124     case 'H':
2125       if (strcasecmp(name, "height") == 0 && value && *value) {
2126         /*--------------------------------------------------------------------*/
2127         /* CHTML 1.0                                                          */
2128         /*--------------------------------------------------------------------*/
2129         W_L(" height=\"");
2130         W_V(value);
2131         W_L("\"");
2132       }
2133       else if (strcasecmp(name, "hspace") == 0 && value && *value) {
2134         /*--------------------------------------------------------------------*/
2135         /* CHTML 1.0                                                          */
2136         /*--------------------------------------------------------------------*/
2137         W_L(" hspace=\"");
2138         W_V(value);
2139         W_L("\"");
2140       }
2141       break;
2142
2143     case 'v':
2144     case 'V':
2145       if (strcasecmp(name, "vspace") == 0 && value && *value) {
2146         /*--------------------------------------------------------------------*/
2147         /* CHTML 1.0                                                          */
2148         /*--------------------------------------------------------------------*/
2149         W_L(" vspace=\"");
2150         W_V(value);
2151         W_L("\"");
2152       }
2153       break;
2154
2155     default:
2156       break;
2157     }
2158   }
2159   W_L(">");
2160   return chtml20->out;
2161 }
2162
2163
2164 /**
2165  * It is a handler who processes the IMG tag.
2166  *
2167  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2168  *                     destination is specified.
2169  * @param node   [i]   The IMG tag node is specified.
2170  * @return The conversion result is returned.
2171  */
2172 static char *
2173 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2174 {
2175   chtml20_t *chtml20;
2176   Doc *doc;
2177   request_rec *r;
2178
2179   chtml20 = GET_CHTML20(pdoc);
2180   doc     = chtml20->doc;
2181   r       = doc->r;
2182
2183   return chtml20->out;
2184 }
2185
2186
2187 /**
2188  * It is a handler who processes the SELECT tag.
2189  *
2190  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2191  *                     destination is specified.
2192  * @param node   [i]   The SELECT tag node is specified.
2193  * @return The conversion result is returned.
2194  */
2195 static char *
2196 s_chtml20_start_select_tag(void *pdoc, Node *child)
2197 {
2198   chtml20_t *chtml20;
2199   Doc *doc;
2200   request_rec *r;
2201   Attr *attr;
2202
2203   chtml20 = GET_CHTML20(pdoc);
2204   doc     = chtml20->doc;
2205   r       = doc->r;
2206
2207   char *size      = NULL;
2208   char *name      = NULL;
2209   char *multiple  = NULL;
2210
2211   W_L("<select");
2212   for (attr = qs_get_attr(doc,child);
2213        attr;
2214        attr = qs_get_next_attr(doc,attr)) {
2215     char *nm = qs_get_attr_name(doc,attr);
2216     char *val = qs_get_attr_value(doc,attr);
2217     switch(*nm) {
2218     case 's':
2219     case 'S':
2220       if (strcasecmp(nm, "size") == 0) {
2221         /*--------------------------------------------------------------------*/
2222         /* CHTML 1.0 version 2.0                                              */
2223         /*--------------------------------------------------------------------*/
2224         size = apr_pstrdup(doc->buf.pool, val);
2225       }
2226       break;
2227
2228     case 'n':
2229     case 'N':
2230       if (strcasecmp(nm, "name") == 0) {
2231         /*--------------------------------------------------------------------*/
2232         /* CHTML 1.0 version 2.0                                              */
2233         /*--------------------------------------------------------------------*/
2234         name = apr_pstrdup(doc->buf.pool, val);
2235       }
2236       break;
2237
2238     case 'm':
2239     case 'M':
2240       if (strcasecmp(nm, "multiple") == 0) {
2241         /*--------------------------------------------------------------------*/
2242         /* CHTML 1.0 version 2.0                                              */
2243         /*--------------------------------------------------------------------*/
2244         multiple = apr_pstrdup(doc->buf.pool, val);
2245       }
2246       break;
2247
2248     default:
2249       break;
2250     }
2251   }
2252   if (size && *size) {
2253     W_L(" size=\"");
2254     W_V(size);
2255     W_L("\"");
2256   }
2257   if (name && *name) {
2258     W_L(" name=\"");
2259     W_V(name);
2260     W_L("\"");
2261   }
2262   if (multiple) {
2263     W_L(" multiple");
2264   }
2265   W_L(">");
2266   return chtml20->out;
2267 }
2268
2269
2270 /**
2271  * It is a handler who processes the SELECT tag.
2272  *
2273  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2274  *                     destination is specified.
2275  * @param node   [i]   The SELECT tag node is specified.
2276  * @return The conversion result is returned.
2277  */
2278 static char *
2279 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2280 {
2281   chtml20_t *chtml20;
2282   Doc *doc;
2283   request_rec *r;
2284
2285   chtml20 = GET_CHTML20(pdoc);
2286   doc     = chtml20->doc;
2287   r       = doc->r;
2288
2289   W_L("</select>");
2290   return chtml20->out;
2291 }
2292
2293
2294 /**
2295  * It is a handler who processes the OPTION tag.
2296  *
2297  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2298  *                     destination is specified.
2299  * @param node   [i]   The OPTION tag node is specified.
2300  * @return The conversion result is returned.
2301  */
2302 static char *
2303 s_chtml20_start_option_tag(void *pdoc, Node *child)
2304 {
2305   chtml20_t *chtml20;
2306   Doc *doc;
2307   request_rec *r;
2308   Attr *attr;
2309
2310   chtml20 = GET_CHTML20(pdoc);
2311   doc     = chtml20->doc;
2312   r       = doc->r;
2313
2314   char *selected   = NULL;
2315   char *value      = NULL;
2316
2317   W_L("<option");
2318   for (attr = qs_get_attr(doc,child);
2319        attr;
2320        attr = qs_get_next_attr(doc,attr)) {
2321
2322     char *nm;
2323     char *val;
2324
2325     nm  = qs_get_attr_name(doc,attr);
2326     val = qs_get_attr_value(doc,attr);
2327
2328     switch(*nm) {
2329     case 's':
2330     case 'S':
2331       if (strcasecmp(nm, "selected") == 0) {
2332         /*--------------------------------------------------------------------*/
2333         /* CHTML 1.0 version 2.0                                              */
2334         /*--------------------------------------------------------------------*/
2335         selected = apr_pstrdup(doc->buf.pool, val);
2336       }
2337       break;
2338
2339     case 'v':
2340     case 'V':
2341       if (strcasecmp(nm, "value") == 0) {
2342         /*--------------------------------------------------------------------*/
2343         /* CHTML 1.0 version 2.0                                              */
2344         /*--------------------------------------------------------------------*/
2345         value = apr_pstrdup(doc->buf.pool, val);
2346       }
2347       break;
2348
2349     default:
2350       break;
2351     }
2352   }
2353
2354   if (value && *value) {
2355     W_L(" value=\"");
2356     W_V(value);
2357     W_L("\"");
2358   }
2359
2360   if (selected) {
2361     W_L(" selected");
2362   }
2363   W_L(">");
2364   return chtml20->out;
2365 }
2366
2367
2368 /**
2369  * It is a handler who processes the OPTION tag.
2370  *
2371  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2372  *                     destination is specified.
2373  * @param node   [i]   The OPTION tag node is specified.
2374  * @return The conversion result is returned.
2375  */
2376 static char *
2377 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2378 {
2379   chtml20_t *chtml20;
2380   Doc *doc;
2381   request_rec *r;
2382
2383   chtml20 = GET_CHTML20(pdoc);
2384   doc     = chtml20->doc;
2385   r       = doc->r;
2386
2387   /* Don't close */
2388
2389   return chtml20->out;
2390 }
2391
2392
2393 /**
2394  * It is a handler who processes the DIV tag.
2395  *
2396  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2397  *                     destination is specified.
2398  * @param node   [i]   The DIV tag node is specified.
2399  * @return The conversion result is returned.
2400  */
2401 static char *
2402 s_chtml20_start_div_tag(void *pdoc, Node *child)
2403 {
2404   chtml20_t *chtml20;
2405   Doc *doc;
2406   request_rec *r;
2407   Attr *attr;
2408
2409   chtml20 = GET_CHTML20(pdoc);
2410   doc     = chtml20->doc;
2411   r       = doc->r;
2412
2413
2414   char* align   = NULL;
2415
2416   W_L("<div");
2417   for (attr = qs_get_attr(doc,child);
2418        attr;
2419        attr = qs_get_next_attr(doc,attr)) {
2420
2421     char *nm;
2422     char *val;
2423
2424     nm  = qs_get_attr_name(doc,attr);
2425     val = qs_get_attr_value(doc,attr);
2426
2427     if (STRCASEEQ('a','A', "align", nm)) {
2428       /*----------------------------------------------------------------------*/
2429       /* CHTML 1.0 (W3C version 3.2)                                          */
2430       /*----------------------------------------------------------------------*/
2431       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2432         align = apr_pstrdup(doc->buf.pool, val);
2433       }
2434     }
2435   }
2436
2437   if (align) {
2438     W_L(" align=\"");
2439     W_V(align);
2440     W_L("\"");
2441   }
2442
2443   W_L(">");
2444   return chtml20->out;
2445 }
2446
2447
2448 /**
2449  * It is a handler who processes the DIV tag.
2450  *
2451  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2452  *                     destination is specified.
2453  * @param node   [i]   The DIV tag node is specified.
2454  * @return The conversion result is returned.
2455  */
2456 static char *
2457 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2458 {
2459   chtml20_t *chtml20;
2460   Doc *doc;
2461   request_rec *r;
2462
2463   chtml20 = GET_CHTML20(pdoc);
2464   doc     = chtml20->doc;
2465   r       = doc->r;
2466
2467   W_L("</div>");
2468   return chtml20->out;
2469 }
2470
2471
2472 /**
2473  * It is a handler who processes the H1 tag.
2474  *
2475  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2476  *                     destination is specified.
2477  * @param node   [i]   The H1 tag node is specified.
2478  * @return The conversion result is returned.
2479  */
2480 static char *
2481 s_chtml20_start_h1_tag(void *pdoc, Node *node) 
2482 {
2483   chtml20_t *chtml20;
2484   Doc *doc;
2485   request_rec *r;
2486   Attr *attr;
2487
2488   chtml20 = GET_CHTML20(pdoc);
2489   doc     = chtml20->doc;
2490   r       = doc->r;
2491
2492   W_L("<h1");
2493   for (attr = qs_get_attr(doc,node);
2494        attr;
2495        attr = qs_get_next_attr(doc,attr)) {
2496     char* name;
2497     char* value;
2498     name  = qs_get_attr_name(doc,attr);
2499     value = qs_get_attr_value(doc,attr);
2500     if (STRCASEEQ('a','A',"align", name)) {
2501       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2502         W_L(" align=\"");
2503         W_V(value);
2504         W_L("\"");
2505         break;
2506       }
2507     }
2508   }
2509   W_L(">");
2510   return chtml20->out;
2511 }
2512
2513
2514 /**
2515  * It is a handler who processes the H1 tag.
2516  *
2517  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2518  *                     destination is specified.
2519  * @param node   [i]   The H1 tag node is specified.
2520  * @return The conversion result is returned.
2521  */
2522 static char *
2523 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2524 {
2525   chtml20_t *chtml20;
2526   Doc *doc;
2527   request_rec *r;
2528
2529   chtml20 = GET_CHTML20(pdoc);
2530   doc     = chtml20->doc;
2531   r       = doc->r;
2532
2533   W_L("</h1>");
2534   return chtml20->out;
2535 }
2536
2537
2538 /**
2539  * It is a handler who processes the H2 tag.
2540  *
2541  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2542  *                     destination is specified.
2543  * @param node   [i]   The H2 tag node is specified.
2544  * @return The conversion result is returned.
2545  */
2546 static char *
2547 s_chtml20_start_h2_tag(void *pdoc, Node *node) 
2548 {
2549   chtml20_t *chtml20;
2550   Doc *doc;
2551   request_rec *r;
2552   Attr *attr;
2553
2554   chtml20 = GET_CHTML20(pdoc);
2555   doc     = chtml20->doc;
2556   r       = doc->r;
2557
2558   W_L("<h2");
2559   for (attr = qs_get_attr(doc,node);
2560        attr;
2561        attr = qs_get_next_attr(doc,attr)) {
2562     char* name;
2563     char* value;
2564     name  = qs_get_attr_name(doc,attr);
2565     value = qs_get_attr_value(doc,attr);
2566     if (STRCASEEQ('a','A',"align", name)) {
2567       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2568         W_L(" align=\"");
2569         W_V(value);
2570         W_L("\"");
2571         break;
2572       }
2573     }
2574   }
2575   W_L(">");
2576   return chtml20->out;
2577 }
2578
2579
2580 /**
2581  * It is a handler who processes the H2 tag.
2582  *
2583  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2584  *                     destination is specified.
2585  * @param node   [i]   The H2 tag node is specified.
2586  * @return The conversion result is returned.
2587  */
2588 static char *
2589 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2590
2591   chtml20_t *chtml20;
2592   Doc *doc;
2593   request_rec *r;
2594
2595   chtml20 = GET_CHTML20(pdoc);
2596   doc     = chtml20->doc;
2597   r       = doc->r;
2598
2599   W_L("</h2>");
2600   return chtml20->out;
2601 }
2602
2603
2604 /**
2605  * It is a handler who processes the H3 tag.
2606  *
2607  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2608  *                     destination is specified.
2609  * @param node   [i]   The H3 tag node is specified.
2610  * @return The conversion result is returned.
2611  */
2612 static char *
2613 s_chtml20_start_h3_tag(void *pdoc, Node *node) 
2614 {
2615   chtml20_t *chtml20;
2616   Doc *doc;
2617   request_rec *r;
2618   Attr *attr;
2619
2620   chtml20 = GET_CHTML20(pdoc);
2621   doc     = chtml20->doc;
2622   r       = doc->r;
2623
2624   W_L("<h3");
2625   for (attr = qs_get_attr(doc,node);
2626        attr;
2627        attr = qs_get_next_attr(doc,attr)) {
2628     char* name;
2629     char* value;
2630     name  = qs_get_attr_name(doc,attr);
2631     value = qs_get_attr_value(doc,attr);
2632     if (STRCASEEQ('a','A',"align", name)) {
2633       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2634         W_L(" align=\"");
2635         W_V(value);
2636         W_L("\"");
2637         break;
2638       }
2639     }
2640   }
2641   W_L(">");
2642   return chtml20->out;
2643 }
2644
2645
2646 /**
2647  * It is a handler who processes the H3 tag.
2648  *
2649  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2650  *                     destination is specified.
2651  * @param node   [i]   The H3 tag node is specified.
2652  * @return The conversion result is returned.
2653  */
2654 static char *
2655 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2656 {
2657   chtml20_t *chtml20;
2658   Doc *doc;
2659   request_rec *r;
2660
2661   chtml20 = GET_CHTML20(pdoc);
2662   doc     = chtml20->doc;
2663   r       = doc->r;
2664
2665   W_L("</h3>");
2666   return chtml20->out;
2667 }
2668
2669
2670 /**
2671  * It is a handler who processes the H4 tag.
2672  *
2673  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2674  *                     destination is specified.
2675  * @param node   [i]   The H4 tag node is specified.
2676  * @return The conversion result is returned.
2677  */
2678 static char *
2679 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2680 {
2681   chtml20_t *chtml20;
2682   Doc *doc;
2683   request_rec *r;
2684   Attr *attr;
2685
2686   chtml20 = GET_CHTML20(pdoc);
2687   doc     = chtml20->doc;
2688   r       = doc->r;
2689
2690   W_L("<h4");
2691   for (attr = qs_get_attr(doc,node);
2692        attr;
2693        attr = qs_get_next_attr(doc,attr)) {
2694     char* name;
2695     char* value;
2696     name  = qs_get_attr_name(doc,attr);
2697     value = qs_get_attr_value(doc,attr);
2698     if (STRCASEEQ('a','A',"align", name)) {
2699       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2700         W_L(" align=\"");
2701         W_V(value);
2702         W_L("\"");
2703         break;
2704       }
2705     }
2706   }
2707   W_L(">");
2708   return chtml20->out;
2709 }
2710
2711
2712 /**
2713  * It is a handler who processes the H4 tag.
2714  *
2715  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2716  *                     destination is specified.
2717  * @param node   [i]   The H4 tag node is specified.
2718  * @return The conversion result is returned.
2719  */
2720 static char *
2721 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2722 {
2723   chtml20_t *chtml20;
2724   Doc *doc;
2725   request_rec *r;
2726
2727   chtml20 = GET_CHTML20(pdoc);
2728   doc     = chtml20->doc;
2729   r       = doc->r;
2730
2731   W_L("</h4>");
2732   return chtml20->out;
2733 }
2734
2735
2736 /**
2737  * It is a handler who processes the H5 tag.
2738  *
2739  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2740  *                     destination is specified.
2741  * @param node   [i]   The H5 tag node is specified.
2742  * @return The conversion result is returned.
2743  */
2744 static char *
2745 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2746 {
2747   chtml20_t *chtml20;
2748   Doc *doc;
2749   request_rec *r;
2750   Attr *attr;
2751
2752   chtml20 = GET_CHTML20(pdoc);
2753   doc     = chtml20->doc;
2754   r       = doc->r;
2755
2756   W_L("<h5");
2757   for (attr = qs_get_attr(doc,node);
2758        attr;
2759        attr = qs_get_next_attr(doc,attr)) {
2760     char *name;
2761     char *value;
2762     name  = qs_get_attr_name(doc,attr);
2763     value = qs_get_attr_value(doc,attr);
2764     if (STRCASEEQ('a','A',"align", name)) {
2765       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2766         W_L(" align=\"");
2767         W_V(value);
2768         W_L("\"");
2769         break;
2770       }
2771     }
2772   }
2773   W_L(">");
2774   return chtml20->out;
2775 }
2776
2777
2778 /**
2779  * It is a handler who processes the H5 tag.
2780  *
2781  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2782  *                     destination is specified.
2783  * @param node   [i]   The H5 tag node is specified.
2784  * @return The conversion result is returned.
2785  */
2786 static char *
2787 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
2788 {
2789   chtml20_t *chtml20;
2790   Doc *doc;
2791   request_rec *r;
2792
2793   chtml20 = GET_CHTML20(pdoc);
2794   doc     = chtml20->doc;
2795   r       = doc->r;
2796
2797   W_L("</h5>");
2798   return chtml20->out;
2799 }
2800
2801
2802 /**
2803  * It is a handler who processes the H6 tag.
2804  *
2805  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2806  *                     destination is specified.
2807  * @param node   [i]   The H6 tag node is specified.
2808  * @return The conversion result is returned.
2809  */
2810 static char *
2811 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2812 {
2813   chtml20_t *chtml20;
2814   Doc *doc;
2815   request_rec *r;
2816   Attr *attr;
2817
2818   chtml20 = GET_CHTML20(pdoc);
2819   doc     = chtml20->doc;
2820   r       = doc->r;
2821
2822   W_L("<h6");
2823   for (attr = qs_get_attr(doc,node);
2824        attr;
2825        attr = qs_get_next_attr(doc,attr)) {
2826     char *name;
2827     char *value;
2828     name  = qs_get_attr_name(doc,attr);
2829     value = qs_get_attr_value(doc,attr);
2830     if (STRCASEEQ('a','A',"align", name)) {
2831       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2832         W_L(" align=\"");
2833         W_V(value);
2834         W_L("\"");
2835         break;
2836       }
2837     }
2838   }
2839   W_L(">");
2840   return chtml20->out;
2841 }
2842
2843
2844 /**
2845  * It is a handler who processes the H6 tag.
2846  *
2847  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2848  *                     destination is specified.
2849  * @param node   [i]   The H6 tag node is specified.
2850  * @return The conversion result is returned.
2851  */
2852 static char *
2853 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
2854 {
2855   chtml20_t *chtml20;
2856   Doc *doc;
2857   request_rec *r;
2858
2859   chtml20 = GET_CHTML20(pdoc);
2860   doc     = chtml20->doc;
2861   r       = doc->r;
2862
2863   W_L("</h6>");
2864   return chtml20->out;
2865 }
2866
2867
2868 /**
2869  * It is a handler who processes the PRE tag.
2870  *
2871  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2872  *                     destination is specified.
2873  * @param node   [i]   The PRE tag node is specified.
2874  * @return The conversion result is returned.
2875  */
2876 static char *
2877 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
2878 {
2879   chtml20_t *chtml20;
2880   Doc *doc;
2881   request_rec *r;
2882
2883   chtml20 = GET_CHTML20(pdoc);
2884   doc     = chtml20->doc;
2885   r       = doc->r;
2886
2887   chtml20->pre_flag++;
2888   W_L("<pre>");
2889   return chtml20->out;
2890 }
2891
2892
2893 /**
2894  * It is a handler who processes the PRE tag.
2895  *
2896  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2897  *                     destination is specified.
2898  * @param node   [i]   The PRE tag node is specified.
2899  * @return The conversion result is returned.
2900  */
2901 static char *
2902 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2903 {
2904   chtml20_t *chtml20;
2905   Doc *doc;
2906   request_rec *r;
2907
2908   chtml20 = GET_CHTML20(pdoc);
2909   doc     = chtml20->doc;
2910   r       = doc->r;
2911
2912   W_L("</pre>");
2913   chtml20->pre_flag--;
2914
2915   return chtml20->out;
2916 }
2917
2918
2919 /**
2920  * It is a handler who processes the P tag.
2921  *
2922  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2923  *                     destination is specified.
2924  * @param node   [i]   The P tag node is specified.
2925  * @return The conversion result is returned.
2926  */
2927 static char *
2928 s_chtml20_start_p_tag(void *pdoc, Node *node)
2929 {
2930   chtml20_t *chtml20;
2931   Doc *doc;
2932   request_rec *r;
2933   Attr *attr;
2934   char *align = NULL;
2935
2936   chtml20 = GET_CHTML20(pdoc);
2937   doc     = chtml20->doc;
2938   r       = doc->r;
2939
2940   W_L("<p");
2941   for (attr = qs_get_attr(doc,node);
2942        attr;
2943        attr = qs_get_next_attr(doc,attr)) {
2944     char *nm  = qs_get_attr_name(doc,attr);
2945     char *val = qs_get_attr_value(doc,attr);
2946     if (STRCASEEQ('a','A',"align", nm)) {
2947       /*----------------------------------------------------------------------*/
2948       /* CHTML 1.0 (W3C version 3.2)                                          */
2949       /*----------------------------------------------------------------------*/
2950       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2951         align = apr_pstrdup(doc->buf.pool, val);
2952         break;
2953       }
2954     }
2955   }
2956   if (align) {
2957     W_L(" align=\"");
2958     W_V(align);
2959     W_L("\"");
2960   }
2961   W_L(">");
2962   return chtml20->out;
2963 }
2964
2965
2966 /**
2967  * It is a handler who processes the P tag.
2968  *
2969  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2970  *                     destination is specified.
2971  * @param node   [i]   The P tag node is specified.
2972  * @return The conversion result is returned.
2973  */
2974 static char *
2975 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child)) 
2976 {
2977   chtml20_t *chtml20;
2978   Doc *doc;
2979   request_rec *r;
2980
2981   chtml20 = GET_CHTML20(pdoc);
2982   doc     = chtml20->doc;
2983   r       = doc->r;
2984
2985   W_L("</p>");
2986   return chtml20->out;
2987 }
2988
2989
2990 static char *
2991 s_chtml20_chxjif_tag(void *pdoc, Node *node)
2992 {
2993   chtml20_t *chtml20;
2994   Doc *doc;
2995   Node *child;
2996   request_rec *r;
2997
2998   chtml20 = GET_CHTML20(pdoc);
2999   doc     = chtml20->doc;
3000   r       = doc->r;
3001
3002   for (child = qs_get_child_node(doc, node);
3003        child;
3004        child = qs_get_next_node(doc, child)) {
3005
3006     W_V(child->otext);
3007     s_chtml20_chxjif_tag(pdoc, child);
3008   }
3009
3010   return NULL;
3011 }
3012
3013
3014 /**
3015  * It is a handler who processes the TEXTARE tag.
3016  *
3017  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3018  *                     destination is specified.
3019  * @param node   [i]   The TEXTAREA tag node is specified.
3020  * @return The conversion result is returned.
3021  */
3022 static char *
3023 s_chtml20_start_textarea_tag(void *pdoc, Node *node) 
3024 {
3025   chtml20_t *chtml20;
3026   Doc *doc;
3027   request_rec *r;
3028   Attr *attr;
3029
3030   chtml20 = GET_CHTML20(pdoc);
3031   doc     = chtml20->doc;
3032   r       = doc->r;
3033
3034   chtml20->textarea_flag++;
3035   W_L("<textarea");
3036   for (attr = qs_get_attr(doc,node);
3037        attr;
3038        attr = qs_get_next_attr(doc,attr)) {
3039     char *name = qs_get_attr_name(doc,attr);
3040     char *value = qs_get_attr_value(doc,attr);
3041     switch(*name) {
3042     case 'a':
3043     case 'A':
3044       if (strcasecmp(name, "accesskey") == 0 && value && *value != 0) {
3045         W_L(" accesskey=\"");
3046         W_V(value);
3047         W_L("\"");
3048       }
3049       break;
3050
3051     case 'n':
3052     case 'N':
3053       if (strcasecmp(name, "name") == 0 && value && *value != 0) {
3054         W_L(" name=\"");
3055         W_V(value);
3056         W_L("\"");
3057       }
3058       break;
3059
3060     case 'r':
3061     case 'R':
3062       if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
3063         W_L(" rows=\"");
3064         W_V(value);
3065         W_L("\"");
3066       }
3067       break;
3068
3069     case 'c':
3070     case 'C':
3071       if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
3072         W_L(" cols=\"");
3073         W_V(value);
3074         W_L("\"");
3075       }
3076       break;
3077
3078     case 'i':
3079     case 'I':
3080       if (strcasecmp(name, "istyle") == 0 && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3081         W_L(" istyle=\"");
3082         W_V(value);
3083         W_L("\"");
3084       }
3085       break;
3086
3087     default:
3088       break;
3089     }
3090   }
3091   W_L(">");
3092   return chtml20->out;
3093 }
3094
3095
3096 /**
3097  * It is a handler who processes the TEXTAREA tag.
3098  *
3099  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3100  *                     destination is specified.
3101  * @param node   [i]   The TEXTAREA tag node is specified.
3102  * @return The conversion result is returned.
3103  */
3104 static char *
3105 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
3106 {
3107   chtml20_t *chtml20;
3108   Doc *doc;
3109   request_rec *r;
3110
3111   chtml20 = GET_CHTML20(pdoc);
3112   doc     = chtml20->doc;
3113   r       = doc->r;
3114
3115   W_L("</textarea>");
3116   chtml20->textarea_flag--;
3117
3118   return chtml20->out;
3119 }
3120
3121
3122 static char *
3123 s_chtml20_text_tag(void *pdoc, Node *child)
3124 {       
3125   chtml20_t *chtml20;
3126   Doc *doc;
3127   request_rec *r;
3128   char *textval;
3129   char *tmp;
3130   char *tdst;
3131   char one_byte[2];
3132   int           ii;
3133   int           tdst_len;
3134
3135   chtml20 = GET_CHTML20(pdoc);
3136   doc     = chtml20->doc;
3137   r       = doc->r;
3138   
3139   textval = qs_get_node_value(doc,child);
3140   if (strlen(textval) == 0) {
3141     return chtml20->out;
3142   }
3143   
3144   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3145   memset(tmp, 0, qs_get_node_size(doc,child)+1);
3146   
3147   tdst     = qs_alloc_zero_byte_string(r);
3148   memset(one_byte, 0, sizeof(one_byte));
3149   tdst_len = 0;
3150   
3151   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3152     char* out;
3153     int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3154     if (rtn != 0) {
3155       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3156       ii+=(rtn - 1);
3157       continue;
3158     }
3159     if (is_sjis_kanji(textval[ii])) {
3160       one_byte[0] = textval[ii+0];
3161       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3162       one_byte[0] = textval[ii+1];
3163       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3164       ii++;
3165     }
3166     else 
3167     if (chtml20->pre_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 (chtml20->textarea_flag) {
3173       one_byte[0] = textval[ii+0];
3174       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3175     }
3176     else 
3177     if (textval[ii] != '\r' && textval[ii] != '\n') {
3178       one_byte[0] = textval[ii+0];
3179       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3180     }
3181   }
3182   W_V(tdst);
3183   return chtml20->out;
3184 }
3185
3186
3187 /**
3188  * It is a handler who processes the BLOCKQUOTE tag.
3189  *
3190  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3191  *                     destination is specified.
3192  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3193  * @return The conversion result is returned.
3194  */
3195 static char *
3196 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3197 {
3198   chtml20_t *chtml20;
3199   Doc *doc;
3200   chtml20 = GET_CHTML20(pdoc);
3201   doc     = chtml20->doc;
3202   W_L("<blockquote>");
3203   return chtml20->out;
3204 }
3205
3206
3207 /**
3208  * It is a handler who processes the BLOCKQUOTE tag.
3209  *
3210  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3211  *                     destination is specified.
3212  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3213  * @return The conversion result is returned.
3214  */
3215 static char *
3216 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3217 {
3218   chtml20_t *chtml20;
3219   Doc *doc;
3220
3221   chtml20 = GET_CHTML20(pdoc);
3222   doc     = chtml20->doc;
3223   W_L("</blockquote>");
3224   return chtml20->out;
3225 }
3226
3227
3228 /**
3229  * It is a handler who processes the DIR tag.
3230  *
3231  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3232  *                     destination is specified.
3233  * @param node   [i]   The DIR tag node is specified.
3234  * @return The conversion result is returned.
3235  */
3236 static char *
3237 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3238 {
3239   chtml20_t *chtml20;
3240   Doc *doc;
3241   chtml20 = GET_CHTML20(pdoc);
3242   doc     = chtml20->doc;
3243   W_L("<dir>");
3244   return chtml20->out;
3245 }
3246
3247
3248 /**
3249  * It is a handler who processes the DIR tag.
3250  *
3251  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3252  *                     destination is specified.
3253  * @param node   [i]   The DIR tag node is specified.
3254  * @return The conversion result is returned.
3255  */
3256 static char *
3257 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3258 {
3259   chtml20_t *chtml20;
3260   Doc *doc;
3261
3262   chtml20 = GET_CHTML20(pdoc);
3263   doc     = chtml20->doc;
3264   W_L("</dir>");
3265   return chtml20->out;
3266 }
3267
3268
3269 /**
3270  * It is a handler who processes the DL tag.
3271  *
3272  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3273  *                     destination is specified.
3274  * @param node   [i]   The DL tag node is specified.
3275  * @return The conversion result is returned.
3276  */
3277 static char *
3278 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3279 {
3280   chtml20_t *chtml20;
3281   Doc *doc;
3282   chtml20 = GET_CHTML20(pdoc);
3283   doc     = chtml20->doc;
3284   W_L("<dl>");
3285   return chtml20->out;
3286 }
3287
3288
3289 /**
3290  * It is a handler who processes the DL tag.
3291  *
3292  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3293  *                     destination is specified.
3294  * @param node   [i]   The DL tag node is specified.
3295  * @return The conversion result is returned.
3296  */
3297 static char *
3298 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3299 {
3300   chtml20_t *chtml20;
3301   Doc *doc;
3302   chtml20 = GET_CHTML20(pdoc);
3303   doc     = chtml20->doc;
3304   W_L("</dl>");
3305   return chtml20->out;
3306 }
3307
3308
3309 /**
3310  * It is a handter who processes the DT tag.
3311  *
3312  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3313  *                     destination is specified.
3314  * @param node   [i]   The DT tag node is specified.
3315  * @return The conversion result is returned.
3316  */
3317 static char *
3318 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3319 {
3320   chtml20_t *chtml20;
3321   Doc *doc;
3322   chtml20 = GET_CHTML20(pdoc);
3323   doc     = chtml20->doc;
3324   W_L("<dt>");
3325   return chtml20->out;
3326 }
3327
3328
3329 /**
3330  * It is a handter who processes the DT tag.
3331  *
3332  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3333  *                     destination is specified.
3334  * @param node   [i]   The DT tag node is specified.
3335  * @return The conversion result is returned.
3336  */
3337 static char *
3338 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3339 {
3340   chtml20_t *chtml20;
3341   chtml20 = GET_CHTML20(pdoc);
3342   return chtml20->out;
3343 }
3344
3345
3346 /**
3347  * It is a handder who processes the DD tag.
3348  *
3349  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3350  *                     destination is specified.
3351  * @param node   [i]   The DD tag node is specified.
3352  * @return The conversion result is returned.
3353  */
3354 static char *
3355 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3356 {
3357   chtml20_t *chtml20;
3358   Doc *doc;
3359   chtml20 = GET_CHTML20(pdoc);
3360   doc     = chtml20->doc;
3361   W_L("<dd>");
3362   return chtml20->out;
3363 }
3364
3365
3366 /**
3367  * It is a handder who processes the DD tag.
3368  *
3369  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3370  *                     destination is specified.
3371  * @param node   [i]   The DD tag node is specified.
3372  * @return The conversion result is returned.
3373  */
3374 static char *
3375 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
3376 {
3377   chtml20_t *chtml20;
3378   chtml20 = GET_CHTML20(pdoc);
3379   return chtml20->out;
3380 }
3381
3382
3383 /**
3384  * It is a hanmenuer who processes the MENU tag.
3385  *
3386  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3387  *                     destination is specified.
3388  * @param node   [i]   The MENU tag node is specified.
3389  * @return The conversion result is returned.
3390  */
3391 static char *
3392 s_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
3393 {
3394   chtml20_t *chtml20;
3395   Doc *doc;
3396   chtml20 = GET_CHTML20(pdoc);
3397   doc     = chtml20->doc;
3398   W_L("<menu>");
3399   return chtml20->out;
3400 }
3401
3402
3403 /**
3404  * It is a hanmenuer who processes the MENU tag.
3405  *
3406  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3407  *                     destination is specified.
3408  * @param node   [i]   The MENU tag node is specified.
3409  * @return The conversion result is returned.
3410  */
3411 static char *
3412 s_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
3413 {
3414   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3415   Doc *doc = chtml20->doc;
3416   W_L("</menu>");
3417   return chtml20->out;
3418 }
3419
3420
3421 /**
3422  * It is a hanplaintexter who processes the PLAINTEXT tag.
3423  *
3424  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3425  *                     destination is specified.
3426  * @param node   [i]   The PLAINTEXT tag node is specified.
3427  * @return The conversion result is returned.
3428  */
3429 static char *
3430 s_chtml20_start_plaintext_tag(void *pdoc, Node *node)
3431 {
3432   chtml20_t *chtml20;
3433   Doc *doc;
3434
3435   chtml20 = GET_CHTML20(pdoc);
3436   doc     = chtml20->doc;
3437   W_L("<plaintext>");
3438   s_chtml20_start_plaintext_tag_inner(pdoc,node);
3439   return chtml20->out;
3440 }
3441
3442 static char *
3443 s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
3444 {
3445   chtml20_t *chtml20;
3446   Doc *doc;
3447   Node *child;
3448   chtml20 = GET_CHTML20(pdoc);
3449   doc     = chtml20->doc;
3450   for (child = qs_get_child_node(doc, node);
3451        child;
3452        child = qs_get_next_node(doc, child)) {
3453     W_V(child->otext);
3454     s_chtml20_start_plaintext_tag_inner(pdoc, child);
3455   }
3456   return chtml20->out;
3457 }
3458
3459
3460 /**
3461  * It is a hanplaintexter who processes the PLAINTEXT tag.
3462  *
3463  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3464  *                     destination is specified.
3465  * @param node   [i]   The PLAINTEXT tag node is specified.
3466  * @return The conversion result is returned.
3467  */
3468 static char *
3469 s_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3470 {
3471   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3472   return chtml20->out;
3473 }
3474
3475 /**
3476  * It is a hanblinker who processes the BLINK tag.
3477  *
3478  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3479  *                     destination is specified.
3480  * @param node   [i]   The BLINK tag node is specified.
3481  * @return The conversion result is returned.
3482  */
3483 static char *
3484 s_chtml20_start_blink_tag(void *pdoc, Node *UNUSED(child))
3485 {
3486   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3487   Doc *doc = chtml20->doc;
3488   W_L("<blink>");
3489   return chtml20->out;
3490 }
3491
3492
3493 /**
3494  * It is a hanblinker who processes the BLINK tag.
3495  *
3496  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3497  *                     destination is specified.
3498  * @param node   [i]   The BLINK tag node is specified.
3499  * @return The conversion result is returned.
3500  */
3501 static char *
3502 s_chtml20_end_blink_tag(void *pdoc, Node *UNUSED(child))
3503 {
3504   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3505   Doc *doc = chtml20->doc;
3506   W_L("</blink>");
3507   return chtml20->out;
3508 }
3509
3510
3511 /**
3512  * It is a hanmarqueeer who processes the MARQUEE tag.
3513  *
3514  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3515  *                     destination is specified.
3516  * @param node   [i]   The MARQUEE tag node is specified.
3517  * @return The conversion result is returned.
3518  */
3519 static char *
3520 s_chtml20_start_marquee_tag(void *pdoc, Node *node)
3521 {
3522   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3523   Doc *doc = chtml20->doc;
3524   Attr *attr;
3525   W_L("<marquee");
3526   /*--------------------------------------------------------------------------*/
3527   /* Get Attributes                                                           */
3528   /*--------------------------------------------------------------------------*/
3529   for (attr = qs_get_attr(doc,node);
3530        attr;
3531        attr = qs_get_next_attr(doc,attr)) {
3532     char *name   = qs_get_attr_name(doc,attr);
3533     char *value  = qs_get_attr_value(doc,attr);
3534     if (STRCASEEQ('d','D',"direction", name)) {
3535       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3536         W_L(" direction=\"");
3537         W_V(value);
3538         W_L("\"");
3539       }
3540     }
3541     else if (STRCASEEQ('b','B',"behavior",name)) {
3542       if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3543         W_L(" behavior=\""); 
3544         W_V(value);
3545         W_L("\"");
3546       }
3547     }
3548     else if (STRCASEEQ('l','L',"loop",name)) {
3549       if (value && *value) {
3550         W_L(" loop=\"");
3551         W_V(value);
3552         W_L("\"");
3553       }
3554     }
3555   }
3556   W_L(">");
3557   return chtml20->out;
3558 }
3559
3560
3561 /**
3562  * It is a hanmarqueeer who processes the MARQUEE tag.
3563  *
3564  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3565  *                     destination is specified.
3566  * @param node   [i]   The MARQUEE tag node is specified.
3567  * @return The conversion result is returned.
3568  */
3569 static char *
3570 s_chtml20_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3571 {
3572   chtml20_t *chtml20 = GET_CHTML20(pdoc);
3573   Doc *doc = chtml20->doc;
3574   W_L("</marquee>");
3575   return chtml20->out;
3576 }
3577 /*
3578  * vim:ts=2 et
3579  */