OSDN Git Service

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