OSDN Git Service

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