OSDN Git Service

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