OSDN Git Service

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