OSDN Git Service

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