OSDN Git Service

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