OSDN Git Service

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