OSDN Git Service

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