OSDN Git Service

* change writting.
[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;
1154     char* value;
1155
1156     name  = qs_get_attr_name(doc,attr);
1157     value = qs_get_attr_value(doc,attr);
1158
1159     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "href") == 0) {
1160       chtml10->out = apr_pstrcat(r->pool, 
1161                       chtml10->out, 
1162                       " href=\"", 
1163                       value, 
1164                       "\"", 
1165                       NULL);
1166     }
1167   }
1168
1169   chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >\r\n", NULL);
1170
1171   return chtml10->out;
1172 }
1173
1174
1175 /**
1176  * It is a handler who processes the BASE tag.
1177  *
1178  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1179  *                     destination is specified.
1180  * @param node   [i]   The BASE tag node is specified.
1181  * @return The conversion result is returned.
1182  */
1183 static char*
1184 s_chtml10_end_base_tag(void* pdoc, Node* child) 
1185 {
1186   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1187
1188   return chtml10->out;
1189 }
1190
1191
1192 /**
1193  * It is a handler who processes the BODY tag.
1194  *
1195  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1196  *                     destination is specified.
1197  * @param node   [i]   The BODY tag node is specified.
1198  * @return The conversion result is returned.
1199  */
1200 static char*
1201 s_chtml10_start_body_tag(void* pdoc, Node* node) 
1202 {
1203   chtml10_t*   chtml10;
1204   Doc*         doc;
1205   request_rec* r;
1206   Attr*        attr;
1207
1208   chtml10 = GET_CHTML10(pdoc);
1209   doc     = chtml10->doc;
1210   r       = doc->r;
1211
1212   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<body", NULL);
1213
1214   /*--------------------------------------------------------------------------*/
1215   /* Get Attributes                                                           */
1216   /*--------------------------------------------------------------------------*/
1217   for (attr = qs_get_attr(doc,node);
1218        attr;
1219        attr = qs_get_next_attr(doc,attr)) {
1220
1221     char* name;
1222
1223     name  = qs_get_attr_name(doc,attr);
1224
1225     switch(*name) {
1226     case 'a':
1227     case 'A':
1228       if (strcasecmp(name, "alink") == 0) {
1229         /*----------------------------------------------------------------------*/
1230         /* CHTML 4.0                                                            */
1231         /*----------------------------------------------------------------------*/
1232         /* ignore */
1233       }
1234       break;
1235
1236     case 'b':
1237     case 'B':
1238       if (strcasecmp(name, "bgcolor") == 0) {
1239         /*----------------------------------------------------------------------*/
1240         /* CHTML 2.0                                                            */
1241         /*----------------------------------------------------------------------*/
1242         /* ignore */
1243       }
1244       break;
1245
1246     case 't':
1247     case 'T':
1248       if (strcasecmp(name, "text") == 0) {
1249         /*----------------------------------------------------------------------*/
1250         /* CHTML 2.0                                                            */
1251         /*----------------------------------------------------------------------*/
1252         /* ignore */
1253       }
1254       break;
1255
1256     case 'l':
1257     case 'L':
1258       if (strcasecmp(name, "link") == 0) {
1259         /*----------------------------------------------------------------------*/
1260         /* CHTML 2.0                                                            */
1261         /*----------------------------------------------------------------------*/
1262         /* ignore */
1263       }
1264       break;
1265
1266     case 'v':
1267     case 'V':
1268       if (strcasecmp(name, "vlink") == 0) {
1269         /*----------------------------------------------------------------------*/
1270         /* CHTML 4.0                                                            */
1271         /*----------------------------------------------------------------------*/
1272         /* ignore */
1273       }
1274       break;
1275
1276     default:
1277       break;
1278     }
1279   }
1280
1281   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\r\n", NULL);
1282
1283   return chtml10->out;
1284 }
1285
1286
1287 /**
1288  * It is a handler who processes the BODY tag.
1289  *
1290  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1291  *                     destination is specified.
1292  * @param node   [i]   The BODY tag node is specified.
1293  * @return The conversion result is returned.
1294  */
1295 static char*
1296 s_chtml10_end_body_tag(void* pdoc, Node* child) 
1297 {
1298   Doc*          doc;
1299   request_rec*  r;
1300   chtml10_t*    chtml10;
1301
1302   chtml10 = GET_CHTML10(pdoc);
1303   doc     = chtml10->doc;
1304   r       = doc->r;
1305
1306   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</body>\r\n", NULL);
1307
1308   return chtml10->out;
1309 }
1310
1311
1312 /**
1313  * It is a handler who processes the A tag.
1314  *
1315  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1316  *                     destination is specified.
1317  * @param node   [i]   The A tag node is specified.
1318  * @return The conversion result is returned.
1319  */
1320 static char*
1321 s_chtml10_start_a_tag(void* pdoc, Node* node) 
1322 {
1323   chtml10_t*    chtml10;
1324   Doc*          doc;
1325   request_rec*  r;
1326   Attr*         attr;
1327
1328   chtml10 = GET_CHTML10(pdoc);
1329   doc     = chtml10->doc;
1330   r       = doc->r;
1331
1332   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<a", NULL);
1333
1334   /*--------------------------------------------------------------------------*/
1335   /* Get Attributes                                                           */
1336   /*--------------------------------------------------------------------------*/
1337   for (attr = qs_get_attr(doc,node);
1338        attr; 
1339        attr = qs_get_next_attr(doc,attr)) {
1340
1341     char* name;
1342     char* value;
1343
1344     name  = qs_get_attr_name(doc,attr);
1345     value = qs_get_attr_value(doc,attr);
1346
1347     switch(*name) {
1348     case 'n':
1349     case 'N':
1350       if (strcasecmp(name, "name") == 0) {
1351         /*----------------------------------------------------------------------*/
1352         /* CHTML1.0                                                             */
1353         /*----------------------------------------------------------------------*/
1354         chtml10->out = apr_pstrcat(r->pool, 
1355                         chtml10->out, 
1356                         " name=\"", 
1357                         value, 
1358                         "\"", 
1359                         NULL);
1360       }
1361       break;
1362
1363     case 'h':
1364     case 'H':
1365       if (strcasecmp(name, "href") == 0) {
1366         /*----------------------------------------------------------------------*/
1367         /* CHTML1.0                                                             */
1368         /*----------------------------------------------------------------------*/
1369         value = chxj_add_cookie_parameter(r, value, chtml10->cookie_id);
1370         
1371         chtml10->out = apr_pstrcat(r->pool, 
1372                         chtml10->out, 
1373                         " href=\"", 
1374                         value, 
1375                         "\"", 
1376                         NULL);
1377       }
1378       break;
1379
1380     case 'a':
1381     case 'A':
1382       if (strcasecmp(name, "accesskey") == 0) {
1383         /*----------------------------------------------------------------------*/
1384         /* CHTML1.0                                                             */
1385         /*----------------------------------------------------------------------*/
1386         chtml10->out = apr_pstrcat(r->pool, 
1387                         chtml10->out, 
1388                         " accesskey=\"", 
1389                         value, 
1390                         "\"", 
1391                         NULL);
1392       }
1393       break;
1394
1395     case 'c':
1396     case 'C':
1397       if (strcasecmp(name, "cti") == 0) {
1398         /*----------------------------------------------------------------------*/
1399         /* CHTML 2.0                                                            */
1400         /*----------------------------------------------------------------------*/
1401         /* ignore */
1402       }
1403       break;
1404
1405     case 'u':
1406     case 'U':
1407       if (strcasecmp(name, "utn") == 0) {
1408         /*----------------------------------------------------------------------*/
1409         /* CHTML 3.0                                                            */
1410         /*----------------------------------------------------------------------*/
1411         /* ignore */
1412       }
1413       break;
1414
1415     case 't':
1416     case 'T':
1417       if (strcasecmp(name, "telbook") == 0) {
1418         /*----------------------------------------------------------------------*/
1419         /* CHTML 3.0                                                            */
1420         /*----------------------------------------------------------------------*/
1421         /* ignore */
1422       }
1423       break;
1424
1425     case 'k':
1426     case 'K':
1427       if (strcasecmp(name, "kana") == 0) {
1428         /*----------------------------------------------------------------------*/
1429         /* CHTML 3.0                                                            */
1430         /*----------------------------------------------------------------------*/
1431         /* ignore */
1432       }
1433       break;
1434
1435     case 'e':
1436     case 'E':
1437       if (strcasecmp(name, "email") == 0) {
1438         /*----------------------------------------------------------------------*/
1439         /* CHTML 3.0                                                            */
1440         /*----------------------------------------------------------------------*/
1441         /* ignore */
1442       }
1443       break;
1444
1445     case 'i':
1446     case 'I':
1447       if (strcasecmp(name, "ista") == 0) {
1448         /*----------------------------------------------------------------------*/
1449         /* CHTML 4.0                                                            */
1450         /*----------------------------------------------------------------------*/
1451         /* ignore */
1452       }
1453       else
1454       if (strcasecmp(name, "ilet") == 0) {
1455         /*----------------------------------------------------------------------*/
1456         /* CHTML 5.0                                                            */
1457         /*----------------------------------------------------------------------*/
1458         /* ignore */
1459       }
1460       else
1461       if (strcasecmp(name, "iswf") == 0) {
1462         /*----------------------------------------------------------------------*/
1463         /* CHTML 5.0                                                            */
1464         /*----------------------------------------------------------------------*/
1465         /* ignore */
1466       }
1467       else
1468       if (strcasecmp(name, "irst") == 0) {
1469         /*----------------------------------------------------------------------*/
1470         /* CHTML 5.0                                                            */
1471         /*----------------------------------------------------------------------*/
1472         /* ignore */
1473       }
1474       else
1475       if (strcasecmp(name, "ijam") == 0) {
1476         /*----------------------------------------------------------------------*/
1477         /* CHTML 3.0                                                            */
1478         /*----------------------------------------------------------------------*/
1479         /* ignore */
1480       }
1481       break;
1482
1483     default:
1484       break;
1485     }
1486   }
1487
1488   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
1489
1490   return chtml10->out;
1491 }
1492
1493
1494 /**
1495  * It is a handler who processes the A tag.
1496  *
1497  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1498  *                     destination is specified.
1499  * @param node   [i]   The A tag node is specified.
1500  * @return The conversion result is returned.
1501  */
1502 static char*
1503 s_chtml10_end_a_tag(void* pdoc, Node* child) 
1504 {
1505   chtml10_t*   chtml10;
1506   Doc*         doc;
1507   request_rec* r;
1508
1509   chtml10 = GET_CHTML10(pdoc);
1510   doc     = chtml10->doc;
1511   r       = doc->r;
1512
1513   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</a>", NULL);
1514
1515   return chtml10->out;
1516 }
1517
1518
1519 /**
1520  * It is a handler who processes the BR tag.
1521  *
1522  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1523  *                     destination is specified.
1524  * @param node   [i]   The BR tag node is specified.
1525  * @return The conversion result is returned.
1526  */
1527 static char*
1528 s_chtml10_start_br_tag(void* pdoc, Node* node) 
1529 {
1530   chtml10_t*   chtml10;
1531   Doc*         doc;
1532   request_rec* r;
1533
1534   chtml10 = GET_CHTML10(pdoc);
1535   doc     = chtml10->doc;
1536   r       = doc->r;
1537
1538   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<br>\r\n", NULL);
1539
1540   return chtml10->out;
1541 }
1542
1543
1544 /**
1545  * It is a handler who processes the BR tag.
1546  *
1547  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1548  *                     destination is specified.
1549  * @param node   [i]   The BR tag node is specified.
1550  * @return The conversion result is returned.
1551  */
1552 static char*
1553 s_chtml10_end_br_tag(void* pdoc, Node* child) 
1554 {
1555   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1556
1557   return chtml10->out;
1558 }
1559
1560
1561 /**
1562  * It is a handler who processes the TR tag.
1563  *
1564  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1565  *                     destination is specified.
1566  * @param node   [i]   The TR tag node is specified.
1567  * @return The conversion result is returned.
1568  */
1569 static char*
1570 s_chtml10_start_tr_tag(void* pdoc, Node* node) 
1571 {
1572   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1573
1574   return chtml10->out;
1575 }
1576
1577
1578 /**
1579  * It is a handler who processes the TR tag.
1580  *
1581  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1582  *                     destination is specified.
1583  * @param node   [i]   The TR tag node is specified.
1584  * @return The conversion result is returned.
1585  */
1586 static char*
1587 s_chtml10_end_tr_tag(void* pdoc, Node* child) 
1588 {
1589   chtml10_t*   chtml10;
1590   Doc*         doc;
1591   request_rec* r;
1592
1593   chtml10 = GET_CHTML10(pdoc);
1594   doc     = chtml10->doc;
1595   r       = doc->r;
1596
1597   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<br>\r\n", NULL);
1598
1599   return chtml10->out;
1600 }
1601
1602
1603 /**
1604  * It is a handler who processes the FONT tag.
1605  *
1606  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1607  *                     destination is specified.
1608  * @param node   [i]   The FONT tag node is specified.
1609  * @return The conversion result is returned.
1610  */
1611 static char*
1612 s_chtml10_start_font_tag(void* pdoc, Node* node) 
1613 {
1614   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1615
1616   /* Ignore */
1617
1618   return chtml10->out;
1619 }
1620
1621
1622 /**
1623  * It is a handler who processes the FONT tag.
1624  *
1625  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1626  *                     destination is specified.
1627  * @param node   [i]   The FONT tag node is specified.
1628  * @return The conversion result is returned.
1629  */
1630 static char*
1631 s_chtml10_end_font_tag(void* pdoc, Node* child) 
1632 {
1633   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1634
1635   /* ignore */
1636
1637   return chtml10->out;
1638 }
1639
1640
1641 /**
1642  * It is a handler who processes the FORM tag.
1643  *
1644  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1645  *                     destination is specified.
1646  * @param node   [i]   The FORM tag node is specified.
1647  * @return The conversion result is returned.
1648  */
1649 static char*
1650 s_chtml10_start_form_tag(void* pdoc, Node* node) 
1651 {
1652   chtml10_t*   chtml10;
1653   Doc*         doc;
1654   request_rec* r;
1655   Attr*        attr;
1656
1657   chtml10 = GET_CHTML10(pdoc);
1658   doc     = chtml10->doc;
1659   r       = doc->r;
1660
1661   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<form", NULL);
1662
1663   /*--------------------------------------------------------------------------*/
1664   /* Get Attributes                                                           */
1665   /*--------------------------------------------------------------------------*/
1666   for (attr = qs_get_attr(doc,node);
1667        attr;
1668        attr = qs_get_next_attr(doc,attr)) {
1669     char* name;
1670     char* value;
1671
1672     name  = qs_get_attr_name(doc,attr);
1673     value = qs_get_attr_value(doc,attr);
1674
1675     switch(*name) {
1676     case 'a':
1677     case 'A':
1678       if (strcasecmp(name, "action") == 0) {
1679         /*----------------------------------------------------------------------*/
1680         /* CHTML 1.0                                                            */
1681         /*----------------------------------------------------------------------*/
1682         value = chxj_add_cookie_parameter(r, value, chtml10->cookie_id);
1683   
1684         chtml10->out = apr_pstrcat(r->pool, 
1685                         chtml10->out, 
1686                         " action=\"",
1687                         value,
1688                         "\"", 
1689                         NULL);
1690       }
1691       break;
1692
1693     case 'm':
1694     case 'M':
1695       if (strcasecmp(name, "method") == 0) {
1696         /*----------------------------------------------------------------------*/
1697         /* CHTML 1.0                                                            */
1698         /*----------------------------------------------------------------------*/
1699         chtml10->out = apr_pstrcat(r->pool, 
1700                         chtml10->out, 
1701                         " method=\"",
1702                         value,
1703                         "\"", 
1704                         NULL);
1705       }
1706       break;
1707
1708     case 'u':
1709     case 'U':
1710       if (strcasecmp(name, "utn") == 0) {
1711         /*----------------------------------------------------------------------*/
1712         /* CHTML 3.0                                                            */
1713         /*----------------------------------------------------------------------*/
1714         /* ignore */
1715       }
1716       break;
1717
1718     default:
1719       break;
1720     }
1721   }
1722
1723   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
1724
1725   return chtml10->out;
1726 }
1727
1728
1729 /**
1730  * It is a handler who processes the FORM tag.
1731  *
1732  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1733  *                     destination is specified.
1734  * @param node   [i]   The FORM tag node is specified.
1735  * @return The conversion result is returned.
1736  */
1737 static char*
1738 s_chtml10_end_form_tag(void* pdoc, Node* child) 
1739 {
1740   chtml10_t*   chtml10;
1741   Doc*         doc;
1742   request_rec* r;
1743
1744   chtml10 = GET_CHTML10(pdoc);
1745   doc     = chtml10->doc;
1746   r       = doc->r;
1747
1748   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</form>", NULL);
1749
1750   return chtml10->out;
1751 }
1752
1753
1754 /**
1755  * It is a handler who processes the INPUT tag.
1756  *
1757  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1758  *                     destination is specified.
1759  * @param node   [i]   The INPUT tag node is specified.
1760  * @return The conversion result is returned.
1761  */
1762 static char*
1763 s_chtml10_start_input_tag(void* pdoc, Node* node) 
1764 {
1765   chtml10_t*    chtml10;
1766   Doc*          doc;
1767   request_rec*  r;
1768   char*         max_length;
1769   char*         type;
1770   char*         name;
1771   char*         value;
1772   char*         istyle;
1773   char*         size;
1774   char*         checked;
1775   char*         accesskey;
1776
1777   chtml10     = GET_CHTML10(pdoc);
1778   doc         = chtml10->doc;
1779   r           = doc->r;
1780
1781   max_length  = NULL;
1782   type        = NULL;
1783   name        = NULL;
1784   value       = NULL;
1785   istyle      = NULL;
1786   size        = NULL;
1787   checked     = NULL;
1788   accesskey   = NULL;
1789
1790   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<input", NULL);
1791
1792   /*--------------------------------------------------------------------------*/
1793   /* Get Attributes                                                           */
1794   /*--------------------------------------------------------------------------*/
1795
1796   type       = qs_get_type_attr(doc, node, r);
1797   name       = qs_get_name_attr(doc, node, r);
1798   value      = qs_get_value_attr(doc,node,r);
1799   istyle     = qs_get_istyle_attr(doc,node,r);
1800   max_length = qs_get_maxlength_attr(doc,node,r);
1801   checked    = qs_get_checked_attr(doc,node,r);
1802   accesskey  = qs_get_accesskey_attr(doc, node, r);
1803   size       = qs_get_size_attr(doc, node, r);
1804
1805   if (type)
1806     chtml10->out = apr_pstrcat(r->pool,
1807                     chtml10->out, 
1808                     " type=\"", 
1809                     type, 
1810                     "\" ", 
1811                     NULL);
1812
1813   if (size) 
1814     chtml10->out = apr_pstrcat(r->pool, 
1815                     chtml10->out, 
1816                     " size=\"", 
1817                     size, 
1818                     "\" ", 
1819                     NULL);
1820
1821   if (name)
1822     chtml10->out = apr_pstrcat(r->pool, 
1823                     chtml10->out, 
1824                     " name=\"", 
1825                     name, 
1826                     "\" ", 
1827                     NULL);
1828
1829   if (value)
1830     chtml10->out = apr_pstrcat(r->pool, 
1831                     chtml10->out, 
1832                     " value=\"", 
1833                     value, 
1834                     "\" ", 
1835                     NULL);
1836
1837   if (accesskey)
1838     chtml10->out = apr_pstrcat(r->pool, 
1839                     chtml10->out, 
1840                     " accesskey=\"", 
1841                     accesskey, "\" ", 
1842                     NULL);
1843
1844   if (istyle) {
1845     /*------------------------------------------------------------------------*/
1846     /* CHTML 2.0                                                              */
1847     /*------------------------------------------------------------------------*/
1848     /* ignore */
1849   }
1850   /*--------------------------------------------------------------------------*/
1851   /* The figure is default for the password.                                  */
1852   /*--------------------------------------------------------------------------*/
1853   if (max_length)
1854     chtml10->out = apr_pstrcat(r->pool, 
1855                       chtml10->out, 
1856                       " maxlength=\"", 
1857                       max_length, 
1858                       "\"", 
1859                       NULL);
1860
1861   if (checked)
1862     chtml10->out = apr_pstrcat(r->pool, 
1863                     chtml10->out, " checked ", NULL);
1864
1865   chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >", NULL);
1866
1867   return chtml10->out;
1868 }
1869
1870
1871 /**
1872  * It is a handler who processes the INPUT tag.
1873  *
1874  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1875  *                     destination is specified.
1876  * @param node   [i]   The INPUT tag node is specified.
1877  * @return The conversion result is returned.
1878  */
1879 static char*
1880 s_chtml10_end_input_tag(void* pdoc, Node* child) 
1881 {
1882   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1883
1884   return chtml10->out;
1885 }
1886
1887
1888 /**
1889  * It is a handler who processes the CENTER tag.
1890  *
1891  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1892  *                     destination is specified.
1893  * @param node   [i]   The CENTER tag node is specified.
1894  * @return The conversion result is returned.
1895  */
1896 static char*
1897 s_chtml10_start_center_tag(void* pdoc, Node* node) 
1898 {
1899   chtml10_t*   chtml10;
1900   Doc*         doc;
1901   request_rec* r;
1902
1903   chtml10 = GET_CHTML10(pdoc);
1904   doc     = chtml10->doc;
1905   r       = doc->r;
1906
1907   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<center>", NULL);
1908
1909   return chtml10->out;
1910 }
1911
1912
1913 /**
1914  * It is a handler who processes the CENTER tag.
1915  *
1916  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1917  *                     destination is specified.
1918  * @param node   [i]   The CENTER tag node is specified.
1919  * @return The conversion result is returned.
1920  */
1921 static char*
1922 s_chtml10_end_center_tag(void* pdoc, Node* child) 
1923 {
1924   chtml10_t*    chtml10;
1925   Doc*          doc;
1926   request_rec*  r;
1927
1928   chtml10 = GET_CHTML10(pdoc);
1929   doc     = chtml10->doc;
1930   r       = doc->r;
1931
1932   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</center>", NULL);
1933
1934   return chtml10->out;
1935 }
1936
1937
1938 /**
1939  * It is a handler who processes the HR tag.
1940  *
1941  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1942  *                     destination is specified.
1943  * @param node   [i]   The HR tag node is specified.
1944  * @return The conversion result is returned.
1945  */
1946 static char*
1947 s_chtml10_start_hr_tag(void* pdoc, Node* node) 
1948 {
1949   chtml10_t*   chtml10;
1950   Doc*         doc;
1951   request_rec* r;
1952   Attr*        attr;
1953
1954   chtml10 = GET_CHTML10(pdoc);
1955   doc     = chtml10->doc;
1956   r       = doc->r;
1957
1958   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<hr ", NULL);
1959  
1960   for (attr = qs_get_attr(doc,node);
1961        attr; 
1962        attr = qs_get_next_attr(doc,attr)) {
1963
1964     char* name;
1965     char* value;
1966
1967     name  = qs_get_attr_name (doc,attr);
1968     value = qs_get_attr_value(doc,attr);
1969
1970     switch(*name) {
1971     case 'a':
1972     case 'A':
1973       if (strcasecmp(name, "align") == 0) {
1974         /*----------------------------------------------------------------------*/
1975         /* CHTML 1.0                                                            */
1976         /*----------------------------------------------------------------------*/
1977         chtml10->out = apr_pstrcat(r->pool,
1978                           chtml10->out, 
1979                           " align=\"", value, "\" ", NULL);
1980       }
1981       break;
1982
1983     case 's':
1984     case 'S':
1985       if (strcasecmp(name, "size") == 0) {
1986         /*----------------------------------------------------------------------*/
1987         /* CHTML 1.0                                                            */
1988         /*----------------------------------------------------------------------*/
1989         chtml10->out = apr_pstrcat(r->pool,
1990                           chtml10->out, 
1991                           " size=\"", value, "\" ", NULL);
1992       }
1993       break;
1994
1995     case 'w':
1996     case 'W':
1997       if (strcasecmp(name, "width") == 0) {
1998         /*----------------------------------------------------------------------*/
1999         /* CHTML 1.0                                                            */
2000         /*----------------------------------------------------------------------*/
2001         chtml10->out = apr_pstrcat(r->pool,
2002                           chtml10->out, 
2003                           " width=\"", value, "\" ", NULL);
2004       }
2005       break;
2006
2007     case 'n':
2008     case 'N':
2009       if (strcasecmp(name, "noshade") == 0) {
2010         /*----------------------------------------------------------------------*/
2011         /* CHTML 1.0                                                            */
2012         /*----------------------------------------------------------------------*/
2013         chtml10->out = apr_pstrcat(r->pool,
2014                           chtml10->out, 
2015                           " noshade ", NULL);
2016       }
2017       break;
2018
2019     case 'c':
2020     case 'C':
2021       if (strcasecmp(name, "color") == 0) {
2022         /*----------------------------------------------------------------------*/
2023         /* CHTML 4.0                                                            */
2024         /*----------------------------------------------------------------------*/
2025         /* ignore */
2026       }
2027       break;
2028
2029     default:
2030       break;
2031     }
2032   }
2033
2034   chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >", NULL);
2035
2036   return chtml10->out;
2037 }
2038
2039
2040 /**
2041  * It is a handler who processes the HR tag.
2042  *
2043  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2044  *                     destination is specified.
2045  * @param node   [i]   The HR tag node is specified.
2046  * @return The conversion result is returned.
2047  */
2048 static char*
2049 s_chtml10_end_hr_tag(void* pdoc, Node* child) 
2050 {
2051   chtml10_t* chtml10;
2052
2053   chtml10 = GET_CHTML10(pdoc);
2054
2055   return chtml10->out;
2056 }
2057
2058
2059 /**
2060  * It is a handler who processes the IMG tag.
2061  *
2062  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2063  *                     destination is specified.
2064  * @param node   [i]   The IMG tag node is specified.
2065  * @return The conversion result is returned.
2066  */
2067 static char*
2068 s_chtml10_start_img_tag(void* pdoc, Node* node) 
2069 {
2070   chtml10_t*   chtml10;
2071   Doc*         doc;
2072   request_rec* r;
2073   Attr*        attr;
2074 #ifndef IMG_NOT_CONVERT_FILENAME
2075   device_table_t* spec;
2076 #endif
2077
2078   chtml10 = GET_CHTML10(pdoc);
2079 #ifndef IMG_NOT_CONVERT_FILENAME
2080   spec    = chtml10->spec;
2081 #endif
2082   doc     = chtml10->doc;
2083   r       = doc->r;
2084
2085   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<img", NULL);
2086  
2087
2088   /*--------------------------------------------------------------------------*/
2089   /* Get Attributes                                                           */
2090   /*--------------------------------------------------------------------------*/
2091   for (attr = qs_get_attr(doc,node);
2092        attr;
2093        attr = qs_get_next_attr(doc,attr)) {
2094     char* name;
2095     char* value;
2096
2097     name  = qs_get_attr_name (doc,attr);
2098     value = qs_get_attr_value(doc,attr);
2099
2100     switch(*name) {
2101     case 's':
2102     case 'S':
2103       if (strcasecmp(name, "src") == 0) {
2104         /*----------------------------------------------------------------------*/
2105         /* CHTML 1.0                                                            */
2106         /*----------------------------------------------------------------------*/
2107 #ifdef IMG_NOT_CONVERT_FILENAME
2108         value = chxj_add_cookie_parameter(r, value, chtml10->cookie_id);
2109         chtml10->out = apr_pstrcat(r->pool, 
2110                         chtml10->out, " src=\"",value,"\"", NULL);
2111 #else
2112         value = chxj_img_conv(r, spec, value);
2113         value = chxj_add_cookie_parameter(r, value, chtml10->cookie_id);
2114         chtml10->out = apr_pstrcat(r->pool, 
2115                         chtml10->out, " src=\"", 
2116                         value, 
2117                         NULL);
2118         chtml10->out = apr_pstrcat(r->pool, chtml10->out, "\"", NULL);
2119 #endif
2120       }
2121       break;
2122
2123     case 'a':
2124     case 'A':
2125       if (strcasecmp(name, "align" ) == 0) {
2126         /*--------------------------------------------------------------------*/
2127         /* CHTML 1.0                                                          */
2128         /*--------------------------------------------------------------------*/
2129         /*--------------------------------------------------------------------*/
2130         /* CHTML 4.0                                                          */
2131         /*--------------------------------------------------------------------*/
2132         chtml10->out = apr_pstrcat(r->pool, 
2133                         chtml10->out, " align=\"",value,"\"", NULL);
2134       }
2135       else
2136       if (strcasecmp(name, "alt"   ) == 0) {
2137         /*--------------------------------------------------------------------*/
2138         /* CHTML 1.0                                                          */
2139         /*--------------------------------------------------------------------*/
2140         chtml10->out = apr_pstrcat(r->pool, 
2141                         chtml10->out, " alt=\"",value,"\"", NULL);
2142       }
2143       break;
2144
2145     case 'w':
2146     case 'W':
2147       if (strcasecmp(name, "width" ) == 0) {
2148         /*----------------------------------------------------------------------*/
2149         /* CHTML 1.0                                                            */
2150         /*----------------------------------------------------------------------*/
2151         chtml10->out = apr_pstrcat(r->pool, 
2152                         chtml10->out, " width=\"",value,"\"", NULL);
2153       }
2154       break;
2155
2156     case 'h':
2157     case 'H':
2158       if (strcasecmp(name, "height") == 0) {
2159         /*--------------------------------------------------------------------*/
2160         /* CHTML 1.0                                                          */
2161         /*--------------------------------------------------------------------*/
2162         chtml10->out = apr_pstrcat(r->pool, 
2163                         chtml10->out, " height=\"",value,"\"", NULL);
2164       }
2165       else
2166       if (strcasecmp(name, "hspace") == 0) {
2167         /*--------------------------------------------------------------------*/
2168         /* CHTML 1.0                                                          */
2169         /*--------------------------------------------------------------------*/
2170         chtml10->out = apr_pstrcat(r->pool, 
2171                         chtml10->out, " hspace=\"",value,"\"", NULL);
2172       }
2173       break;
2174
2175     case 'v':
2176     case 'V':
2177       if (strcasecmp(name, "vspace") == 0) {
2178         /*----------------------------------------------------------------------*/
2179         /* CHTML 1.0                                                            */
2180         /*----------------------------------------------------------------------*/
2181         chtml10->out = apr_pstrcat(r->pool, 
2182                         chtml10->out, " vspace=\"",value,"\"", NULL);
2183       }
2184       break;
2185
2186     default:
2187       break;
2188     }
2189   }
2190
2191   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2192
2193   return chtml10->out;
2194 }
2195
2196
2197 /**
2198  * It is a handler who processes the IMG tag.
2199  *
2200  * @param chtml10  [i/o] The pointer to the CHTML structure at the output
2201  *                     destination is specified.
2202  * @param node   [i]   The IMG tag node is specified.
2203  * @return The conversion result is returned.
2204  */
2205 static char*
2206 s_chtml10_end_img_tag(void* pdoc, Node* child) 
2207 {
2208   chtml10_t* chtml10;
2209
2210   chtml10 = GET_CHTML10(pdoc);
2211
2212   return chtml10->out;
2213 }
2214
2215
2216 /**
2217  * It is a handler who processes the SELECT tag.
2218  *
2219  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2220  *                     destination is specified.
2221  * @param node   [i]   The SELECT tag node is specified.
2222  * @return The conversion result is returned.
2223  */
2224 static char*
2225 s_chtml10_start_select_tag(void* pdoc, Node* child)
2226 {
2227   chtml10_t*   chtml10;
2228   Doc*         doc;
2229   request_rec* r;
2230   Attr*        attr;
2231
2232   char*        size;
2233   char*        name;
2234
2235   chtml10 = GET_CHTML10(pdoc);
2236   doc     = chtml10->doc;
2237   r       = doc->r;
2238
2239   size    = NULL;
2240   name    = NULL;
2241
2242   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<select", NULL);
2243   for (attr = qs_get_attr(doc,child);
2244        attr;
2245        attr = qs_get_next_attr(doc,attr)) {
2246     char* nm;
2247     char* val;
2248
2249     nm  = qs_get_attr_name (doc,attr);
2250     val = qs_get_attr_value(doc,attr);
2251
2252     if ((*nm == 's' || *nm == 'S') && strcasecmp(nm, "size") == 0) {
2253       /*----------------------------------------------------------------------*/
2254       /* CHTML 1.0 version 2.0                                                */
2255       /*----------------------------------------------------------------------*/
2256       size = apr_pstrdup(r->pool, val);
2257     }
2258     else
2259     if ((*nm == 'n' || *nm == 'N') && strcasecmp(nm, "name") == 0) {
2260       /*----------------------------------------------------------------------*/
2261       /* CHTML 1.0 version 2.0                                                */
2262       /*----------------------------------------------------------------------*/
2263       name = apr_pstrdup(r->pool, val);
2264     }
2265     else
2266     if ((*nm == 'm' || *nm == 'M') && strcasecmp(nm, "multiple") == 0) {
2267       /*----------------------------------------------------------------------*/
2268       /* CHTML 1.0 version 2.0                                                */
2269       /*----------------------------------------------------------------------*/
2270       /* Ignore */
2271     }
2272   }
2273
2274   if (size)
2275     chtml10->out = apr_pstrcat(r->pool, 
2276                                chtml10->out, 
2277                                " size=\"",
2278                                size,
2279                                "\"", 
2280                                NULL);
2281
2282   if (name) 
2283     chtml10->out = apr_pstrcat(r->pool, 
2284                                chtml10->out, 
2285                                " name=\"",
2286                                name,
2287                                "\"", 
2288                                NULL);
2289
2290   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\n", NULL);
2291
2292   return chtml10->out;
2293 }
2294
2295
2296 /**
2297  * It is a handler who processes the SELECT tag.
2298  *
2299  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2300  *                     destination is specified.
2301  * @param node   [i]   The SELECT tag node is specified.
2302  * @return The conversion result is returned.
2303  */
2304 static char*
2305 s_chtml10_end_select_tag(void* pdoc, Node* child)
2306 {
2307   chtml10_t*   chtml10;
2308   Doc*         doc;
2309   request_rec* r;
2310
2311   chtml10 = GET_CHTML10(pdoc);
2312   doc     = chtml10->doc;
2313   r       = doc->r;
2314
2315   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</select>\n", NULL);
2316
2317   return chtml10->out;
2318 }
2319
2320
2321 /**
2322  * It is a handler who processes the OPTION 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 OPTION tag node is specified.
2327  * @return The conversion result is returned.
2328  */
2329 static char*
2330 s_chtml10_start_option_tag(void* pdoc, Node* child)
2331 {
2332   chtml10_t*   chtml10;
2333   Doc*         doc;
2334   request_rec* r;
2335   Attr*        attr;
2336
2337   char*        selected;
2338   char*        value;
2339
2340   chtml10   = GET_CHTML10(pdoc);
2341   doc       = chtml10->doc;
2342   r         = doc->r;
2343
2344   selected  = NULL;
2345   value     = NULL;
2346
2347   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<option", NULL);
2348   for (attr = qs_get_attr(doc,child);
2349        attr;
2350        attr = qs_get_next_attr(doc,attr)) {
2351     char* nm;
2352     char* val;
2353
2354     nm  = qs_get_attr_name (doc,attr);
2355     val = qs_get_attr_value(doc,attr);
2356
2357     if ((*nm == 's' || *nm == 'S') && strcasecmp(nm, "selected") == 0) {
2358       /*----------------------------------------------------------------------*/
2359       /* CHTML 1.0 version 2.0                                                */
2360       /*----------------------------------------------------------------------*/
2361       selected = apr_pstrdup(r->pool, val);
2362     }
2363     else
2364     if ((*nm == 'v' || *nm == 'V') && strcasecmp(nm, "value") == 0) {
2365       /*----------------------------------------------------------------------*/
2366       /* CHTML 1.0 version 2.0                                                */
2367       /*----------------------------------------------------------------------*/
2368       value = apr_pstrdup(r->pool, val);
2369     }
2370   }
2371
2372   if (value)
2373     chtml10->out = apr_pstrcat(r->pool, 
2374                                chtml10->out, 
2375                                " value=\"",
2376                                value,
2377                                "\"", 
2378                                NULL);
2379   else
2380     chtml10->out = apr_pstrcat(r->pool, 
2381                                chtml10->out, 
2382                                " value=\"\"", 
2383                                NULL);
2384
2385   if (selected)
2386     chtml10->out = apr_pstrcat(r->pool, 
2387                                chtml10->out, 
2388                                " selected ", 
2389                                NULL);
2390
2391   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2392
2393   return chtml10->out;
2394 }
2395
2396
2397 /**
2398  * It is a handler who processes the OPTION tag.
2399  *
2400  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2401  *                     destination is specified.
2402  * @param node   [i]   The OPTION tag node is specified.
2403  * @return The conversion result is returned.
2404  */
2405 static char*
2406 s_chtml10_end_option_tag(void* pdoc, Node* child)
2407 {
2408   chtml10_t* chtml10;
2409  
2410   chtml10 = GET_CHTML10(pdoc);
2411
2412   /* Don't close */
2413
2414   return chtml10->out;
2415 }
2416
2417
2418 /**
2419  * It is a handler who processes the DIV tag.
2420  *
2421  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2422  *                     destination is specified.
2423  * @param node   [i]   The DIV tag node is specified.
2424  * @return The conversion result is returned.
2425  */
2426 static char*
2427 s_chtml10_start_div_tag(void* pdoc, Node* child)
2428 {
2429   chtml10_t*   chtml10;
2430   Doc*         doc;
2431   request_rec* r;
2432   Attr*        attr;
2433
2434   char*        align;
2435
2436   chtml10 = GET_CHTML10(pdoc);
2437   doc     = chtml10->doc;
2438   r       = doc->r;
2439
2440   align   = NULL;
2441
2442   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<div", NULL);
2443   for (attr = qs_get_attr(doc,child);
2444        attr;
2445        attr = qs_get_next_attr(doc,attr)) {
2446     char* nm;
2447     char* val;
2448
2449     nm  = qs_get_attr_name(doc,attr);
2450     val = qs_get_attr_value(doc,attr);
2451
2452     if ((*nm == 'a' || *nm == 'A') && strcasecmp(nm, "align") == 0) {
2453       /*----------------------------------------------------------------------*/
2454       /* CHTML 1.0 (W3C version 3.2)                                          */
2455       /*----------------------------------------------------------------------*/
2456       align = apr_pstrdup(r->pool, val);
2457     }
2458   }
2459
2460   if (align)
2461     chtml10->out = apr_pstrcat(r->pool, 
2462                     chtml10->out, " align=\"", align, "\"", NULL);
2463
2464   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
2465
2466   return chtml10->out;
2467 }
2468
2469
2470 /**
2471  * It is a handler who processes the DIV tag.
2472  *
2473  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2474  *                     destination is specified.
2475  * @param node   [i]   The DIV tag node is specified.
2476  * @return The conversion result is returned.
2477  */
2478 static char*
2479 s_chtml10_end_div_tag(void* pdoc, Node* child)
2480 {
2481   chtml10_t*   chtml10;
2482   Doc*         doc;
2483   request_rec* r;
2484
2485   chtml10 = GET_CHTML10(pdoc);
2486   doc     = chtml10->doc;
2487   r       = doc->r;
2488
2489   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</div>\n", NULL);
2490
2491   return chtml10->out;
2492 }
2493
2494
2495 /**
2496  * It is a handler who processes the CHXJ:IF tag.
2497  *
2498  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2499  *                     destination is specified.
2500  * @param node   [i]   The CHXJ:IF tag node is specified.
2501  * @return The conversion result is returned.
2502  */
2503 static char* 
2504 s_chtml10_chxjif_tag(void* pdoc, Node* node)
2505 {
2506   chtml10_t*   chtml10;
2507   Doc*         doc;
2508   Node*        child;
2509   request_rec* r;
2510
2511   chtml10 = GET_CHTML10(pdoc);
2512   doc     = chtml10->doc;
2513   r       = doc->r;
2514
2515   for (child = qs_get_child_node(doc, node);
2516        child;
2517        child = qs_get_next_node(doc, child)) {
2518     chtml10->out = apr_pstrcat(r->pool, chtml10->out, child->otext, NULL);
2519     s_chtml10_chxjif_tag(chtml10, child);
2520   }
2521
2522   return chtml10->out;
2523 }
2524
2525
2526 /**
2527  * It is a handler who processes the PRE tag.
2528  *
2529  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2530  *                     destination is specified.
2531  * @param node   [i]   The PRE tag node is specified.
2532  * @return The conversion result is returned.
2533  */
2534 static char*
2535 s_chtml10_start_pre_tag(void* pdoc, Node* node) 
2536 {
2537   Doc*          doc;
2538   request_rec*  r;
2539   chtml10_t*    chtml10;
2540
2541   chtml10 = GET_CHTML10(pdoc);
2542   doc     = chtml10->doc;
2543   r       = doc->r;
2544
2545   chtml10->pre_flag++;
2546   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<pre>", NULL);
2547
2548   return chtml10->out;
2549 }
2550
2551
2552 /**
2553  * It is a handler who processes the PRE tag.
2554  *
2555  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2556  *                     destination is specified.
2557  * @param node   [i]   The PRE tag node is specified.
2558  * @return The conversion result is returned.
2559  */
2560 static char*
2561 s_chtml10_end_pre_tag(void* pdoc, Node* child) 
2562 {
2563   chtml10_t*    chtml10;
2564   Doc*          doc;
2565   request_rec*  r;
2566
2567   chtml10 = GET_CHTML10(pdoc);
2568   doc     = chtml10->doc;
2569   r       = doc->r;
2570
2571   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</pre>", NULL);
2572   chtml10->pre_flag--;
2573
2574   return chtml10->out;
2575 }
2576
2577
2578 /**
2579  * It is a handler who processes the P tag.
2580  *
2581  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2582  *                     destination is specified.
2583  * @param node   [i]   The P tag node is specified.
2584  * @return The conversion result is returned.
2585  */
2586 static char*
2587 s_chtml10_start_p_tag(void* pdoc, Node* node) 
2588 {
2589   Doc*          doc;
2590   request_rec*  r;
2591   chtml10_t*    chtml10;
2592
2593   chtml10 = GET_CHTML10(pdoc);
2594   doc     = chtml10->doc;
2595   r       = doc->r;
2596
2597   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<p>", NULL);
2598
2599   return chtml10->out;
2600 }
2601
2602
2603 /**
2604  * It is a handler who processes the P tag.
2605  *
2606  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2607  *                     destination is specified.
2608  * @param node   [i]   The P tag node is specified.
2609  * @return The conversion result is returned.
2610  */
2611 static char*
2612 s_chtml10_end_p_tag(void* pdoc, Node* child) 
2613 {
2614   Doc*          doc;
2615   request_rec*  r;
2616   chtml10_t*    chtml10;
2617
2618   chtml10 = GET_CHTML10(pdoc);
2619   doc     = chtml10->doc;
2620   r       = doc->r;
2621
2622   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</p>", NULL);
2623
2624   return chtml10->out;
2625 }
2626
2627
2628 /**
2629  * It is a handler who processes the TEXTARE tag.
2630  *
2631  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2632  *                     destination is specified.
2633  * @param node   [i]   The TEXTAREA tag node is specified.
2634  * @return The conversion result is returned.
2635  */
2636 static char*
2637 s_chtml10_start_textarea_tag(void* pdoc, Node* node) 
2638 {
2639   Doc*          doc;
2640   request_rec*  r;
2641   chtml10_t*    chtml10;
2642   Attr*         attr;
2643
2644   chtml10 = GET_CHTML10(pdoc);
2645   doc     = chtml10->doc;
2646   r       = doc->r;
2647
2648
2649   chtml10->textarea_flag++;
2650   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<textarea ", NULL);
2651
2652   for (attr = qs_get_attr(doc,node);
2653        attr;
2654        attr = qs_get_next_attr(doc,attr)) {
2655
2656     char* name;
2657     char* value;
2658
2659     name  = qs_get_attr_name (doc,attr);
2660     value = qs_get_attr_value(doc,attr);
2661
2662     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
2663       chtml10->out = apr_pstrcat(r->pool, 
2664                                  chtml10->out, 
2665                                  " name=\"",
2666                                  value,
2667                                  "\"", 
2668                                  NULL);
2669     }
2670     else 
2671     if ((*name == 'r' || *name == 'R') && strcasecmp(name, "rows") == 0) {
2672       chtml10->out = apr_pstrcat(r->pool, 
2673                                  chtml10->out, 
2674                                  " rows=\"",
2675                                    value,
2676                                    "\"",
2677                                    NULL);
2678     }
2679     else 
2680     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cols") == 0) {
2681       chtml10->out = apr_pstrcat(r->pool, 
2682                                  chtml10->out, 
2683                                  " cols=\"",
2684                                  value,
2685                                  "\"", 
2686                                  NULL);
2687     }
2688   }
2689
2690   chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\r\n", NULL);
2691
2692   return chtml10->out;
2693 }
2694
2695
2696 /**
2697  * It is a handler who processes the TEXTAREA tag.
2698  *
2699  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2700  *                     destination is specified.
2701  * @param node   [i]   The TEXTAREA tag node is specified.
2702  * @return The conversion result is returned.
2703  */
2704 static char*
2705 s_chtml10_end_textarea_tag(void* pdoc, Node* child) 
2706 {
2707   Doc*          doc;
2708   request_rec*  r;
2709   chtml10_t*    chtml10;
2710
2711   chtml10 = GET_CHTML10(pdoc);
2712   doc     = chtml10->doc;
2713   r       = doc->r;
2714
2715   chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</textarea>\r\n", NULL);
2716   chtml10->textarea_flag--;
2717
2718   return chtml10->out;
2719 }
2720
2721
2722 static char*
2723 s_chtml10_text(void* pdoc, Node* child)
2724 {
2725   char*        textval;
2726   char*        tmp;
2727   char*        tdst;
2728   char         one_byte[2];
2729   int          ii;
2730   int          tdst_len;
2731   chtml10_t*   chtml10;
2732   Doc*         doc;
2733   request_rec* r;
2734
2735   chtml10 = GET_CHTML10(pdoc);
2736   doc     = chtml10->doc;
2737   r       = doc->r;
2738   
2739   textval = qs_get_node_value(doc,child);
2740   textval = qs_trim_string(r, textval);
2741
2742   if (strlen(textval) == 0)
2743     return chtml10->out;
2744   
2745   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2746   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2747   
2748   tdst     = qs_alloc_zero_byte_string(r);
2749   memset(one_byte, 0, sizeof(one_byte));
2750   tdst_len = 0;
2751   
2752   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2753     char* out;
2754     int   rtn;
2755
2756     rtn = s_chtml10_search_emoji(chtml10, &textval[ii], &out);
2757     if (rtn) {
2758       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2759       ii+=(rtn - 1);
2760       continue;
2761     }
2762   
2763     if (is_sjis_kanji(textval[ii])) {
2764       one_byte[0] = textval[ii+0];
2765       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2766       one_byte[0] = textval[ii+1];
2767       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2768       ii++;
2769     }
2770     else 
2771     if (chtml10->pre_flag) {
2772       one_byte[0] = textval[ii+0];
2773       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2774     }
2775     else 
2776     if (chtml10->textarea_flag) {
2777       one_byte[0] = textval[ii+0];
2778       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2779     }
2780     else 
2781     if (textval[ii] != '\r' && textval[ii] != '\n') {
2782       one_byte[0] = textval[ii+0];
2783       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2784     }
2785   }
2786
2787   chtml10->out = apr_pstrcat(r->pool, chtml10->out, tdst, NULL);
2788
2789   return chtml10->out;
2790 }
2791 /*
2792  * vim:ts=2 et
2793  */