OSDN Git Service

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