OSDN Git Service

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