OSDN Git Service

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