OSDN Git Service

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