OSDN Git Service

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