OSDN Git Service

2a706e1247cf5641aadc5f27ad7bfe29f019bce8
[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 /**
1857  * It is a handler who processes the HR tag.
1858  *
1859  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1860  *                     destination is specified.
1861  * @param node   [i]   The HR tag node is specified.
1862  * @return The conversion result is returned.
1863  */
1864 static char*
1865 s_chtml10_start_hr_tag(void* pdoc, Node* node) 
1866 {
1867   chtml10_t*   chtml10;
1868   Doc*         doc;
1869   request_rec* r;
1870   Attr*        attr;
1871
1872   chtml10 = GET_CHTML10(pdoc);
1873   doc     = chtml10->doc;
1874   r       = doc->r;
1875
1876   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<hr ", NULL);
1877  
1878   for (attr = qs_get_attr(doc,node);
1879        attr; 
1880        attr = qs_get_next_attr(doc,attr)) {
1881     char* name;
1882     char* value;
1883
1884     name  = qs_get_attr_name (doc,attr);
1885     value = qs_get_attr_value(doc,attr);
1886
1887     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align") == 0) {
1888       /*----------------------------------------------------------------------*/
1889       /* CHTML 1.0                                                            */
1890       /*----------------------------------------------------------------------*/
1891       chtml10->out = apr_pstrcat(r->pool,
1892                         chtml10->out, 
1893                         " align=\"", value, "\" ", NULL);
1894     }
1895     else
1896     if ((*name == 's' || *name == 'S') && strcasecmp(name, "size") == 0) {
1897       /*----------------------------------------------------------------------*/
1898       /* CHTML 1.0                                                            */
1899       /*----------------------------------------------------------------------*/
1900       chtml10->out = apr_pstrcat(r->pool,
1901                         chtml10->out, 
1902                         " size=\"", value, "\" ", NULL);
1903     }
1904     else
1905     if ((*name == 'w' || *name == 'W') && strcasecmp(name, "width") == 0) {
1906       /*----------------------------------------------------------------------*/
1907       /* CHTML 1.0                                                            */
1908       /*----------------------------------------------------------------------*/
1909       chtml10->out = apr_pstrcat(r->pool,
1910                         chtml10->out, 
1911                         " width=\"", value, "\" ", NULL);
1912     }
1913     else
1914     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "noshade") == 0) {
1915       /*----------------------------------------------------------------------*/
1916       /* CHTML 1.0                                                            */
1917       /*----------------------------------------------------------------------*/
1918       chtml10->out = apr_pstrcat(r->pool,
1919                         chtml10->out, 
1920                         " noshade ", NULL);
1921     }
1922     else
1923     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "color") == 0) {
1924       /*----------------------------------------------------------------------*/
1925       /* CHTML 4.0                                                            */
1926       /*----------------------------------------------------------------------*/
1927       /* ignore */
1928     }
1929   }
1930
1931   chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >", NULL);
1932
1933   return chtml10->out;
1934 }
1935
1936
1937 /**
1938  * It is a handler who processes the HR tag.
1939  *
1940  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1941  *                     destination is specified.
1942  * @param node   [i]   The HR tag node is specified.
1943  * @return The conversion result is returned.
1944  */
1945 static char*
1946 s_chtml10_end_hr_tag(void* pdoc, Node* child) 
1947 {
1948   chtml10_t* chtml10;
1949
1950   chtml10 = GET_CHTML10(pdoc);
1951
1952   return chtml10->out;
1953 }
1954
1955
1956 /**
1957  * It is a handler who processes the IMG tag.
1958  *
1959  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1960  *                     destination is specified.
1961  * @param node   [i]   The IMG tag node is specified.
1962  * @return The conversion result is returned.
1963  */
1964 static char*
1965 s_chtml10_start_img_tag(void* pdoc, Node* node) 
1966 {
1967   chtml10_t*   chtml10;
1968   Doc*         doc;
1969   request_rec* r;
1970   Attr*        attr;
1971 #ifndef IMG_NOT_CONVERT_FILENAME
1972   device_table_t* spec;
1973 #endif
1974
1975   chtml10 = GET_CHTML10(pdoc);
1976 #ifndef IMG_NOT_CONVERT_FILENAME
1977   spec    = chtml10->spec;
1978 #endif
1979   doc     = chtml10->doc;
1980   r       = doc->r;
1981
1982   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<img", NULL);
1983  
1984
1985   /*--------------------------------------------------------------------------*/
1986   /* Get Attributes                                                           */
1987   /*--------------------------------------------------------------------------*/
1988   for (attr = qs_get_attr(doc,node);
1989        attr;
1990        attr = qs_get_next_attr(doc,attr)) {
1991     char* name;
1992     char* value;
1993
1994     name  = qs_get_attr_name (doc,attr);
1995     value = qs_get_attr_value(doc,attr);
1996
1997     if ((*name == 's' || *name == 'S') && strcasecmp(name, "src") == 0) {
1998       /*----------------------------------------------------------------------*/
1999       /* CHTML 1.0                                                            */
2000       /*----------------------------------------------------------------------*/
2001 #ifdef IMG_NOT_CONVERT_FILENAME
2002       chtml10->out = apr_pstrcat(r->pool, 
2003                       chtml10->out, " src=\"",value,"\"", NULL);
2004 #else
2005       chtml10->out = apr_pstrcat(r->pool, 
2006                       chtml10->out, " src=\"", 
2007                       chxj_img_conv(r, spec, value), NULL);
2008       chtml10->out = apr_pstrcat(r->pool, chtml10->out, "\"", NULL);
2009 #endif
2010     }
2011     else
2012     if (*name == 'a' || *name == 'A') {
2013       if (strcasecmp(name, "align" ) == 0) {
2014         /*--------------------------------------------------------------------*/
2015         /* CHTML 1.0                                                          */
2016         /*--------------------------------------------------------------------*/
2017         /*--------------------------------------------------------------------*/
2018         /* CHTML 4.0                                                          */
2019         /*--------------------------------------------------------------------*/
2020         chtml10->out = apr_pstrcat(r->pool, 
2021                         chtml10->out, " align=\"",value,"\"", NULL);
2022       }
2023       else
2024       if (strcasecmp(name, "alt"   ) == 0) {
2025         /*--------------------------------------------------------------------*/
2026         /* CHTML 1.0                                                          */
2027         /*--------------------------------------------------------------------*/
2028         chtml10->out = apr_pstrcat(r->pool, 
2029                         chtml10->out, " alt=\"",value,"\"", NULL);
2030       }
2031     }
2032     else
2033     if ((*name == 'w' || *name == 'W') && strcasecmp(name, "width" ) == 0) {
2034       /*----------------------------------------------------------------------*/
2035       /* CHTML 1.0                                                            */
2036       /*----------------------------------------------------------------------*/
2037       chtml10->out = apr_pstrcat(r->pool, 
2038                       chtml10->out, " width=\"",value,"\"", NULL);
2039     }
2040     else
2041     if (*name == 'h' || *name == 'H') {
2042       if (strcasecmp(name, "height") == 0) {
2043         /*--------------------------------------------------------------------*/
2044         /* CHTML 1.0                                                          */
2045         /*--------------------------------------------------------------------*/
2046         chtml10->out = apr_pstrcat(r->pool, 
2047                         chtml10->out, " height=\"",value,"\"", NULL);
2048       }
2049       else
2050       if (strcasecmp(name, "hspace") == 0) {
2051         /*--------------------------------------------------------------------*/
2052         /* CHTML 1.0                                                          */
2053         /*--------------------------------------------------------------------*/
2054         chtml10->out = apr_pstrcat(r->pool, 
2055                         chtml10->out, " hspace=\"",value,"\"", NULL);
2056       }
2057     }
2058     else
2059     if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vspace") == 0) {
2060       /*----------------------------------------------------------------------*/
2061       /* CHTML 1.0                                                            */
2062       /*----------------------------------------------------------------------*/
2063       chtml10->out = apr_pstrcat(r->pool, 
2064                       chtml10->out, " vspace=\"",value,"\"", NULL);
2065     }
2066   }
2067
2068   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2069
2070   return chtml10->out;
2071 }
2072
2073
2074 /**
2075  * It is a handler who processes the IMG tag.
2076  *
2077  * @param chtml10  [i/o] The pointer to the CHTML structure at the output
2078  *                     destination is specified.
2079  * @param node   [i]   The IMG tag node is specified.
2080  * @return The conversion result is returned.
2081  */
2082 static char*
2083 s_chtml10_end_img_tag(void* pdoc, Node* child) 
2084 {
2085   chtml10_t* chtml10;
2086
2087   chtml10 = GET_CHTML10(pdoc);
2088
2089   return chtml10->out;
2090 }
2091
2092
2093 /**
2094  * It is a handler who processes the SELECT tag.
2095  *
2096  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2097  *                     destination is specified.
2098  * @param node   [i]   The SELECT tag node is specified.
2099  * @return The conversion result is returned.
2100  */
2101 static char*
2102 s_chtml10_start_select_tag(void* pdoc, Node* child)
2103 {
2104   chtml10_t*   chtml10;
2105   Doc*         doc;
2106   request_rec* r;
2107   Attr*        attr;
2108
2109   char*        size;
2110   char*        name;
2111
2112   chtml10 = GET_CHTML10(pdoc);
2113   doc     = chtml10->doc;
2114   r       = doc->r;
2115
2116   size    = NULL;
2117   name    = NULL;
2118
2119   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<select", NULL);
2120   for (attr = qs_get_attr(doc,child);
2121        attr;
2122        attr = qs_get_next_attr(doc,attr)) {
2123     char* nm;
2124     char* val;
2125
2126     nm  = qs_get_attr_name (doc,attr);
2127     val = qs_get_attr_value(doc,attr);
2128
2129     if ((*nm == 's' || *nm == 'S') && strcasecmp(nm, "size") == 0) {
2130       /*----------------------------------------------------------------------*/
2131       /* CHTML 1.0 version 2.0                                                */
2132       /*----------------------------------------------------------------------*/
2133       size = apr_pstrdup(r->pool, val);
2134     }
2135     else
2136     if ((*nm == 'n' || *nm == 'N') && strcasecmp(nm, "name") == 0) {
2137       /*----------------------------------------------------------------------*/
2138       /* CHTML 1.0 version 2.0                                                */
2139       /*----------------------------------------------------------------------*/
2140       name = apr_pstrdup(r->pool, val);
2141     }
2142     else
2143     if ((*nm == 'm' || *nm == 'M') && strcasecmp(nm, "multiple") == 0) {
2144       /*----------------------------------------------------------------------*/
2145       /* CHTML 1.0 version 2.0                                                */
2146       /*----------------------------------------------------------------------*/
2147       /* Ignore */
2148     }
2149   }
2150
2151   if (size)
2152     chtml10->out = apr_pstrcat(r->pool, 
2153                                chtml10->out, 
2154                                " size=\"",
2155                                size,
2156                                "\"", 
2157                                NULL);
2158
2159   if (name) 
2160     chtml10->out = apr_pstrcat(r->pool, 
2161                                chtml10->out, 
2162                                " name=\"",
2163                                name,
2164                                "\"", 
2165                                NULL);
2166
2167   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\n", NULL);
2168
2169   return chtml10->out;
2170 }
2171
2172
2173 /**
2174  * It is a handler who processes the SELECT tag.
2175  *
2176  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2177  *                     destination is specified.
2178  * @param node   [i]   The SELECT tag node is specified.
2179  * @return The conversion result is returned.
2180  */
2181 static char*
2182 s_chtml10_end_select_tag(void* pdoc, Node* child)
2183 {
2184   chtml10_t*   chtml10;
2185   Doc*         doc;
2186   request_rec* r;
2187
2188   chtml10 = GET_CHTML10(pdoc);
2189   doc     = chtml10->doc;
2190   r       = doc->r;
2191
2192   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</select>\n", NULL);
2193
2194   return chtml10->out;
2195 }
2196
2197
2198 /**
2199  * It is a handler who processes the OPTION tag.
2200  *
2201  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2202  *                     destination is specified.
2203  * @param node   [i]   The OPTION tag node is specified.
2204  * @return The conversion result is returned.
2205  */
2206 static char*
2207 s_chtml10_start_option_tag(void* pdoc, Node* child)
2208 {
2209   chtml10_t*   chtml10;
2210   Doc*         doc;
2211   request_rec* r;
2212   Attr*        attr;
2213
2214   char*        selected;
2215   char*        value;
2216
2217   chtml10   = GET_CHTML10(pdoc);
2218   doc       = chtml10->doc;
2219   r         = doc->r;
2220
2221   selected  = NULL;
2222   value     = NULL;
2223
2224   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<option", NULL);
2225   for (attr = qs_get_attr(doc,child);
2226        attr;
2227        attr = qs_get_next_attr(doc,attr)) {
2228     char* nm;
2229     char* val;
2230
2231     nm  = qs_get_attr_name (doc,attr);
2232     val = qs_get_attr_value(doc,attr);
2233
2234     if ((*nm == 's' || *nm == 'S') && strcasecmp(nm, "selected") == 0) {
2235       /*----------------------------------------------------------------------*/
2236       /* CHTML 1.0 version 2.0                                                */
2237       /*----------------------------------------------------------------------*/
2238       selected = apr_pstrdup(r->pool, val);
2239     }
2240     else
2241     if ((*nm == 'v' || *nm == 'V') && strcasecmp(nm, "value") == 0) {
2242       /*----------------------------------------------------------------------*/
2243       /* CHTML 1.0 version 2.0                                                */
2244       /*----------------------------------------------------------------------*/
2245       value = apr_pstrdup(r->pool, val);
2246     }
2247   }
2248
2249   if (value)
2250     chtml10->out = apr_pstrcat(r->pool, 
2251                                chtml10->out, 
2252                                " value=\"",
2253                                value,
2254                                "\"", 
2255                                NULL);
2256   else
2257     chtml10->out = apr_pstrcat(r->pool, 
2258                                chtml10->out, 
2259                                " value=\"\"", 
2260                                NULL);
2261
2262   if (selected)
2263     chtml10->out = apr_pstrcat(r->pool, 
2264                                chtml10->out, 
2265                                " selected ", 
2266                                NULL);
2267
2268   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2269
2270   return chtml10->out;
2271 }
2272
2273
2274 /**
2275  * It is a handler who processes the OPTION tag.
2276  *
2277  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2278  *                     destination is specified.
2279  * @param node   [i]   The OPTION tag node is specified.
2280  * @return The conversion result is returned.
2281  */
2282 static char*
2283 s_chtml10_end_option_tag(void* pdoc, Node* child)
2284 {
2285   chtml10_t* chtml10;
2286  
2287   chtml10 = GET_CHTML10(pdoc);
2288
2289   /* Don't close */
2290
2291   return chtml10->out;
2292 }
2293
2294
2295 /**
2296  * It is a handler who processes the DIV tag.
2297  *
2298  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2299  *                     destination is specified.
2300  * @param node   [i]   The DIV tag node is specified.
2301  * @return The conversion result is returned.
2302  */
2303 static char*
2304 s_chtml10_start_div_tag(void* pdoc, Node* child)
2305 {
2306   chtml10_t*   chtml10;
2307   Doc*         doc;
2308   request_rec* r;
2309   Attr*        attr;
2310
2311   char*        align;
2312
2313   chtml10 = GET_CHTML10(pdoc);
2314   doc     = chtml10->doc;
2315   r       = doc->r;
2316
2317   align   = NULL;
2318
2319   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<div", NULL);
2320   for (attr = qs_get_attr(doc,child);
2321        attr;
2322        attr = qs_get_next_attr(doc,attr)) {
2323     char* nm;
2324     char* val;
2325
2326     nm  = qs_get_attr_name(doc,attr);
2327     val = qs_get_attr_value(doc,attr);
2328
2329     if ((*nm == 'a' || *nm == 'A') && strcasecmp(nm, "align") == 0) {
2330       /*----------------------------------------------------------------------*/
2331       /* CHTML 1.0 (W3C version 3.2)                                          */
2332       /*----------------------------------------------------------------------*/
2333       align = apr_pstrdup(r->pool, val);
2334     }
2335   }
2336
2337   if (align)
2338     chtml10->out = apr_pstrcat(r->pool, 
2339                     chtml10->out, " align=\"", align, "\"", NULL);
2340
2341   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2342
2343   return chtml10->out;
2344 }
2345
2346
2347 /**
2348  * It is a handler who processes the DIV tag.
2349  *
2350  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2351  *                     destination is specified.
2352  * @param node   [i]   The DIV tag node is specified.
2353  * @return The conversion result is returned.
2354  */
2355 static char*
2356 s_chtml10_end_div_tag(void* pdoc, Node* child)
2357 {
2358   chtml10_t*   chtml10;
2359   Doc*         doc;
2360   request_rec* r;
2361
2362   chtml10 = GET_CHTML10(pdoc);
2363   doc     = chtml10->doc;
2364   r       = doc->r;
2365
2366   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</div>\n", NULL);
2367
2368   return chtml10->out;
2369 }
2370
2371
2372 /**
2373  * It is a handler who processes the CHXJ:IF tag.
2374  *
2375  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2376  *                     destination is specified.
2377  * @param node   [i]   The CHXJ:IF tag node is specified.
2378  * @return The conversion result is returned.
2379  */
2380 static char* 
2381 s_chtml10_chxjif_tag(void* pdoc, Node* node)
2382 {
2383   chtml10_t*   chtml10;
2384   Doc*         doc;
2385   Node*        child;
2386   request_rec* r;
2387
2388   chtml10 = GET_CHTML10(pdoc);
2389   doc     = chtml10->doc;
2390   r       = doc->r;
2391
2392   for (child = qs_get_child_node(doc, node);
2393        child;
2394        child = qs_get_next_node(doc, child)) {
2395     chtml10->out = apr_pstrcat(r->pool, chtml10->out, child->otext, NULL);
2396     s_chtml10_chxjif_tag(chtml10, child);
2397   }
2398
2399   return chtml10->out;
2400 }
2401
2402
2403 /**
2404  * It is a handler who processes the PRE tag.
2405  *
2406  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2407  *                     destination is specified.
2408  * @param node   [i]   The PRE tag node is specified.
2409  * @return The conversion result is returned.
2410  */
2411 static char*
2412 s_chtml10_start_pre_tag(void* pdoc, Node* node) 
2413 {
2414   Doc*          doc;
2415   request_rec*  r;
2416   chtml10_t*    chtml10;
2417
2418   chtml10 = GET_CHTML10(pdoc);
2419   doc     = chtml10->doc;
2420   r       = doc->r;
2421
2422   chtml10->pre_flag++;
2423   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<pre>", NULL);
2424
2425   return chtml10->out;
2426 }
2427
2428
2429 /**
2430  * It is a handler who processes the PRE tag.
2431  *
2432  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2433  *                     destination is specified.
2434  * @param node   [i]   The PRE tag node is specified.
2435  * @return The conversion result is returned.
2436  */
2437 static char*
2438 s_chtml10_end_pre_tag(void* pdoc, Node* child) 
2439 {
2440   chtml10_t*    chtml10;
2441   Doc*          doc;
2442   request_rec*  r;
2443
2444   chtml10 = GET_CHTML10(pdoc);
2445   doc     = chtml10->doc;
2446   r       = doc->r;
2447
2448   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</pre>", NULL);
2449   chtml10->pre_flag--;
2450
2451   return chtml10->out;
2452 }
2453
2454
2455 /**
2456  * It is a handler who processes the P tag.
2457  *
2458  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2459  *                     destination is specified.
2460  * @param node   [i]   The P tag node is specified.
2461  * @return The conversion result is returned.
2462  */
2463 static char*
2464 s_chtml10_start_p_tag(void* pdoc, Node* node) 
2465 {
2466   Doc*          doc;
2467   request_rec*  r;
2468   chtml10_t*    chtml10;
2469
2470   chtml10 = GET_CHTML10(pdoc);
2471   doc     = chtml10->doc;
2472   r       = doc->r;
2473
2474   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<p>", NULL);
2475
2476   return chtml10->out;
2477 }
2478
2479
2480 /**
2481  * It is a handler who processes the P tag.
2482  *
2483  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2484  *                     destination is specified.
2485  * @param node   [i]   The P tag node is specified.
2486  * @return The conversion result is returned.
2487  */
2488 static char*
2489 s_chtml10_end_p_tag(void* pdoc, Node* child) 
2490 {
2491   Doc*          doc;
2492   request_rec*  r;
2493   chtml10_t*    chtml10;
2494
2495   chtml10 = GET_CHTML10(pdoc);
2496   doc     = chtml10->doc;
2497   r       = doc->r;
2498
2499   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</p>", NULL);
2500
2501   return chtml10->out;
2502 }
2503
2504
2505 /**
2506  * It is a handler who processes the TEXTARE tag.
2507  *
2508  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2509  *                     destination is specified.
2510  * @param node   [i]   The TEXTAREA tag node is specified.
2511  * @return The conversion result is returned.
2512  */
2513 static char*
2514 s_chtml10_start_textarea_tag(void* pdoc, Node* node) 
2515 {
2516   Doc*          doc;
2517   request_rec*  r;
2518   chtml10_t*    chtml10;
2519   Attr*         attr;
2520
2521   chtml10 = GET_CHTML10(pdoc);
2522   doc     = chtml10->doc;
2523   r       = doc->r;
2524
2525
2526   chtml10->textarea_flag++;
2527   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<textarea ", NULL);
2528
2529   for (attr = qs_get_attr(doc,node);
2530        attr;
2531        attr = qs_get_next_attr(doc,attr)) {
2532
2533     char* name;
2534     char* value;
2535
2536     name  = qs_get_attr_name (doc,attr);
2537     value = qs_get_attr_value(doc,attr);
2538
2539     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
2540       chtml10->out = apr_pstrcat(r->pool, 
2541                                  chtml10->out, 
2542                                  " name=\"",
2543                                  value,
2544                                  "\"", 
2545                                  NULL);
2546     }
2547     else 
2548     if ((*name == 'r' || *name == 'R') && strcasecmp(name, "rows") == 0) {
2549       chtml10->out = apr_pstrcat(r->pool, chtml10->out, " rows=\"",value,"\"", NULL);
2550     }
2551     else 
2552     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cols") == 0) {
2553       chtml10->out = apr_pstrcat(r->pool, chtml10->out, " cols=\"",value,"\"", NULL);
2554     }
2555   }
2556
2557   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\r\n", NULL);
2558
2559   return chtml10->out;
2560 }
2561
2562 /**
2563  * It is a handler who processes the TEXTAREA tag.
2564  *
2565  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2566  *                     destination is specified.
2567  * @param node   [i]   The TEXTAREA tag node is specified.
2568  * @return The conversion result is returned.
2569  */
2570 static char*
2571 s_chtml10_end_textarea_tag(void* pdoc, Node* child) 
2572 {
2573   Doc*          doc;
2574   request_rec*  r;
2575   chtml10_t*    chtml10;
2576
2577   chtml10 = GET_CHTML10(pdoc);
2578   doc     = chtml10->doc;
2579   r       = doc->r;
2580
2581   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</textarea>\r\n", NULL);
2582   chtml10->textarea_flag--;
2583
2584   return chtml10->out;
2585 }
2586
2587
2588 static char*
2589 s_chtml10_text(void* pdoc, Node* child)
2590 {
2591   char*        textval;
2592   char*        tmp;
2593   char*        tdst;
2594   char         one_byte[2];
2595   int          ii;
2596   int          tdst_len;
2597   chtml10_t*   chtml10;
2598   Doc*         doc;
2599   request_rec* r;
2600
2601   chtml10 = GET_CHTML10(pdoc);
2602   doc     = chtml10->doc;
2603   r       = doc->r;
2604   
2605   textval = qs_get_node_value(doc,child);
2606   textval = qs_trim_string(r, textval);
2607   if (strlen(textval) == 0)
2608     return chtml10->out;
2609   
2610   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2611   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2612   
2613   tdst     = qs_alloc_zero_byte_string(r);
2614   memset(one_byte, 0, sizeof(one_byte));
2615   tdst_len = 0;
2616   
2617   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2618     char* out;
2619     int rtn = s_chtml10_search_emoji(chtml10, &textval[ii], &out);
2620     if (rtn) {
2621       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2622       ii+=(rtn - 1);
2623       continue;
2624     }
2625   
2626     if (is_sjis_kanji(textval[ii])) {
2627       one_byte[0] = textval[ii+0];
2628       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2629       one_byte[0] = textval[ii+1];
2630       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2631       ii++;
2632     }
2633     else 
2634     if (chtml10->pre_flag) {
2635       one_byte[0] = textval[ii+0];
2636       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2637     }
2638     else 
2639     if (chtml10->textarea_flag) {
2640       one_byte[0] = textval[ii+0];
2641       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2642     }
2643     else 
2644     if (textval[ii] != '\r' && textval[ii] != '\n') {
2645       one_byte[0] = textval[ii+0];
2646       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2647     }
2648   }
2649   chtml10->out = apr_pstrcat(r->pool, chtml10->out, tdst, NULL);
2650
2651   return chtml10->out;
2652 }
2653 /*
2654  * vim:ts=2 et
2655  */