OSDN Git Service

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