OSDN Git Service

b5d27f310c47ee322ac8df90699765b09f4a3868
[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
1293     char* name;
1294     char* value;
1295
1296     name  = qs_get_attr_name(doc,attr);
1297     value = qs_get_attr_value(doc,attr);
1298
1299     if (STRCASEEQ('c','C',"color", name)) {
1300       W_L(" color=\"");
1301       W_V(value);
1302       W_L("\"");
1303     }
1304     else if (STRCASEEQ('s','S',"size", name)) {
1305       /*----------------------------------------------------------------------*/
1306       /* CHTML 5.0                                                            */
1307       /*----------------------------------------------------------------------*/
1308       /* ignore */
1309     }
1310   }
1311
1312   W_L(">");
1313
1314   return chtml30->out;
1315 }
1316
1317
1318 /**
1319  * It is a handler who processes the FONT tag.
1320  *
1321  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1322  *                     destination is specified.
1323  * @param node   [i]   The FONT tag node is specified.
1324  * @return The conversion result is returned.
1325  */
1326 static char*
1327 s_chtml30_end_font_tag(void* pdoc, Node* UNUSED(child)) 
1328 {
1329   chtml30_t*    chtml30;
1330   Doc*          doc;
1331   request_rec*  r;
1332
1333   chtml30 = GET_CHTML30(pdoc);
1334   doc     = chtml30->doc;
1335   r       = doc->r;
1336
1337   W_L("</font>");
1338
1339   return chtml30->out;
1340 }
1341
1342
1343 /**
1344  * It is a handler who processes the FORM tag.
1345  *
1346  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1347  *                     destination is specified.
1348  * @param node   [i]   The FORM tag node is specified.
1349  * @return The conversion result is returned.
1350  */
1351 static char *
1352 s_chtml30_start_form_tag(void *pdoc, Node *node) 
1353 {
1354   chtml30_t     *chtml30;
1355   Doc           *doc;
1356   request_rec   *r;
1357   Attr          *attr;
1358
1359   chtml30 = GET_CHTML30(pdoc);
1360   doc     = chtml30->doc;
1361   r       = doc->r;
1362
1363   W_L("<form");
1364   /*--------------------------------------------------------------------------*/
1365   /* Get Attributes                                                           */
1366   /*--------------------------------------------------------------------------*/
1367   for (attr = qs_get_attr(doc,node);
1368        attr;
1369        attr = qs_get_next_attr(doc,attr)) {
1370     char *name  = qs_get_attr_name(doc,attr);
1371     char *value = qs_get_attr_value(doc,attr);
1372     if (STRCASEEQ('a','A',"action", name)) {
1373       /*----------------------------------------------------------------------*/
1374       /* CHTML 1.0                                                            */
1375       /*----------------------------------------------------------------------*/
1376       value = chxj_encoding_parameter(r, value);
1377       value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
1378       W_L(" action=\"");
1379       W_V(value);
1380       W_L("\"");
1381     }
1382     else if (STRCASEEQ('m','M',"method", name)) {
1383       /*----------------------------------------------------------------------*/
1384       /* CHTML 1.0                                                            */
1385       /*----------------------------------------------------------------------*/
1386       W_L(" method=\"");
1387       W_V(value);
1388       W_L("\"");
1389     }
1390     else if (STRCASEEQ('u','U',"utn", name)) {
1391       /*----------------------------------------------------------------------*/
1392       /* CHTML 3.0                                                            */
1393       /* It is special only for CHTML.                                        */
1394       /*----------------------------------------------------------------------*/
1395       W_L(" utn");
1396     }
1397   }
1398   W_L(">");
1399   return chtml30->out;
1400 }
1401
1402
1403 /**
1404  * It is a handler who processes the FORM tag.
1405  *
1406  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1407  *                     destination is specified.
1408  * @param node   [i]   The FORM tag node is specified.
1409  * @return The conversion result is returned.
1410  */
1411 static char*
1412 s_chtml30_end_form_tag(void* pdoc, Node* UNUSED(child)) 
1413 {
1414   chtml30_t*    chtml30;
1415   Doc*          doc;
1416   request_rec*  r;
1417
1418   chtml30 = GET_CHTML30(pdoc);
1419   doc     = chtml30->doc;
1420   r       = doc->r;
1421
1422   W_L("</form>");
1423
1424   return chtml30->out;
1425 }
1426
1427
1428 /**
1429  * It is a handler who processes the INPUT tag.
1430  *
1431  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1432  *                     destination is specified.
1433  * @param node   [i]   The INPUT tag node is specified.
1434  * @return The conversion result is returned.
1435  */
1436 static char *
1437 s_chtml30_start_input_tag(void *pdoc, Node *node) 
1438 {
1439   chtml30_t *chtml30;
1440   Doc *doc;
1441   request_rec *r;
1442   char *max_length  = NULL;
1443   char *type        = NULL;
1444   char *name        = NULL;
1445   char *value       = NULL;
1446   char *istyle      = NULL;
1447   char *size        = NULL;
1448   char *checked     = NULL;
1449   char *accesskey   = NULL;
1450
1451   chtml30   = GET_CHTML30(pdoc);
1452   doc       = chtml30->doc;
1453   r         = doc->r;
1454   W_L("<input");
1455   /*--------------------------------------------------------------------------*/
1456   /* Get Attributes                                                           */
1457   /*--------------------------------------------------------------------------*/
1458   type       = qs_get_type_attr(doc, node, r);
1459   name       = qs_get_name_attr(doc, node, r);
1460   value      = qs_get_value_attr(doc,node,r);
1461   istyle     = qs_get_istyle_attr(doc,node,r);
1462   max_length = qs_get_maxlength_attr(doc,node,r);
1463   checked    = qs_get_checked_attr(doc,node,r);
1464   accesskey  = qs_get_accesskey_attr(doc, node, r);
1465   size       = qs_get_size_attr(doc, node, r);
1466
1467   if (type) {
1468     type = qs_trim_string(doc->buf.pool, type);
1469     if (type && (STRCASEEQ('t','T',"text",    type) ||
1470                  STRCASEEQ('p','P',"password",type) ||
1471                  STRCASEEQ('c','C',"checkbox",type) ||
1472                  STRCASEEQ('r','R',"radio",   type) ||
1473                  STRCASEEQ('h','H',"hidden",  type) ||
1474                  STRCASEEQ('s','S',"submit",  type) ||
1475                  STRCASEEQ('r','R',"reset",   type))) {
1476       W_L(" type=\"");
1477       W_V(type);
1478       W_L("\"");
1479     }
1480   }
1481   if (size && *size) {
1482     W_L(" size=\"");
1483     W_V(size);
1484     W_L("\"");
1485   }
1486   if (name && *name) {
1487     W_L(" name=\"");
1488     W_V(name);
1489     W_L("\"");
1490   }
1491   if (value && *value) {
1492     W_L(" value=\"");
1493     W_V(value);
1494     W_L("\"");
1495   }
1496   if (accesskey && *accesskey) {
1497     W_L(" accesskey=\"");
1498     W_V(accesskey);
1499     W_L("\"");
1500   }
1501   if (istyle) {
1502     /*------------------------------------------------------------------------*/
1503     /* CHTML 2.0                                                              */
1504     /*------------------------------------------------------------------------*/
1505     if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1506       W_L(" istyle=\"");
1507       W_V(istyle);
1508       W_L("\"");
1509     }
1510   }
1511
1512   /*--------------------------------------------------------------------------*/
1513   /* The figure is default for the password.                                  */
1514   /*--------------------------------------------------------------------------*/
1515   if (max_length && *max_length) {
1516     if (chxj_chk_numeric(max_length) != 0) {
1517       max_length = apr_psprintf(r->pool, "0");
1518     }
1519     if (istyle != NULL && *istyle == '1') {
1520       char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1521       W_V(vv);
1522     }
1523     else  {
1524       char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1525       W_V(vv);
1526     }
1527   }
1528   if (checked) {
1529     W_L(" checked");
1530   }
1531   W_L(">");
1532   return chtml30->out;
1533 }
1534
1535
1536 /**
1537  * It is a handler who processes the INPUT tag.
1538  *
1539  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1540  *                     destination is specified.
1541  * @param node   [i]   The INPUT tag node is specified.
1542  * @return The conversion result is returned.
1543  */
1544 static char*
1545 s_chtml30_end_input_tag(void* pdoc, Node* UNUSED(child)) 
1546 {
1547   chtml30_t*    chtml30;
1548
1549   chtml30 = GET_CHTML30(pdoc);
1550
1551   return chtml30->out;
1552 }
1553
1554
1555 /**
1556  * It is a handler who processes the CENTER tag.
1557  *
1558  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1559  *                     destination is specified.
1560  * @param node   [i]   The CENTER tag node is specified.
1561  * @return The conversion result is returned.
1562  */
1563 static char*
1564 s_chtml30_start_center_tag(void* pdoc, Node* UNUSED(node)) 
1565 {
1566   chtml30_t*    chtml30;
1567   Doc*          doc;
1568   request_rec*  r;
1569
1570   chtml30 = GET_CHTML30(pdoc);
1571   doc     = chtml30->doc;
1572   r       = doc->r;
1573
1574   W_L("<center>");
1575
1576   return chtml30->out;
1577 }
1578
1579
1580 /**
1581  * It is a handler who processes the CENTER tag.
1582  *
1583  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1584  *                     destination is specified.
1585  * @param node   [i]   The CENTER tag node is specified.
1586  * @return The conversion result is returned.
1587  */
1588 static char*
1589 s_chtml30_end_center_tag(void* pdoc, Node* UNUSED(child)) 
1590 {
1591   chtml30_t*    chtml30;
1592   Doc*          doc;
1593   request_rec*  r;
1594
1595   chtml30 = GET_CHTML30(pdoc);
1596   doc     = chtml30->doc;
1597   r       = doc->r;
1598
1599   W_L("</center>");
1600
1601   return chtml30->out;
1602 }
1603
1604
1605 /**
1606  * It is a handler who processes the HR tag.
1607  *
1608  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1609  *                     destination is specified.
1610  * @param node   [i]   The HR tag node is specified.
1611  * @return The conversion result is returned.
1612  */
1613 static char*
1614 s_chtml30_start_hr_tag(void* pdoc, Node* node) 
1615 {
1616   Attr*         attr;
1617   chtml30_t*    chtml30;
1618   Doc*          doc;
1619   request_rec*  r;
1620
1621   chtml30 = GET_CHTML30(pdoc);
1622   doc     = chtml30->doc;
1623   r       = doc->r;
1624
1625   W_L("<hr");
1626  
1627   for (attr = qs_get_attr(doc,node);
1628        attr; 
1629        attr = qs_get_next_attr(doc,attr)) {
1630     char* name = qs_get_attr_name(doc,attr);
1631     char* value = qs_get_attr_value(doc,attr);
1632
1633     if (STRCASEEQ('a','A',"align", name)) {
1634       /*----------------------------------------------------------------------*/
1635       /* CHTML 1.0                                                            */
1636       /*----------------------------------------------------------------------*/
1637       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1638         W_L(" align=\"");
1639         W_V(value);
1640         W_L("\"");
1641       }
1642     }
1643     else if (STRCASEEQ('s','S',"size", name)) {
1644       /*----------------------------------------------------------------------*/
1645       /* CHTML 1.0                                                            */
1646       /*----------------------------------------------------------------------*/
1647       if (value && *value) {
1648         W_L(" size=\"");
1649         W_V(value);
1650         W_L("\"");
1651       }
1652     }
1653     else if (STRCASEEQ('w','W',"width", name)) {
1654       /*----------------------------------------------------------------------*/
1655       /* CHTML 1.0                                                            */
1656       /*----------------------------------------------------------------------*/
1657       if (value && *value) {
1658         W_L(" width=\"");
1659         W_V(value);
1660         W_L("\"");
1661       }
1662     }
1663     else if (STRCASEEQ('n','N',"noshade", name)) {
1664       /*----------------------------------------------------------------------*/
1665       /* CHTML 1.0                                                            */
1666       /*----------------------------------------------------------------------*/
1667       W_L(" noshade");
1668     }
1669     else if (STRCASEEQ('c','C',"color", name)) {
1670       /*----------------------------------------------------------------------*/
1671       /* CHTML 4.0                                                            */
1672       /*----------------------------------------------------------------------*/
1673       /* ignore */
1674     }
1675   }
1676
1677   W_L(">");
1678
1679   return chtml30->out;
1680 }
1681
1682
1683 /**
1684  * It is a handler who processes the HR tag.
1685  *
1686  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1687  *                     destination is specified.
1688  * @param node   [i]   The HR tag node is specified.
1689  * @return The conversion result is returned.
1690  */
1691 static char*
1692 s_chtml30_end_hr_tag(void* pdoc, Node* UNUSED(child)) 
1693 {
1694   chtml30_t*    chtml30;
1695
1696   chtml30 = GET_CHTML30(pdoc);
1697
1698   return chtml30->out;
1699 }
1700
1701
1702 /**
1703  * It is a handler who processes the IMG tag.
1704  *
1705  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1706  *                     destination is specified.
1707  * @param node   [i]   The IMG tag node is specified.
1708  * @return The conversion result is returned.
1709  */
1710 static char *
1711 s_chtml30_start_img_tag(void *pdoc, Node *node) 
1712 {
1713 #ifndef IMG_NOT_CONVERT_FILENAME
1714   device_table *spec;
1715 #endif
1716   chtml30_t    *chtml30;
1717   Doc          *doc;
1718   request_rec  *r;
1719   Attr         *attr;
1720
1721   chtml30 = GET_CHTML30(pdoc);
1722   doc     = chtml30->doc;
1723   r       = doc->r;
1724 #ifndef IMG_NOT_CONVERT_FILENAME
1725   spec    = chtml30->spec;
1726 #endif
1727
1728   W_L("<img");
1729   /*--------------------------------------------------------------------------*/
1730   /* Get Attributes                                                           */
1731   /*--------------------------------------------------------------------------*/
1732   for (attr = qs_get_attr(doc,node);
1733        attr;
1734        attr = qs_get_next_attr(doc,attr)) {
1735     char* name  = qs_get_attr_name(doc,attr);
1736     char* value = qs_get_attr_value(doc,attr);
1737
1738     if (STRCASEEQ('s','S',"src", name)) {
1739       /*----------------------------------------------------------------------*/
1740       /* CHTML 1.0                                                            */
1741       /*----------------------------------------------------------------------*/
1742 #ifdef IMG_NOT_CONVERT_FILENAME
1743       value = chxj_encoding_parameter(r, value);
1744       value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
1745       if (value) {
1746         value = apr_psprintf(r->pool,
1747                              "%s%c%s=true",
1748                              value,
1749                              (strchr(value, '?')) ? '&' : '?',
1750                              CHXJ_COOKIE_NOUPDATE_PARAM);
1751         W_L(" src=\"");
1752         W_V(value);
1753         W_L("\"");
1754       }
1755
1756 #else
1757       value = chxj_img_conv(r,spec,value);
1758       value = chxj_encoding_parameter(r, value);
1759       value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
1760       if (value) {
1761         value = apr_psprintf(r->pool,
1762                              "%s%c%s=true",
1763                              value,
1764                              (strchr(value, '?')) ? '&' : '?',
1765                              CHXJ_COOKIE_NOUPDATE_PARAM);
1766       }
1767       W_L(" src=\"");
1768       W_V(value);
1769       W_L("\"");
1770 #endif
1771     }
1772     else if (STRCASEEQ('a','A',"align", name)) {
1773       /*----------------------------------------------------------------------*/
1774       /* CHTML 1.0                                                            */
1775       /*----------------------------------------------------------------------*/
1776       if (value && (STRCASEEQ('t','T',"top",   value) ||
1777                     STRCASEEQ('m','M',"middle",value) ||
1778                     STRCASEEQ('b','B',"bottom",value) ||
1779                     STRCASEEQ('l','L',"left",  value) ||
1780                     STRCASEEQ('r','R',"right", value))) {
1781         W_L(" align=\"");
1782         W_V(value);
1783         W_L("\"");
1784       }
1785     }
1786     else if (STRCASEEQ('w','W',"width", name) && value && *value) {
1787       /*----------------------------------------------------------------------*/
1788       /* CHTML 1.0                                                            */
1789       /*----------------------------------------------------------------------*/
1790       W_L(" width=\"");
1791       W_V(value);
1792       W_L("\"");
1793     }
1794     else if (STRCASEEQ('h','H', "height", name) && value && *value) {
1795       /*----------------------------------------------------------------------*/
1796       /* CHTML 1.0                                                            */
1797       /*----------------------------------------------------------------------*/
1798       W_L(" height=\"");
1799       W_V(value);
1800       W_L("\"");
1801     }
1802     else if (STRCASEEQ('h','H',"hspace", name) && value && *value) {
1803       /*----------------------------------------------------------------------*/
1804       /* CHTML 1.0                                                            */
1805       /*----------------------------------------------------------------------*/
1806       W_L(" hspace=\"");
1807       W_V(value);
1808       W_L("\"");
1809     }
1810     else if (STRCASEEQ('v','V',"vspace", name) && value && *value) {
1811       /*----------------------------------------------------------------------*/
1812       /* CHTML 1.0                                                            */
1813       /*----------------------------------------------------------------------*/
1814       W_L(" vspace=\"");
1815       W_V(value);
1816       W_L("\"");
1817     }
1818     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
1819       /*----------------------------------------------------------------------*/
1820       /* CHTML 1.0                                                            */
1821       /*----------------------------------------------------------------------*/
1822       W_L(" alt=\"");
1823       W_V(value);
1824       W_L("\"");
1825     }
1826     else if (STRCASEEQ('a','A',"align", name) && value && *value) {
1827       /*----------------------------------------------------------------------*/
1828       /* CHTML 4.0                                                            */
1829       /*----------------------------------------------------------------------*/
1830       /* ignore */
1831     }
1832   }
1833
1834   W_L(">");
1835
1836   return chtml30->out;
1837 }
1838
1839
1840 /**
1841  * It is a handler who processes the IMG tag.
1842  *
1843  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1844  *                     destination is specified.
1845  * @param node   [i]   The IMG tag node is specified.
1846  * @return The conversion result is returned.
1847  */
1848 static char*
1849 s_chtml30_end_img_tag(void* pdoc, Node* UNUSED(child)) 
1850 {
1851   chtml30_t*    chtml30;
1852
1853   chtml30 = GET_CHTML30(pdoc);
1854
1855   return chtml30->out;
1856 }
1857
1858
1859 /**
1860  * It is a handler who processes the SELECT tag.
1861  *
1862  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1863  *                     destination is specified.
1864  * @param node   [i]   The SELECT tag node is specified.
1865  * @return The conversion result is returned.
1866  */
1867 static char*
1868 s_chtml30_start_select_tag(void* pdoc, Node* child)
1869 {
1870   chtml30_t   *chtml30 = GET_CHTML30(pdoc);
1871   Doc         *doc     = chtml30->doc;
1872   char        *size    = NULL;
1873   char        *name    = NULL;
1874   char        *multiple    = NULL;
1875   Attr        *attr;
1876
1877   W_L("<select");
1878
1879   for (attr = qs_get_attr(doc,child);
1880        attr;
1881        attr = qs_get_next_attr(doc,attr)) {
1882     char *nm  = qs_get_attr_name(doc,attr);
1883     char *val = qs_get_attr_value(doc,attr);
1884     if (STRCASEEQ('s','S',"size", nm)) {
1885       /*----------------------------------------------------------------------*/
1886       /* CHTML 1.0 version 2.0                                                */
1887       /*----------------------------------------------------------------------*/
1888       size = apr_pstrdup(doc->buf.pool, val);
1889     }
1890     else if (STRCASEEQ('n','N',"name", nm)) {
1891       /*----------------------------------------------------------------------*/
1892       /* CHTML 1.0 version 2.0                                                */
1893       /*----------------------------------------------------------------------*/
1894       name = apr_pstrdup(doc->buf.pool, val);
1895     }
1896     else if (STRCASEEQ('m','M',"multiple", nm)) {
1897       /*----------------------------------------------------------------------*/
1898       /* CHTML 1.0 version 2.0                                                */
1899       /*----------------------------------------------------------------------*/
1900       multiple = apr_pstrdup(doc->buf.pool, val);
1901     }
1902   }
1903   if (size && *size) {
1904     W_L(" size=\"");
1905     W_V(size);
1906     W_L("\"");
1907   }
1908   if (name && *name) {
1909     W_L(" name=\"");
1910     W_V(name);
1911     W_L("\"");
1912   }
1913   if (multiple) {
1914     W_L(" multiple");
1915   }
1916   W_L(">");
1917   return chtml30->out;
1918 }
1919
1920
1921 /**
1922  * It is a handler who processes the SELECT tag.
1923  *
1924  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1925  *                     destination is specified.
1926  * @param node   [i]   The SELECT tag node is specified.
1927  * @return The conversion result is returned.
1928  */
1929 static char*
1930 s_chtml30_end_select_tag(void* pdoc, Node* UNUSED(child))
1931 {
1932   chtml30_t*    chtml30;
1933   Doc*          doc;
1934   request_rec*  r;
1935
1936   chtml30 = GET_CHTML30(pdoc);
1937   doc   = chtml30->doc;
1938   r     = doc->r;
1939   W_L("</select>");
1940   return chtml30->out;
1941 }
1942
1943
1944 /**
1945  * It is a handler who processes the OPTION tag.
1946  *
1947  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1948  *                     destination is specified.
1949  * @param node   [i]   The OPTION tag node is specified.
1950  * @return The conversion result is returned.
1951  */
1952 static char *
1953 s_chtml30_start_option_tag(void *pdoc, Node *child)
1954 {
1955   Attr *attr;
1956   chtml30_t *chtml30;
1957   Doc *doc;
1958   request_rec *r;
1959   char *selected;
1960   char *value;
1961
1962   chtml30    = GET_CHTML30(pdoc);
1963   doc        = chtml30->doc;
1964   r          = doc->r;
1965   selected   = NULL;
1966   value      = NULL;
1967
1968   W_L("<option");
1969   for (attr = qs_get_attr(doc,child);
1970        attr;
1971        attr = qs_get_next_attr(doc,attr)) {
1972     char *nm  = qs_get_attr_name(doc,attr);
1973     char *val = qs_get_attr_value(doc,attr);
1974     if (STRCASEEQ('s','S',"selected", nm)) {
1975       /*----------------------------------------------------------------------*/
1976       /* CHTML 1.0 version 2.0                                                */
1977       /*----------------------------------------------------------------------*/
1978       selected = apr_pstrdup(doc->buf.pool, val);
1979     }
1980     else if (STRCASEEQ('v','V',"value", nm)) {
1981       /*----------------------------------------------------------------------*/
1982       /* CHTML 1.0 version 2.0                                                */
1983       /*----------------------------------------------------------------------*/
1984       value = apr_pstrdup(doc->buf.pool, val);
1985     }
1986   }
1987   if (value && *value) {
1988     W_L(" value=\"");
1989     W_V(value);
1990     W_L("\"");
1991   }
1992   if (selected) {
1993     W_L(" selected");
1994   }
1995   W_L(">");
1996
1997   return chtml30->out;
1998 }
1999
2000
2001 /**
2002  * It is a handler who processes the OPTION tag.
2003  *
2004  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2005  *                     destination is specified.
2006  * @param node   [i]   The OPTION tag node is specified.
2007  * @return The conversion result is returned.
2008  */
2009 static char*
2010 s_chtml30_end_option_tag(void* pdoc, Node* UNUSED(child))
2011 {
2012   chtml30_t*    chtml30;
2013
2014   chtml30 = GET_CHTML30(pdoc);
2015
2016   /* Don't close */
2017
2018   return chtml30->out;
2019 }
2020
2021
2022 /**
2023  * It is a handler who processes the DIV tag.
2024  *
2025  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2026  *                     destination is specified.
2027  * @param node   [i]   The DIV tag node is specified.
2028  * @return The conversion result is returned.
2029  */
2030 static char*
2031 s_chtml30_start_div_tag(void *pdoc, Node *child)
2032 {
2033   Attr          *attr;
2034   chtml30_t     *chtml30;
2035   Doc           *doc;
2036   request_rec   *r;
2037   char          *align;
2038
2039   chtml30 = GET_CHTML30(pdoc);
2040   doc     = chtml30->doc;
2041   r       = doc->r;
2042   align   = NULL;
2043
2044   W_L("<div");
2045
2046   for (attr = qs_get_attr(doc,child);
2047        attr;
2048        attr = qs_get_next_attr(doc,attr)) {
2049     char* nm  = qs_get_attr_name(doc,attr);
2050     char* val = qs_get_attr_value(doc,attr);
2051
2052     if (STRCASEEQ('a','A',"align", nm)) {
2053       /*----------------------------------------------------------------------*/
2054       /* CHTML 1.0 (W3C version 3.2)                                          */
2055       /*----------------------------------------------------------------------*/
2056       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2057         align = apr_pstrdup(doc->buf.pool, val);
2058       }
2059     }
2060   }
2061
2062   if (align) {
2063     W_L(" align=\"");
2064     W_V(align);
2065     W_L("\"");
2066   }
2067
2068   W_L(">");
2069
2070   return chtml30->out;
2071 }
2072
2073
2074 /**
2075  * It is a handler who processes the DIV tag.
2076  *
2077  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2078  *                     destination is specified.
2079  * @param node   [i]   The DIV tag node is specified.
2080  * @return The conversion result is returned.
2081  */
2082 static char*
2083 s_chtml30_end_div_tag(void* pdoc, Node* UNUSED(node))
2084 {
2085   chtml30_t*    chtml30;
2086   Doc*          doc;
2087   request_rec*  r;
2088
2089   chtml30 = GET_CHTML30(pdoc);
2090   doc     = chtml30->doc;
2091   r       = doc->r;
2092
2093   W_L("</div>");
2094
2095   return chtml30->out;
2096 }
2097
2098
2099 /**
2100  * It is a handler who processes the UL tag.
2101  *
2102  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2103  *                     destination is specified.
2104  * @param node   [i]   The UL tag node is specified.
2105  * @return The conversion result is returned.
2106  */
2107 static char*
2108 s_chtml30_start_ul_tag(void* pdoc, Node* UNUSED(node)) 
2109 {
2110   chtml30_t*    chtml30;
2111   Doc*          doc;
2112   request_rec*  r;
2113
2114   chtml30 = GET_CHTML30(pdoc);
2115   doc     = chtml30->doc;
2116   r       = doc->r;
2117
2118   W_L("<ul>");
2119
2120   return chtml30->out;
2121 }
2122
2123
2124 /**
2125  * It is a handler who processes the UL tag.
2126  *
2127  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2128  *                     destination is specified.
2129  * @param node   [i]   The UL tag node is specified.
2130  * @return The conversion result is returned.
2131  */
2132 static char *
2133 s_chtml30_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
2134 {
2135   chtml30_t     *chtml30;
2136   Doc           *doc;
2137   request_rec   *r;
2138
2139   chtml30 = GET_CHTML30(pdoc);
2140   doc     = chtml30->doc;
2141   r       = doc->r;
2142
2143   W_L("</ul>");
2144
2145   return chtml30->out;
2146 }
2147
2148
2149 /**
2150  * It is a handler who processes the PRE tag.
2151  *
2152  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2153  *                     destination is specified.
2154  * @param node   [i]   The PRE tag node is specified.
2155  * @return The conversion result is returned.
2156  */
2157 static char *
2158 s_chtml30_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
2159 {
2160   chtml30_t     *chtml30;
2161   Doc           *doc;
2162   request_rec   *r;
2163
2164   chtml30 = GET_CHTML30(pdoc);
2165   doc     = chtml30->doc;
2166   r       = doc->r;
2167
2168   chtml30->pre_flag++;
2169   W_L("<pre>");
2170
2171   return chtml30->out;
2172 }
2173
2174
2175 /**
2176  * It is a handler who processes the PRE tag.
2177  *
2178  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2179  *                     destination is specified.
2180  * @param node   [i]   The PRE tag node is specified.
2181  * @return The conversion result is returned.
2182  */
2183 static char *
2184 s_chtml30_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2185 {
2186   chtml30_t     *chtml30;
2187   Doc           *doc;
2188   request_rec   *r;
2189
2190   chtml30 = GET_CHTML30(pdoc);
2191   doc     = chtml30->doc;
2192   r       = doc->r;
2193
2194   W_L("</pre>");
2195   chtml30->pre_flag--;
2196
2197   return chtml30->out;
2198 }
2199
2200
2201 /**
2202  * It is a handler who processes the P tag.
2203  *
2204  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2205  *                     destination is specified.
2206  * @param node   [i]   The P tag node is specified.
2207  * @return The conversion result is returned.
2208  */
2209 static char *
2210 s_chtml30_start_p_tag(void *pdoc, Node *node) 
2211 {
2212   chtml30_t     *chtml30;
2213   Doc           *doc;
2214   request_rec   *r;
2215   Attr          *attr;
2216   char          *align = NULL;
2217
2218   chtml30 = GET_CHTML30(pdoc);
2219   doc     = chtml30->doc;
2220   r       = doc->r;
2221
2222   W_L("<p");
2223   for (attr = qs_get_attr(doc,node);
2224        attr;
2225        attr = qs_get_next_attr(doc,attr)) {
2226     char *nm  = qs_get_attr_name(doc,attr);
2227     char *val = qs_get_attr_value(doc,attr);
2228     if (STRCASEEQ('a','A',"align", nm)) {
2229       /*----------------------------------------------------------------------*/
2230       /* CHTML 1.0 (W3C version 3.2)                                          */
2231       /*----------------------------------------------------------------------*/
2232       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2233         align = apr_pstrdup(doc->buf.pool, val);
2234         break;
2235       }
2236     }
2237   }
2238   if (align) {
2239     W_L(" align=\"");
2240     W_V(align);
2241     W_L("\"");
2242   }
2243   W_L(">");
2244
2245   return chtml30->out;
2246 }
2247
2248
2249 /**
2250  * It is a handler who processes the P tag.
2251  *
2252  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2253  *                     destination is specified.
2254  * @param node   [i]   The P tag node is specified.
2255  * @return The conversion result is returned.
2256  */
2257 static char*
2258 s_chtml30_end_p_tag(void* pdoc, Node* UNUSED(child)) 
2259 {
2260   chtml30_t*    chtml30;
2261   Doc*          doc;
2262   request_rec*  r;
2263
2264   chtml30 = GET_CHTML30(pdoc);
2265   doc     = chtml30->doc;
2266   r       = doc->r;
2267
2268   W_L("</p>");
2269
2270   return chtml30->out;
2271 }
2272
2273
2274 /**
2275  * It is a handler who processes the OL tag.
2276  *
2277  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2278  *                     destination is specified.
2279  * @param node   [i]   The OL tag node is specified.
2280  * @return The conversion result is returned.
2281  */
2282 static char *
2283 s_chtml30_start_ol_tag(void *pdoc, Node *node)
2284 {
2285   chtml30_t     *chtml30;
2286   Doc           *doc;
2287   request_rec   *r;
2288   Attr          *attr;
2289
2290   chtml30 = GET_CHTML30(pdoc);
2291   doc     = chtml30->doc;
2292   r       = doc->r;
2293
2294   W_L("<ol");
2295   /*--------------------------------------------------------------------------*/
2296   /* Get Attributes                                                           */
2297   /*--------------------------------------------------------------------------*/
2298   for (attr = qs_get_attr(doc,node);
2299        attr;
2300        attr = qs_get_next_attr(doc,attr)) {
2301     char *name = qs_get_attr_name(doc,attr);
2302     char *value = qs_get_attr_value(doc,attr);
2303     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2304       W_L(" type=\"");
2305       W_V(value);
2306       W_L("\"");
2307     }
2308     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
2309       W_L(" start=\"");
2310       W_V(value);
2311       W_L("\"");
2312     }
2313   }
2314   W_L(">");
2315
2316   return chtml30->out;
2317 }
2318
2319
2320 /**
2321  * It is a handler who processes the OL tag.
2322  *
2323  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2324  *                     destination is specified.
2325  * @param node   [i]   The OL tag node is specified.
2326  * @return The conversion result is returned.
2327  */
2328 static char *
2329 s_chtml30_end_ol_tag(void *pdoc, Node *UNUSED(node)) 
2330 {
2331   chtml30_t     *chtml30;
2332   Doc           *doc;
2333   request_rec   *r;
2334
2335   chtml30 = GET_CHTML30(pdoc);
2336   doc     = chtml30->doc;
2337   r       = doc->r;
2338
2339   W_L("</ol>");
2340
2341   return chtml30->out;
2342 }
2343
2344
2345 /**
2346  * It is a handler who processes the LI tag.
2347  *
2348  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2349  *                     destination is specified.
2350  * @param node   [i]   The LI tag node is specified.
2351  * @return The conversion result is returned.
2352  */
2353 static char *
2354 s_chtml30_start_li_tag(void *pdoc, Node *node) 
2355 {
2356   chtml30_t *chtml30;
2357   Doc *doc;
2358   request_rec *r;
2359   Attr *attr;
2360
2361   chtml30 = GET_CHTML30(pdoc);
2362   doc     = chtml30->doc;
2363   r       = doc->r;
2364
2365   W_L("<li");
2366   /*--------------------------------------------------------------------------*/
2367   /* Get Attributes                                                           */
2368   /*--------------------------------------------------------------------------*/
2369   for (attr = qs_get_attr(doc,node);
2370        attr;
2371        attr = qs_get_next_attr(doc,attr)) {
2372     char *name = qs_get_attr_name(doc,attr);
2373     char *value = qs_get_attr_value(doc,attr);
2374     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2375       W_L(" type=\"");
2376       W_V(value);
2377       W_L("\"");
2378     }
2379     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2380       W_L(" value=\"");
2381       W_V(value);
2382       W_L("\"");
2383     }
2384   }
2385   W_L(">");
2386
2387   return chtml30->out;
2388 }
2389
2390
2391 /**
2392  * It is a handler who processes the LI tag.
2393  *
2394  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2395  *                     destination is specified.
2396  * @param node   [i]   The LI tag node is specified.
2397  * @return The conversion result is returned.
2398  */
2399 static char *
2400 s_chtml30_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2401 {
2402   chtml30_t *chtml30 = GET_CHTML30(pdoc);
2403   return chtml30->out;
2404 }
2405
2406
2407 /**
2408  * It is a handler who processes the H1 tag.
2409  *
2410  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2411  *                     destination is specified.
2412  * @param node   [i]   The H1 tag node is specified.
2413  * @return The conversion result is returned.
2414  */
2415 static char *
2416 s_chtml30_start_h1_tag(void *pdoc, Node *node)
2417 {
2418   chtml30_t     *chtml30;
2419   Doc           *doc;
2420   request_rec   *r;
2421   Attr          *attr;
2422
2423   chtml30 = GET_CHTML30(pdoc);
2424   doc     = chtml30->doc;
2425   r       = doc->r;
2426
2427   W_L("<h1");
2428   for (attr = qs_get_attr(doc,node);
2429        attr;
2430        attr = qs_get_next_attr(doc,attr)) {
2431     char *name = qs_get_attr_name(doc,attr);
2432     char *value = qs_get_attr_value(doc,attr);
2433     if (STRCASEEQ('a','A',"align", name)) {
2434       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2435         W_L(" align=\"");
2436         W_V(value);
2437         W_L("\"");
2438         break;
2439       }
2440     }
2441   }
2442   W_L(">");
2443
2444   return chtml30->out;
2445 }
2446
2447
2448 /**
2449  * It is a handler who processes the H1 tag.
2450  *
2451  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2452  *                     destination is specified.
2453  * @param node   [i]   The H1 tag node is specified.
2454  * @return The conversion result is returned.
2455  */
2456 static char *
2457 s_chtml30_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2458 {
2459   chtml30_t   *chtml30;
2460   Doc         *doc;
2461   request_rec *r;
2462
2463   chtml30 = GET_CHTML30(pdoc);
2464   doc     = chtml30->doc;
2465   r       = doc->r;
2466
2467   W_L("</h1>");
2468
2469   return chtml30->out;
2470 }
2471
2472
2473 /**
2474  * It is a handler who processes the H2 tag.
2475  *
2476  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2477  *                     destination is specified.
2478  * @param node   [i]   The H2 tag node is specified.
2479  * @return The conversion result is returned.
2480  */
2481 static char *
2482 s_chtml30_start_h2_tag(void *pdoc, Node *node)
2483 {
2484   chtml30_t     *chtml30;
2485   Doc           *doc;
2486   request_rec   *r;
2487   Attr          *attr;
2488
2489   chtml30 = GET_CHTML30(pdoc);
2490   doc     = chtml30->doc;
2491   r       = doc->r;
2492
2493   W_L("<h2");
2494   for (attr = qs_get_attr(doc,node);
2495        attr;
2496        attr = qs_get_next_attr(doc,attr)) {
2497     char* name;
2498     char* value;
2499     name  = qs_get_attr_name(doc,attr);
2500     value = qs_get_attr_value(doc,attr);
2501     if (STRCASEEQ('a','A',"align", name)) {
2502       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2503         W_L(" align=\"");
2504         W_V(value);
2505         W_L("\"");
2506         break;
2507       }
2508     }
2509   }
2510   W_L(">");
2511   return chtml30->out;
2512 }
2513
2514
2515 /**
2516  * It is a handler who processes the H2 tag.
2517  *
2518  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2519  *                     destination is specified.
2520  * @param node   [i]   The H2 tag node is specified.
2521  * @return The conversion result is returned.
2522  */
2523 static char *
2524 s_chtml30_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2525 {
2526   chtml30_t *chtml30;
2527   Doc *doc;
2528   request_rec *r;
2529
2530   chtml30 = GET_CHTML30(pdoc);
2531   doc     = chtml30->doc;
2532   r       = doc->r;
2533
2534   W_L("</h2>");
2535
2536   return chtml30->out;
2537 }
2538
2539
2540 /**
2541  * It is a handler who processes the H3 tag.
2542  *
2543  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2544  *                     destination is specified.
2545  * @param node   [i]   The H3 tag node is specified.
2546  * @return The conversion result is returned.
2547  */
2548 static char *
2549 s_chtml30_start_h3_tag(void *pdoc, Node *node)
2550 {
2551   chtml30_t *chtml30;
2552   Doc *doc;
2553   request_rec   *r;
2554   Attr          *attr;
2555
2556   chtml30 = GET_CHTML30(pdoc);
2557   doc     = chtml30->doc;
2558   r       = doc->r;
2559
2560   W_L("<h3");
2561   for (attr = qs_get_attr(doc,node);
2562        attr;
2563        attr = qs_get_next_attr(doc,attr)) {
2564     char* name;
2565     char* value;
2566     name  = qs_get_attr_name(doc,attr);
2567     value = qs_get_attr_value(doc,attr);
2568     if (STRCASEEQ('a','A',"align", name)) {
2569       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2570         W_L(" align=\"");
2571         W_V(value);
2572         W_L("\"");
2573         break;
2574       }
2575     }
2576   }
2577   W_L(">");
2578
2579   return chtml30->out;
2580 }
2581
2582
2583 /**
2584  * It is a handler who processes the H3 tag.
2585  *
2586  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2587  *                     destination is specified.
2588  * @param node   [i]   The H3 tag node is specified.
2589  * @return The conversion result is returned.
2590  */
2591 static char *
2592 s_chtml30_end_h3_tag(void *pdoc, Node *UNUSED(child))
2593 {
2594   chtml30_t *chtml30;
2595   Doc *doc;
2596   request_rec *r;
2597
2598   chtml30 = GET_CHTML30(pdoc);
2599   doc   = chtml30->doc;
2600   r     = doc->r;
2601
2602   W_L("</h3>");
2603
2604   return chtml30->out;
2605 }
2606
2607
2608 /**
2609  * It is a handler who processes the H4 tag.
2610  *
2611  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2612  *                     destination is specified.
2613  * @param node   [i]   The H4 tag node is specified.
2614  * @return The conversion result is returned.
2615  */
2616 static char *
2617 s_chtml30_start_h4_tag(void *pdoc, Node *node)
2618 {
2619   chtml30_t *chtml30;
2620   Doc *doc;
2621   request_rec *r;
2622   Attr *attr;
2623
2624   chtml30 = GET_CHTML30(pdoc);
2625   doc     = chtml30->doc;
2626   r       = doc->r;
2627
2628   W_L("<h4");
2629   for (attr = qs_get_attr(doc,node);
2630        attr;
2631        attr = qs_get_next_attr(doc,attr)) {
2632     char* name;
2633     char* value;
2634     name  = qs_get_attr_name(doc,attr);
2635     value = qs_get_attr_value(doc,attr);
2636     if (STRCASEEQ('a','A',"align", name)) {
2637       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2638         W_L(" align=\"");
2639         W_V(value);
2640         W_L("\"");
2641         break;
2642       }
2643     }
2644   }
2645   W_L(">");
2646   return chtml30->out;
2647 }
2648
2649
2650 /**
2651  * It is a handler who processes the H4 tag.
2652  *
2653  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2654  *                     destination is specified.
2655  * @param node   [i]   The H4 tag node is specified.
2656  * @return The conversion result is returned.
2657  */
2658 static char *
2659 s_chtml30_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2660 {
2661   chtml30_t *chtml30;
2662   Doc *doc;
2663   request_rec *r;
2664
2665   chtml30 = GET_CHTML30(pdoc);
2666   doc     = chtml30->doc;
2667   r       = doc->r;
2668
2669   W_L("</h4>");
2670
2671   return chtml30->out;
2672 }
2673
2674
2675 /**
2676  * It is a handler who processes the H5 tag.
2677  *
2678  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2679  *                     destination is specified.
2680  * @param node   [i]   The H5 tag node is specified.
2681  * @return The conversion result is returned.
2682  */
2683 static char *
2684 s_chtml30_start_h5_tag(void *pdoc, Node *node)
2685 {
2686   chtml30_t *chtml30;
2687   Doc *doc;
2688   request_rec *r;
2689   Attr *attr;
2690
2691   chtml30 = GET_CHTML30(pdoc);
2692   doc     = chtml30->doc;
2693   r       = doc->r;
2694
2695   W_L("<h5");
2696   for (attr = qs_get_attr(doc,node);
2697        attr;
2698        attr = qs_get_next_attr(doc,attr)) {
2699     char *name;
2700     char *value;
2701     name  = qs_get_attr_name(doc,attr);
2702     value = qs_get_attr_value(doc,attr);
2703     if (STRCASEEQ('a','A',"align", name)) {
2704       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2705         W_L(" align=\"");
2706         W_V(value);
2707         W_L("\"");
2708         break;
2709       }
2710     }
2711   }
2712   W_L(">");
2713   return chtml30->out;
2714 }
2715
2716
2717 /**
2718  * It is a handler who processes the H5 tag.
2719  *
2720  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2721  *                     destination is specified.
2722  * @param node   [i]   The H5 tag node is specified.
2723  * @return The conversion result is returned.
2724  */
2725 static char*
2726 s_chtml30_end_h5_tag(void* pdoc, Node* UNUSED(child)) 
2727 {
2728   chtml30_t*    chtml30;
2729   Doc*          doc;
2730   request_rec*  r;
2731
2732   chtml30 = GET_CHTML30(pdoc);
2733   doc     = chtml30->doc;
2734   r       = doc->r;
2735
2736   W_L("</h5>");
2737
2738   return chtml30->out;
2739 }
2740
2741
2742 /**
2743  * It is a handler who processes the H6 tag.
2744  *
2745  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2746  *                     destination is specified.
2747  * @param node   [i]   The H6 tag node is specified.
2748  * @return The conversion result is returned.
2749  */
2750 static char *
2751 s_chtml30_start_h6_tag(void *pdoc, Node *node)
2752 {
2753   chtml30_t *chtml30;
2754   Doc *doc;
2755   request_rec *r;
2756   Attr *attr;
2757
2758   chtml30 = GET_CHTML30(pdoc);
2759   doc     = chtml30->doc;
2760   r       = doc->r;
2761
2762   W_L("<h6");
2763   for (attr = qs_get_attr(doc,node);
2764        attr;
2765        attr = qs_get_next_attr(doc,attr)) {
2766     char *name;
2767     char *value;
2768     name  = qs_get_attr_name(doc,attr);
2769     value = qs_get_attr_value(doc,attr);
2770     if (STRCASEEQ('a','A',"align", name)) {
2771       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2772         W_L(" align=\"");
2773         W_V(value);
2774         W_L("\"");
2775         break;
2776       }
2777     }
2778   }
2779   W_L(">");
2780   return chtml30->out;
2781 }
2782
2783
2784 /**
2785  * It is a handler who processes the H6 tag.
2786  *
2787  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2788  *                     destination is specified.
2789  * @param node   [i]   The H6 tag node is specified.
2790  * @return The conversion result is returned.
2791  */
2792 static char*
2793 s_chtml30_end_h6_tag(void* pdoc, Node* UNUSED(child)) 
2794 {
2795   chtml30_t*    chtml30;
2796   Doc*          doc;
2797   request_rec*  r;
2798
2799   chtml30 = GET_CHTML30(pdoc);
2800   doc     = chtml30->doc;
2801   r       = doc->r;
2802
2803   W_L("</h6>");
2804
2805   return chtml30->out;
2806 }
2807
2808
2809 /**
2810  * It is a handler who processes the TEXTARE tag.
2811  *
2812  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2813  *                     destination is specified.
2814  * @param node   [i]   The TEXTAREA tag node is specified.
2815  * @return The conversion result is returned.
2816  */
2817 static char *
2818 s_chtml30_start_textarea_tag(void *pdoc, Node *node) 
2819 {
2820   chtml30_t     *chtml30;
2821   Doc           *doc;
2822   request_rec   *r;
2823   Attr          *attr;
2824
2825   chtml30 = GET_CHTML30(pdoc);
2826   doc     = chtml30->doc;
2827   r       = doc->r;
2828
2829   chtml30->textarea_flag++;
2830
2831   W_L("<textarea");
2832   for (attr = qs_get_attr(doc,node);
2833        attr;
2834        attr = qs_get_next_attr(doc,attr)) {
2835     char *name  = qs_get_attr_name(doc,attr);
2836     char *value = qs_get_attr_value(doc,attr);
2837     if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
2838       W_L(" accesskey=\"");
2839       W_V(value);
2840       W_L("\"");
2841     }
2842     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
2843       W_L(" istyle=\"");
2844       W_V(value);
2845       W_L("\"");
2846     }
2847     else if (STRCASEEQ('n','N',"name", name) && value && *value) {
2848       W_L(" name=\"");
2849       W_V(value);
2850       W_L("\"");
2851     }
2852     else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
2853       W_L(" rows=\"");
2854       W_V(value);
2855       W_L("\"");
2856     }
2857     else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
2858       W_L(" cols=\"");
2859       W_V(value);
2860       W_L("\"");
2861     }
2862   }
2863
2864   W_L(">");
2865
2866   return chtml30->out;
2867 }
2868
2869
2870 /**
2871  * It is a handler who processes the TEXTAREA tag.
2872  *
2873  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2874  *                     destination is specified.
2875  * @param node   [i]   The TEXTAREA tag node is specified.
2876  * @return The conversion result is returned.
2877  */
2878 static char*
2879 s_chtml30_end_textarea_tag(void* pdoc, Node* UNUSED(child)) 
2880 {
2881   chtml30_t*    chtml30;
2882   Doc*          doc;
2883   request_rec*  r;
2884
2885   chtml30 = GET_CHTML30(pdoc);
2886   doc     = chtml30->doc;
2887   r       = doc->r;
2888
2889   W_L("</textarea>");
2890   chtml30->textarea_flag--;
2891
2892   return chtml30->out;
2893 }
2894
2895
2896 static char*
2897 s_chtml30_chxjif_tag(void* pdoc, Node* node)
2898 {
2899   Node*         child;
2900   chtml30_t*    chtml30;
2901   Doc*          doc;
2902   request_rec*  r;
2903
2904   chtml30 = GET_CHTML30(pdoc);
2905   doc     = chtml30->doc;
2906   r       = doc->r;
2907
2908   for (child = qs_get_child_node(doc, node);
2909        child;
2910        child = qs_get_next_node(doc, child)) {
2911     W_V(child->otext);
2912     s_chtml30_chxjif_tag(chtml30, child);
2913   }
2914
2915   return NULL;
2916 }
2917
2918 static char *
2919 s_chtml30_text_tag(void *pdoc, Node *child)
2920 {
2921   chtml30_t *chtml30;
2922   Doc *doc;
2923   request_rec *r;
2924
2925   char *textval;
2926   char *tmp;
2927   char *tdst;
2928   char    one_byte[2];
2929   int     ii;
2930   int     tdst_len;
2931
2932   chtml30 = GET_CHTML30(pdoc);
2933   doc     = chtml30->doc;
2934   r       = doc->r;
2935   
2936   textval = qs_get_node_value(doc,child);
2937   if (strlen(textval) == 0) {
2938     return chtml30->out;
2939   }
2940   
2941   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2942   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2943   
2944   tdst     = qs_alloc_zero_byte_string(r);
2945   memset(one_byte, 0, sizeof(one_byte));
2946   tdst_len = 0;
2947   
2948   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2949     char* out;
2950     int rtn = s_chtml30_search_emoji(chtml30, &textval[ii], &out);
2951     if (rtn) {
2952       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2953       ii+=(rtn - 1);
2954       continue;
2955     }
2956   
2957     if (is_sjis_kanji(textval[ii])) {
2958       one_byte[0] = textval[ii+0];
2959       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2960       one_byte[0] = textval[ii+1];
2961       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2962       ii++;
2963     }
2964     else if (chtml30->pre_flag) {
2965       one_byte[0] = textval[ii+0];
2966       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2967     }
2968     else if (chtml30->textarea_flag) {
2969       one_byte[0] = textval[ii+0];
2970       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2971     }
2972     else if (textval[ii] != '\r' && textval[ii] != '\n') {
2973       one_byte[0] = textval[ii+0];
2974       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2975     }
2976   }
2977   W_V(tdst);
2978
2979   return chtml30->out;
2980 }
2981
2982
2983 /**
2984  * It is a handler who processes the BLOCKQUOTE tag.
2985  *
2986  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2987  *                     destination is specified.
2988  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2989  * @return The conversion result is returned.
2990  */
2991 static char *
2992 s_chtml30_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
2993 {
2994   chtml30_t *chtml30;
2995   Doc *doc;
2996   chtml30 = GET_CHTML30(pdoc);
2997   doc     = chtml30->doc;
2998   W_L("<blockquote>");
2999   return chtml30->out;
3000 }
3001
3002
3003 /**
3004  * It is a handler who processes the BLOCKQUOTE tag.
3005  *
3006  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3007  *                     destination is specified.
3008  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3009  * @return The conversion result is returned.
3010  */
3011 static char *
3012 s_chtml30_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3013 {
3014   chtml30_t *chtml30;
3015   Doc *doc;
3016
3017   chtml30 = GET_CHTML30(pdoc);
3018   doc     = chtml30->doc;
3019   W_L("</blockquote>");
3020   return chtml30->out;
3021 }
3022
3023
3024 /**
3025  * It is a handler who processes the DIR tag.
3026  *
3027  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3028  *                     destination is specified.
3029  * @param node   [i]   The DIR tag node is specified.
3030  * @return The conversion result is returned.
3031  */
3032 static char *
3033 s_chtml30_start_dir_tag(void *pdoc, Node *UNUSED(child))
3034 {
3035   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3036   Doc *doc = chtml30->doc;
3037   W_L("<dir>");
3038   return chtml30->out;
3039 }
3040
3041
3042 /**
3043  * It is a handler who processes the DIR tag.
3044  *
3045  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3046  *                     destination is specified.
3047  * @param node   [i]   The DIR tag node is specified.
3048  * @return The conversion result is returned.
3049  */
3050 static char *
3051 s_chtml30_end_dir_tag(void *pdoc, Node *UNUSED(child))
3052 {
3053   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3054   Doc *doc = chtml30->doc;
3055   W_L("</dir>");
3056   return chtml30->out;
3057 }
3058
3059
3060 /**
3061  * It is a handler who processes the DL tag.
3062  *
3063  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3064  *                     destination is specified.
3065  * @param node   [i]   The DL tag node is specified.
3066  * @return The conversion result is returned.
3067  */
3068 static char *
3069 s_chtml30_start_dl_tag(void *pdoc, Node *UNUSED(child))
3070 {
3071   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3072   Doc *doc = chtml30->doc;
3073   W_L("<dl>");
3074   return chtml30->out;
3075 }
3076
3077
3078 /**
3079  * It is a handler who processes the DL tag.
3080  *
3081  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3082  *                     destination is specified.
3083  * @param node   [i]   The DL tag node is specified.
3084  * @return The conversion result is returned.
3085  */
3086 static char *
3087 s_chtml30_end_dl_tag(void *pdoc, Node *UNUSED(child))
3088 {
3089   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3090   Doc *doc = chtml30->doc;
3091   W_L("</dl>");
3092   return chtml30->out;
3093 }
3094
3095
3096 /**
3097  * It is a handler who processes the DT tag.
3098  *
3099  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3100  *                     destination is specified.
3101  * @param node   [i]   The DT tag node is specified.
3102  * @return The conversion result is returned.
3103  */
3104 static char *
3105 s_chtml30_start_dt_tag(void *pdoc, Node *UNUSED(child))
3106 {
3107   chtml30_t *chtml30;
3108   Doc *doc;
3109   chtml30 = GET_CHTML30(pdoc);
3110   doc     = chtml30->doc;
3111   W_L("<dt>");
3112   return chtml30->out;
3113 }
3114
3115
3116 /**
3117  * It is a handler who processes the DT tag.
3118  *
3119  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3120  *                     destination is specified.
3121  * @param node   [i]   The DT tag node is specified.
3122  * @return The conversion result is returned.
3123  */
3124 static char *
3125 s_chtml30_end_dt_tag(void *pdoc, Node *UNUSED(child))
3126 {
3127   chtml30_t *chtml30;
3128   chtml30 = GET_CHTML30(pdoc);
3129   return chtml30->out;
3130 }
3131
3132
3133 /**
3134  * It is a handler who processes the DD tag.
3135  *
3136  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3137  *                     destination is specified.
3138  * @param node   [i]   The DD tag node is specified.
3139  * @return The conversion result is returned.
3140  */
3141 static char *
3142 s_chtml30_start_dd_tag(void *pdoc, Node *UNUSED(child))
3143 {
3144   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3145   Doc *doc = chtml30->doc;
3146   W_L("<dd>");
3147   return chtml30->out;
3148 }
3149
3150
3151 /**
3152  * It is a handler who processes the DD tag.
3153  *
3154  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3155  *                     destination is specified.
3156  * @param node   [i]   The DD tag node is specified.
3157  * @return The conversion result is returned.
3158  */
3159 static char *
3160 s_chtml30_end_dd_tag(void *pdoc, Node *UNUSED(child))
3161 {
3162   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3163   return chtml30->out;
3164 }
3165
3166
3167 /**
3168  * It is a handler who processes the MARQUEE tag.
3169  *
3170  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3171  *                     destination is specified.
3172  * @param node   [i]   The MARQUEE tag node is specified.
3173  * @return The conversion result is returned.
3174  */
3175 static char *
3176 s_chtml30_start_marquee_tag(void *pdoc, Node *node)
3177 {
3178   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3179   Doc *doc = chtml30->doc;
3180   Attr *attr;
3181   W_L("<marquee");
3182   /*--------------------------------------------------------------------------*/
3183   /* Get Attributes                                                           */
3184   /*--------------------------------------------------------------------------*/
3185   for (attr = qs_get_attr(doc,node);
3186        attr;
3187        attr = qs_get_next_attr(doc,attr)) {
3188     char *name   = qs_get_attr_name(doc,attr);
3189     char *value  = qs_get_attr_value(doc,attr);
3190     if (STRCASEEQ('d','D',"direction", name)) {
3191       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3192         W_L(" direction=\"");
3193         W_V(value);
3194         W_L("\"");
3195       }
3196     }
3197     else if (STRCASEEQ('b','B',"behavior",name)) {
3198       if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3199         W_L(" behavior=\""); 
3200         W_V(value);
3201         W_L("\"");
3202       }
3203     }
3204     else if (STRCASEEQ('l','L',"loop",name)) {
3205       if (value && *value) {
3206         W_L(" loop=\"");
3207         W_V(value);
3208         W_L("\"");
3209       }
3210     }
3211   }
3212   W_L(">");
3213   return chtml30->out;
3214 }
3215
3216
3217 /**
3218  * It is a handler who processes the MARQUEE tag.
3219  *
3220  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3221  *                     destination is specified.
3222  * @param node   [i]   The MARQUEE tag node is specified.
3223  * @return The conversion result is returned.
3224  */
3225 static char *
3226 s_chtml30_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3227 {
3228   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3229   Doc *doc = chtml30->doc;
3230   W_L("</marquee>");
3231   return chtml30->out;
3232 }
3233
3234
3235 /**
3236  * It is a handler who processes the BLINK tag.
3237  *
3238  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3239  *                     destination is specified.
3240  * @param node   [i]   The BLINK tag node is specified.
3241  * @return The conversion result is returned.
3242  */
3243 static char *
3244 s_chtml30_start_blink_tag(void *pdoc, Node *UNUSED(child))
3245 {
3246   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3247   Doc *doc = chtml30->doc;
3248   W_L("<blink>");
3249   return chtml30->out;
3250 }
3251
3252
3253 /**
3254  * It is a handler who processes the BLINK tag.
3255  *
3256  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3257  *                     destination is specified.
3258  * @param node   [i]   The BLINK tag node is specified.
3259  * @return The conversion result is returned.
3260  */
3261 static char *
3262 s_chtml30_end_blink_tag(void *pdoc, Node *UNUSED(child))
3263 {
3264   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3265   Doc *doc = chtml30->doc;
3266   W_L("</blink>");
3267   return chtml30->out;
3268 }
3269
3270
3271 /**
3272  * It is a handler who processes the MENU tag.
3273  *
3274  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3275  *                     destination is specified.
3276  * @param node   [i]   The MENU tag node is specified.
3277  * @return The conversion result is returned.
3278  */
3279 static char *
3280 s_chtml30_start_menu_tag(void *pdoc, Node *UNUSED(child))
3281 {
3282   chtml30_t *chtml30;
3283   Doc *doc;
3284   chtml30 = GET_CHTML30(pdoc);
3285   doc     = chtml30->doc;
3286   W_L("<menu>");
3287   return chtml30->out;
3288 }
3289
3290
3291 /**
3292  * It is a handler who processes the MENU tag.
3293  *
3294  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3295  *                     destination is specified.
3296  * @param node   [i]   The MENU tag node is specified.
3297  * @return The conversion result is returned.
3298  */
3299 static char *
3300 s_chtml30_end_menu_tag(void *pdoc, Node *UNUSED(child))
3301 {
3302   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3303   Doc *doc = chtml30->doc;
3304   W_L("</menu>");
3305   return chtml30->out;
3306 }
3307
3308
3309 /**
3310  * It is a handler who processes the PLAINTEXT tag.
3311  *
3312  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3313  *                     destination is specified.
3314  * @param node   [i]   The PLAINTEXT tag node is specified.
3315  * @return The conversion result is returned.
3316  */
3317 static char *
3318 s_chtml30_start_plaintext_tag(void *pdoc, Node *node)
3319 {
3320   chtml30_t *chtml30;
3321   Doc *doc;
3322
3323   chtml30 = GET_CHTML30(pdoc);
3324   doc     = chtml30->doc;
3325   W_L("<plaintext>");
3326   s_chtml30_start_plaintext_tag_inner(pdoc,node);
3327   return chtml30->out;
3328 }
3329
3330 static char *
3331 s_chtml30_start_plaintext_tag_inner(void *pdoc, Node *node)
3332 {
3333   chtml30_t *chtml30;
3334   Doc *doc;
3335   Node *child;
3336   chtml30 = GET_CHTML30(pdoc);
3337   doc     = chtml30->doc;
3338   for (child = qs_get_child_node(doc, node);
3339        child;
3340        child = qs_get_next_node(doc, child)) {
3341     W_V(child->otext);
3342     s_chtml30_start_plaintext_tag_inner(pdoc, child);
3343   }
3344   return chtml30->out;
3345 }
3346
3347
3348 /**
3349  * It is a handler who processes the PLAINTEXT tag.
3350  *
3351  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3352  *                     destination is specified.
3353  * @param node   [i]   The PLAINTEXT tag node is specified.
3354  * @return The conversion result is returned.
3355  */
3356 static char *
3357 s_chtml30_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3358 {
3359   chtml30_t *chtml30 = GET_CHTML30(pdoc);
3360   return chtml30->out;
3361 }
3362 /*
3363  * vim:ts=2 et
3364  */