OSDN Git Service

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