OSDN Git Service

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