OSDN Git Service

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