OSDN Git Service

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