OSDN Git Service

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