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     char *name  = qs_get_attr_name(doc,attr);
1229     char *value = qs_get_attr_value(doc,attr);
1230     if (STRCASEEQ('c','C',"color",name)) {
1231       W_L(" color=\"");
1232       W_V(value);
1233       W_L("\"");
1234     }
1235     else if (STRCASEEQ('s','S',"size",name)) {
1236       /*----------------------------------------------------------------------*/
1237       /* CHTML 5.0                                                            */
1238       /*----------------------------------------------------------------------*/
1239       /* ignore */
1240     }
1241   }
1242   W_L(">");
1243   return jhtml->out;
1244 }
1245
1246
1247 /**
1248  * It is a handler who processes the FONT tag.
1249  *
1250  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1251  *                     destination is specified.
1252  * @param node   [i]   The FONT tag node is specified.
1253  * @return The conversion result is returned.
1254  */
1255 static char *
1256 s_jhtml_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1257 {
1258   jhtml_t      *jhtml;
1259   request_rec  *r;
1260   Doc          *doc;
1261
1262   jhtml = GET_JHTML(pdoc);
1263   doc   = jhtml->doc;
1264   r     = jhtml->doc->r;
1265
1266   W_L("</font>");
1267   return jhtml->out;
1268 }
1269
1270
1271 /**
1272  * It is a handler who processes the FORM tag.
1273  *
1274  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1275  *                     destination is specified.
1276  * @param node   [i]   The FORM tag node is specified.
1277  * @return The conversion result is returned.
1278  */
1279 static char *
1280 s_jhtml_start_form_tag(void *pdoc, Node *node) 
1281 {
1282   jhtml_t      *jhtml;
1283   Doc          *doc;
1284   request_rec  *r;
1285   Attr         *attr;
1286
1287   jhtml = GET_JHTML(pdoc);
1288   doc   = jhtml->doc;
1289   r     = doc->r;
1290   W_L("<form");
1291   /*--------------------------------------------------------------------------*/
1292   /* Get Attributes                                                           */
1293   /*--------------------------------------------------------------------------*/
1294   for (attr = qs_get_attr(doc,node);
1295        attr;
1296        attr = qs_get_next_attr(doc,attr)) {
1297     char *name  = qs_get_attr_name(doc,attr);
1298     char *value = qs_get_attr_value(doc,attr);
1299     if (STRCASEEQ('a','A',"action",name)) {
1300       /*----------------------------------------------------------------------*/
1301       /* CHTML 1.0                                                            */
1302       /*----------------------------------------------------------------------*/
1303       W_L(" action=\"");
1304       W_V(value);
1305       W_L("\"");
1306     }
1307     else if (STRCASEEQ('m','M',"method",name)) {
1308       /*----------------------------------------------------------------------*/
1309       /* CHTML 1.0                                                            */
1310       /*----------------------------------------------------------------------*/
1311       W_L(" method=\"");
1312       W_V(value);
1313       W_L("\"");
1314     }
1315     else if (STRCASEEQ('u','U',"utn",name)) {
1316       /*----------------------------------------------------------------------*/
1317       /* CHTML 3.0                                                            */
1318       /* It is special only for CHTML.                                        */
1319       /*----------------------------------------------------------------------*/
1320       W_L(" utn ");
1321     }
1322   }
1323   W_L(">");
1324   if (jhtml->cookie && jhtml->cookie->cookie_id) {
1325     char *vv = apr_psprintf(doc->buf.pool, "%s<input type='hidden' name='%s' value='%s'>",
1326                             jhtml->out, 
1327                             CHXJ_COOKIE_PARAM,
1328                             chxj_url_decode(r, jhtml->cookie->cookie_id));
1329     W_V(vv);
1330   }
1331   return jhtml->out;
1332 }
1333
1334
1335 /**
1336  * It is a handler who processes the FORM tag.
1337  *
1338  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1339  *                     destination is specified.
1340  * @param node   [i]   The FORM tag node is specified.
1341  * @return The conversion result is returned.
1342  */
1343 static char *
1344 s_jhtml_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1345 {
1346   jhtml_t *jhtml = GET_JHTML(pdoc);
1347   Doc     *doc   = jhtml->doc;
1348   W_L("</form>");
1349   return jhtml->out;
1350 }
1351
1352
1353 /**
1354  * It is a handler who processes the INPUT tag.
1355  *
1356  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1357  *                     destination is specified.
1358  * @param node   [i]   The INPUT tag node is specified.
1359  * @return The conversion result is returned.
1360  */
1361 static char *
1362 s_jhtml_start_input_tag(void *pdoc, Node *node) 
1363 {
1364   jhtml_t       *jhtml;
1365   Doc           *doc;
1366   request_rec   *r;
1367   char          *max_length;
1368   char          *type;
1369   char          *name;
1370   char          *value;
1371   char          *istyle;
1372   char          *size;
1373   char          *checked;
1374   char          *accesskey;
1375
1376   jhtml       = GET_JHTML(pdoc);
1377   doc         = jhtml->doc;
1378   r           = doc->r;
1379   max_length  = NULL;
1380   type        = NULL;
1381   name        = NULL;
1382   value       = NULL;
1383   istyle      = NULL;
1384   size        = NULL;
1385   checked     = NULL;
1386   accesskey   = NULL;
1387
1388   W_L("<input");
1389   /*--------------------------------------------------------------------------*/
1390   /* Get Attributes                                                           */
1391   /*--------------------------------------------------------------------------*/
1392   type       = qs_get_type_attr(doc, node, r);
1393   name       = qs_get_name_attr(doc, node, r);
1394   value      = qs_get_value_attr(doc,node,r);
1395   istyle     = qs_get_istyle_attr(doc,node,r);
1396   max_length = qs_get_maxlength_attr(doc,node,r);
1397   checked    = qs_get_checked_attr(doc,node,r);
1398   accesskey  = qs_get_accesskey_attr(doc, node, r);
1399   size       = qs_get_size_attr(doc, node, r);
1400
1401   if (type) {
1402     W_L(" type=\"");
1403     W_V(type);
1404     W_L("\" ");
1405   }
1406   if (size) {
1407     W_L(" size=\"");
1408     W_V(size);
1409     W_L("\" ");
1410   }
1411   if (name) {
1412     W_L(" name=\"");
1413     W_V(name);
1414     W_L("\" ");
1415   }
1416   if (value) {
1417     W_L(" value=\"");
1418     W_V(value);
1419     W_L("\" ");
1420   }
1421   if (accesskey) {
1422     W_L(" accesskey=\"");
1423     W_V(accesskey);
1424     W_L("\" ");
1425   }
1426   if (istyle) {
1427     /*------------------------------------------------------------------------*/
1428     /* CHTML 2.0                                                              */
1429     /*------------------------------------------------------------------------*/
1430     if (STRCASEEQ('p','P',"password", type) && ! jhtml->entryp->pc_flag ) {
1431       W_L(" mode=\"");
1432       W_L("numeric");
1433       W_L("\" ");
1434     }
1435     else {
1436       char *vv = chxj_istyle_to_mode(r,istyle);
1437       W_L(" mode=\"");
1438       W_V(vv);
1439       W_L("\" ");
1440     }
1441   }
1442   else if (istyle == NULL && type != NULL && STRCASEEQ('p','P',"password",type)) {
1443     W_L(" mode=\"");
1444     W_L("numeric");
1445     W_L("\" ");
1446   }
1447   /*--------------------------------------------------------------------------*/
1448   /* The figure is default for the password.                                  */
1449   /*--------------------------------------------------------------------------*/
1450   if (max_length) {
1451     W_L(" maxlength=\"");
1452     W_V(max_length);
1453     W_L("\"");
1454   }
1455
1456   if (checked) {
1457     W_L(" checked ");
1458   }
1459   W_L(" >");
1460   return jhtml->out;
1461 }
1462
1463
1464 /**
1465  * It is a handler who processes the INPUT tag.
1466  *
1467  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1468  *                     destination is specified.
1469  * @param node   [i]   The INPUT tag node is specified.
1470  * @return The conversion result is returned.
1471  */
1472 static char *
1473 s_jhtml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1474 {
1475   jhtml_t *jhtml = GET_JHTML(pdoc);
1476   return jhtml->out;
1477 }
1478
1479
1480 /**
1481  * It is a handler who processes the CENTER tag.
1482  *
1483  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1484  *                     destination is specified.
1485  * @param node   [i]   The CENTER tag node is specified.
1486  * @return The conversion result is returned.
1487  */
1488 static char *
1489 s_jhtml_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1490 {
1491   jhtml_t *jhtml = GET_JHTML(pdoc);
1492   Doc     *doc   = jhtml->doc;
1493   W_L("<center>");
1494   return jhtml->out;
1495 }
1496
1497
1498 /**
1499  * It is a handler who processes the CENTER tag.
1500  *
1501  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1502  *                     destination is specified.
1503  * @param node   [i]   The CENTER tag node is specified.
1504  * @return The conversion result is returned.
1505  */
1506 static char *
1507 s_jhtml_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1508 {
1509   jhtml_t     *jhtml;
1510   Doc         *doc;
1511   request_rec *r;
1512
1513   jhtml = GET_JHTML(pdoc);
1514   doc   = jhtml->doc;
1515   r     = doc->r;
1516
1517   W_L("</center>");
1518   return jhtml->out;
1519 }
1520
1521
1522 /**
1523  * It is a handler who processes the li tag.
1524  *
1525  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1526  *                     destination is specified.
1527  * @param node   [i]   The li tag node is specified.
1528  * @return The conversion result is returned.
1529  */
1530 static char *
1531 s_jhtml_start_li_tag(void *pdoc, Node *UNUSED(node)) 
1532 {
1533   jhtml_t       *jhtml;
1534   Doc           *doc;
1535   request_rec   *r;
1536
1537   jhtml = GET_JHTML(pdoc);
1538   doc   = jhtml->doc;
1539   r     = doc->r;
1540
1541   W_L("<li>");
1542   return jhtml->out;
1543 }
1544
1545
1546 /**
1547  * It is a handler who processes the li tag.
1548  *
1549  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1550  *                     destination is specified.
1551  * @param node   [i]   The li tag node is specified.
1552  * @return The conversion result is returned.
1553  */
1554 static char *
1555 s_jhtml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
1556 {
1557   jhtml_t     *jhtml;
1558   Doc         *doc;
1559   request_rec *r;
1560
1561   jhtml = GET_JHTML(pdoc);
1562   doc   = jhtml->doc;
1563   r     = doc->r;
1564
1565   W_L("</li>");
1566   return jhtml->out;
1567 }
1568
1569
1570 /**
1571  * It is a handler who processes the OL tag.
1572  *
1573  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1574  *                     destination is specified.
1575  * @param node   [i]   The OL tag node is specified.
1576  * @return The conversion result is returned.
1577  */
1578 static char *
1579 s_jhtml_start_ol_tag(void *pdoc, Node *UNUSED(node)) 
1580 {
1581   jhtml_t     *jhtml;
1582   Doc         *doc;
1583   request_rec *r;
1584
1585   jhtml = GET_JHTML(pdoc);
1586   doc   = jhtml->doc;
1587   r     = doc->r;
1588
1589   W_L("<ol>");
1590   return jhtml->out;
1591 }
1592
1593
1594 /**
1595  * It is a handler who processes the OL tag.
1596  *
1597  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1598  *                     destination is specified.
1599  * @param node   [i]   The OL tag node is specified.
1600  * @return The conversion result is returned.
1601  */
1602 static char *
1603 s_jhtml_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
1604 {
1605   jhtml_t     *jhtml;
1606   Doc         *doc;
1607   request_rec *r;
1608
1609   jhtml = GET_JHTML(pdoc);
1610   doc   = jhtml->doc;
1611   r     = doc->r;
1612
1613   W_L("</ol>");
1614   return jhtml->out;
1615 }
1616
1617
1618 /**
1619  * It is a handler who processes the P tag.
1620  *
1621  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1622  *                     destination is specified.
1623  * @param node   [i]   The P tag node is specified.
1624  * @return The conversion result is returned.
1625  */
1626 static char *
1627 s_jhtml_start_p_tag(void *pdoc, Node *UNUSED(node)) 
1628 {
1629   jhtml_t     *jhtml;
1630   Doc         *doc;
1631   request_rec *r;
1632
1633   jhtml = GET_JHTML(pdoc);
1634   doc   = jhtml->doc;
1635   r     = doc->r;
1636
1637   W_L("<p>");
1638   return jhtml->out;
1639 }
1640
1641
1642 /**
1643  * It is a handler who processes the P tag.
1644  *
1645  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1646  *                     destination is specified.
1647  * @param node   [i]   The P tag node is specified.
1648  * @return The conversion result is returned.
1649  */
1650 static char *
1651 s_jhtml_end_p_tag(void *pdoc, Node *UNUSED(child)) 
1652 {
1653   jhtml_t   *jhtml = GET_JHTML(pdoc);
1654   Doc       *doc   = jhtml->doc;
1655
1656   W_L("</p>");
1657   return jhtml->out;
1658 }
1659
1660
1661 /**
1662  * It is a handler who processes the PRE 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 PRE tag node is specified.
1667  * @return The conversion result is returned.
1668  */
1669 static char *
1670 s_jhtml_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
1671 {
1672   jhtml_t  *jhtml = GET_JHTML(pdoc);
1673   Doc      *doc   = jhtml->doc;
1674
1675   jhtml->pre_flag++;
1676   W_L("<pre>");
1677   return jhtml->out;
1678 }
1679
1680
1681 /**
1682  * It is a handler who processes the PRE tag.
1683  *
1684  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1685  *                     destination is specified.
1686  * @param node   [i]   The PRE tag node is specified.
1687  * @return The conversion result is returned.
1688  */
1689 static char *
1690 s_jhtml_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
1691 {
1692   jhtml_t *jhtml = GET_JHTML(pdoc);
1693   Doc     *doc   = jhtml->doc;
1694
1695   W_L("</pre>");
1696   jhtml->pre_flag--;
1697
1698   return jhtml->out;
1699 }
1700
1701
1702 /**
1703  * It is a handler who processes the UL tag.
1704  *
1705  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1706  *                     destination is specified.
1707  * @param node   [i]   The UL tag node is specified.
1708  * @return The conversion result is returned.
1709  */
1710 static char *
1711 s_jhtml_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
1712 {
1713   jhtml_t *jhtml = GET_JHTML(pdoc);
1714   Doc     *doc   = jhtml->doc;
1715
1716   W_L("<ul>");
1717   return jhtml->out;
1718 }
1719
1720
1721 /**
1722  * It is a handler who processes the UL tag.
1723  *
1724  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1725  *                     destination is specified.
1726  * @param node   [i]   The UL tag node is specified.
1727  * @return The conversion result is returned.
1728  */
1729 static char *
1730 s_jhtml_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1731 {
1732   jhtml_t *jhtml = GET_JHTML(pdoc);
1733   Doc     *doc   = jhtml->doc;
1734
1735   W_L("</ul>");
1736   return jhtml->out;
1737 }
1738
1739
1740 /**
1741  * It is a handler who processes the HR tag.
1742  *
1743  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1744  *                     destination is specified.
1745  * @param node   [i]   The HR tag node is specified.
1746  * @return The conversion result is returned.
1747  */
1748 static char *
1749 s_jhtml_start_hr_tag(void *pdoc, Node *node) 
1750 {
1751   jhtml_t *jhtml = GET_JHTML(pdoc);
1752   Doc     *doc   = jhtml->doc;
1753   Attr    *attr;
1754
1755   W_L("<hr");
1756   for (attr = qs_get_attr(doc,node);
1757        attr; 
1758        attr = qs_get_next_attr(doc,attr)) {
1759     char *name = qs_get_attr_name(doc,attr);
1760     char *value = qs_get_attr_value(doc,attr);
1761     if (STRCASEEQ('a','A',"align",name)) {
1762       /*----------------------------------------------------------------------*/
1763       /* CHTML 1.0                                                            */
1764       /*----------------------------------------------------------------------*/
1765       W_L(" align=\"");
1766       W_V(value);
1767       W_L("\"");
1768     }
1769     else if (STRCASEEQ('s','S',"size",name)) {
1770       /*----------------------------------------------------------------------*/
1771       /* CHTML 1.0                                                            */
1772       /*----------------------------------------------------------------------*/
1773       W_L(" size=\"");
1774       W_V(value);
1775       W_L("\"");
1776     }
1777     else if (STRCASEEQ('w','W',"width",name)) {
1778       /*----------------------------------------------------------------------*/
1779       /* CHTML 1.0                                                            */
1780       /*----------------------------------------------------------------------*/
1781       W_L(" width=\"");
1782       W_V(value);
1783       W_L("\"");
1784     }
1785     else if (STRCASEEQ('n','N',"noshade",name)) {
1786       /*----------------------------------------------------------------------*/
1787       /* CHTML 1.0                                                            */
1788       /*----------------------------------------------------------------------*/
1789       W_L(" noshade");
1790     }
1791     else if (STRCASEEQ('c','C',"color",name)) {
1792       /*----------------------------------------------------------------------*/
1793       /* CHTML 4.0                                                            */
1794       /*----------------------------------------------------------------------*/
1795       /* ignore */
1796     }
1797   }
1798   W_L(">");
1799   return jhtml->out;
1800 }
1801
1802
1803 /**
1804  * It is a handler who processes the HR tag.
1805  *
1806  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1807  *                     destination is specified.
1808  * @param node   [i]   The HR tag node is specified.
1809  * @return The conversion result is returned.
1810  */
1811 static char *
1812 s_jhtml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1813 {
1814   jhtml_t *jhtml = GET_JHTML(pdoc);
1815   return jhtml->out;
1816 }
1817
1818
1819 /**
1820  * It is a handler who processes the IMG tag.
1821  *
1822  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1823  *                     destination is specified.
1824  * @param node   [i]   The IMG tag node is specified.
1825  * @return The conversion result is returned.
1826  */
1827 static char *
1828 s_jhtml_start_img_tag(void *pdoc, Node *node) 
1829 {
1830   jhtml_t       *jhtml = GET_JHTML(pdoc);
1831   Doc           *doc   = jhtml->doc;
1832   request_rec   *r     = doc->r;
1833   Attr          *attr;
1834 #ifndef IMG_NOT_CONVERT_FILENAME
1835   device_table  *spec = jhtml->spec;
1836 #endif
1837
1838   W_L("<img");
1839   /*--------------------------------------------------------------------------*/
1840   /* Get Attributes                                                           */
1841   /*--------------------------------------------------------------------------*/
1842   for (attr = qs_get_attr(doc,node);
1843        attr;
1844        attr = qs_get_next_attr(doc,attr)) {
1845     char *name  = qs_get_attr_name(doc,attr);
1846     char *value = qs_get_attr_value(doc,attr);
1847     if (STRCASEEQ('s','S',"src",name)) {
1848       /*----------------------------------------------------------------------*/
1849       /* CHTML 1.0                                                            */
1850       /*----------------------------------------------------------------------*/
1851 #ifdef IMG_NOT_CONVERT_FILENAME
1852       value = chxj_encoding_parameter(r, value);
1853       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1854       if (value) {
1855         value = apr_psprintf(r->pool,
1856                              "%s%c%s=true",
1857                              value,
1858                              (strchr(value, '?')) ? '&' : '?',
1859                              CHXJ_COOKIE_NOUPDATE_PARAM);
1860       }
1861       W_L(" src=\"");
1862       W_V(value);
1863       W_L("\"");
1864 #else
1865       value = chxj_img_conv(r, spec, value);
1866       value = chxj_encoding_parameter(r, value);
1867       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1868       if (value) {
1869         value = apr_psprintf(r->pool,
1870                              "%s%c%s=true",
1871                              value,
1872                              (strchr(value, '?')) ? '&' : '?',
1873                              CHXJ_COOKIE_NOUPDATE_PARAM);
1874       }
1875       W_L(" src=\"");
1876       W_V(value);
1877       W_L("\"");
1878 #endif
1879     }
1880     else if (STRCASEEQ('a','A',"align",name)) {
1881       /*----------------------------------------------------------------------*/
1882       /* CHTML 1.0                                                            */
1883       /*----------------------------------------------------------------------*/
1884       W_L(" align=\"");
1885       W_V(value);
1886       W_L("\"");
1887     }
1888     else if (STRCASEEQ('w','W',"width",name)) {
1889       /*----------------------------------------------------------------------*/
1890       /* CHTML 1.0                                                            */
1891       /*----------------------------------------------------------------------*/
1892       W_L(" width=\"");
1893       W_V(value);
1894       W_L("\"");
1895     }
1896     else if (STRCASEEQ('h','H',"height",name)) {
1897       /*----------------------------------------------------------------------*/
1898       /* CHTML 1.0                                                            */
1899       /*----------------------------------------------------------------------*/
1900       W_L(" height=\"");
1901       W_V(value);
1902       W_L("\"");
1903     }
1904     else if (STRCASEEQ('h','H',"hspace",name)) {
1905       /*----------------------------------------------------------------------*/
1906       /* CHTML 1.0                                                            */
1907       /*----------------------------------------------------------------------*/
1908       W_L(" hspace=\"");
1909       W_V(value);
1910       W_L("\"");
1911     }
1912     else if (STRCASEEQ('v','V',"vspace",name)) {
1913       /*----------------------------------------------------------------------*/
1914       /* CHTML 1.0                                                            */
1915       /*----------------------------------------------------------------------*/
1916       W_L(" vspace=\"");
1917       W_V(value);
1918       W_L("\"");
1919     }
1920     else if (STRCASEEQ('a','A',"alt",name)) {
1921       /*----------------------------------------------------------------------*/
1922       /* CHTML 1.0                                                            */
1923       /*----------------------------------------------------------------------*/
1924       W_L(" alt=\"");
1925       W_V(value);
1926       W_L("\"");
1927     }
1928     else if (STRCASEEQ('a','A',"align",name)) {
1929       /*----------------------------------------------------------------------*/
1930       /* CHTML 4.0                                                            */
1931       /*----------------------------------------------------------------------*/
1932       /* ignore */
1933     }
1934   }
1935   W_L(">");
1936   return jhtml->out;
1937 }
1938
1939
1940 /**
1941  * It is a handler who processes the IMG tag.
1942  *
1943  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1944  *                     destination is specified.
1945  * @param node   [i]   The IMG tag node is specified.
1946  * @return The conversion result is returned.
1947  */
1948 static char *
1949 s_jhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
1950 {
1951   jhtml_t *jhtml = GET_JHTML(pdoc);
1952   return jhtml->out;
1953 }
1954
1955
1956 /**
1957  * It is a handler who processes the SELECT tag.
1958  *
1959  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1960  *                     destination is specified.
1961  * @param node   [i]   The SELECT tag node is specified.
1962  * @return The conversion result is returned.
1963  */
1964 static char *
1965 s_jhtml_start_select_tag(void *pdoc, Node *child)
1966 {
1967   jhtml_t *jhtml = GET_JHTML(pdoc);
1968   Doc     *doc   = jhtml->doc;
1969   Attr    *attr;
1970
1971   char *size      = NULL;
1972   char *name      = NULL;
1973
1974   W_L("<select");
1975   for (attr = qs_get_attr(doc,child);
1976        attr;
1977        attr = qs_get_next_attr(doc,attr)) {
1978     char *nm  = qs_get_attr_name(doc,attr);
1979     char *val = qs_get_attr_value(doc,attr);
1980     if (STRCASEEQ('s','S',"size",nm)) {
1981       /*----------------------------------------------------------------------*/
1982       /* CHTML 1.0 version 2.0                                                */
1983       /*----------------------------------------------------------------------*/
1984       size = apr_pstrdup(doc->buf.pool, val);
1985     }
1986     else if (STRCASEEQ('n','N',"name",nm)) {
1987       /*----------------------------------------------------------------------*/
1988       /* CHTML 1.0 version 2.0                                                */
1989       /*----------------------------------------------------------------------*/
1990       name = apr_pstrdup(doc->buf.pool, val);
1991     }
1992     else if (STRCASEEQ('m','M',"multiple",nm)) {
1993       /*----------------------------------------------------------------------*/
1994       /* CHTML 1.0 version 2.0                                                */
1995       /*----------------------------------------------------------------------*/
1996       /* not support */
1997     }
1998   }
1999
2000   if (size) {
2001     W_L(" size=\"");
2002     W_V(size);
2003     W_L("\"");
2004   }
2005
2006   if (name) {
2007     W_L(" name=\"");
2008     W_V(name);
2009     W_L("\"");
2010   }
2011   W_L(">");
2012   return jhtml->out;
2013 }
2014
2015 /**
2016  * It is a handler who processes the SELECT tag.
2017  *
2018  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2019  *                     destination is specified.
2020  * @param node   [i]   The SELECT tag node is specified.
2021  * @return The conversion result is returned.
2022  */
2023 static char *
2024 s_jhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
2025 {
2026   jhtml_t *jhtml = GET_JHTML(pdoc);
2027   Doc     *doc   = jhtml->doc;
2028
2029   W_L("</select>");
2030   return jhtml->out;
2031 }
2032
2033 /**
2034  * It is a handler who processes the OPTION tag.
2035  *
2036  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2037  *                     destination is specified.
2038  * @param node   [i]   The OPTION tag node is specified.
2039  * @return The conversion result is returned.
2040  */
2041 static char *
2042 s_jhtml_start_option_tag(void *pdoc, Node *child)
2043 {
2044   jhtml_t *jhtml = GET_JHTML(pdoc);
2045   Doc     *doc   = jhtml->doc;
2046   Attr    *attr;
2047
2048   char *selected   = NULL;
2049   char *value      = NULL;
2050
2051   W_L("<option");
2052   for (attr = qs_get_attr(doc,child);
2053        attr;
2054        attr = qs_get_next_attr(doc,attr)) {
2055     char *nm  = qs_get_attr_name(doc,attr);
2056     char *val = qs_get_attr_value(doc,attr);
2057     if (STRCASEEQ('s','S',"selected",nm)) {
2058       /*----------------------------------------------------------------------*/
2059       /* CHTML 1.0 version 2.0                                                */
2060       /*----------------------------------------------------------------------*/
2061       selected = apr_pstrdup(doc->buf.pool, val);
2062     }
2063     else if (STRCASEEQ('v','V',"value",nm)) {
2064       /*----------------------------------------------------------------------*/
2065       /* CHTML 1.0 version 2.0                                                */
2066       /*----------------------------------------------------------------------*/
2067       value = apr_pstrdup(doc->buf.pool, val);
2068     }
2069   }
2070
2071   if (value) {
2072     W_L(" value=\"");
2073     W_V(value);
2074     W_L("\"");
2075   }
2076   else {
2077     W_L(" value=\"\"");
2078   }
2079
2080   if (selected) {
2081     W_L(" selected ");
2082   }
2083   W_L(">");
2084   return jhtml->out;
2085 }
2086
2087
2088 /**
2089  * It is a handler who processes the OPTION tag.
2090  *
2091  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2092  *                     destination is specified.
2093  * @param node   [i]   The OPTION tag node is specified.
2094  * @return The conversion result is returned.
2095  */
2096 static char *
2097 s_jhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
2098 {
2099   jhtml_t *jhtml = GET_JHTML(pdoc);
2100   /* Don't close */
2101   return jhtml->out;
2102 }
2103
2104
2105 /**
2106  * It is a handler who processes the DIV tag.
2107  *
2108  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2109  *                     destination is specified.
2110  * @param node   [i]   The DIV tag node is specified.
2111  * @return The conversion result is returned.
2112  */
2113 static char *
2114 s_jhtml_start_div_tag(void *pdoc, Node *child)
2115 {
2116   jhtml_t      *jhtml;
2117   Doc          *doc;
2118   request_rec  *r;
2119   Attr         *attr;
2120   char         *align;
2121
2122   jhtml = GET_JHTML(pdoc);
2123   doc   = jhtml->doc;
2124   r     = doc->r;
2125
2126   align = NULL;
2127
2128   W_L("<div");
2129   for (attr = qs_get_attr(doc,child);
2130        attr;
2131        attr = qs_get_next_attr(doc,attr)) {
2132     char *nm  = qs_get_attr_name(doc,attr);
2133     char *val = qs_get_attr_value(doc,attr);
2134     if (STRCASEEQ('a','A',"align",nm)) {
2135       /*----------------------------------------------------------------------*/
2136       /* CHTML 1.0 (W3C version 3.2)                                          */
2137       /*----------------------------------------------------------------------*/
2138       align = apr_pstrdup(doc->buf.pool, val);
2139     }
2140   }
2141
2142   if (align) {
2143     W_L(" align=\"");
2144     W_V(align);
2145     W_L("\"");
2146   }
2147   W_L(">");
2148   return jhtml->out;
2149 }
2150
2151
2152 /**
2153  * It is a handler who processes the DIV tag.
2154  *
2155  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2156  *                     destination is specified.
2157  * @param node   [i]   The DIV tag node is specified.
2158  * @return The conversion result is returned.
2159  */
2160 static char *
2161 s_jhtml_end_div_tag(void *pdoc, Node *UNUSED(child))
2162 {
2163   jhtml_t      *jhtml;
2164   Doc          *doc;
2165   request_rec  *r;
2166
2167   jhtml = GET_JHTML(pdoc);
2168   doc   = jhtml->doc;
2169   r     = doc->r;
2170
2171   W_L("</div>\n");
2172   return jhtml->out;
2173 }
2174
2175
2176 static char *
2177 chxj_istyle_to_mode(request_rec *r, const char *s)
2178 {
2179   char *tmp;
2180
2181   if (s) {
2182     switch (s[0]) {
2183     case '1': return apr_psprintf(r->pool, "hiragana");
2184     case '2': return apr_psprintf(r->pool, "hankakukana");
2185     case '3': return apr_psprintf(r->pool, "alphabet");
2186     case '4': return apr_psprintf(r->pool, "numeric");
2187     default: 
2188       tmp = apr_palloc(r->pool, 1);
2189       tmp[0] = '\0';
2190       return apr_pstrdup(r->pool, tmp);
2191     }
2192   }
2193
2194   tmp = apr_palloc(r->pool, 1);
2195   tmp[0] = '\0';
2196   return apr_pstrdup(r->pool,tmp);
2197 }
2198
2199
2200 static char *
2201 s_jhtml_chxjif_tag(void *pdoc, Node *node)
2202 {
2203   jhtml_t *jhtml;
2204   Doc     *doc;
2205   Node    *child;
2206   request_rec *r;
2207
2208   jhtml = GET_JHTML(pdoc);
2209   doc   = jhtml->doc;
2210   r     = doc->r;
2211
2212   for (child = qs_get_child_node(doc, node);
2213        child;
2214        child = qs_get_next_node(doc, child)) {
2215     W_V(child->otext);
2216     s_jhtml_chxjif_tag(jhtml, child);
2217   }
2218   return NULL;
2219 }
2220
2221
2222 /**
2223  * It is a handler who processes the TEXTARE tag.
2224  *
2225  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2226  *                     destination is specified.
2227  * @param node   [i]   The TEXTAREA tag node is specified.
2228  * @return The conversion result is returned.
2229  */
2230 static char*
2231 s_jhtml_start_textarea_tag(void* pdoc, Node* node) 
2232 {
2233   jhtml_t*      jhtml;
2234   Doc*          doc;
2235   request_rec*  r;
2236   Attr*         attr;
2237
2238   jhtml = GET_JHTML(pdoc);
2239   doc   = jhtml->doc;
2240   r     = doc->r;
2241
2242   jhtml->textarea_flag++;
2243   W_L("<textarea ");
2244   for (attr = qs_get_attr(doc,node);
2245        attr;
2246        attr = qs_get_next_attr(doc,attr)) {
2247
2248     char* name;
2249     char* value;
2250
2251     name  = qs_get_attr_name(doc,attr);
2252     value = qs_get_attr_value(doc,attr);
2253
2254     if (STRCASEEQ('n','N',"name",name)) {
2255       W_L(" name=\"");
2256       W_V(value);
2257       W_L("\"");
2258     }
2259     else if (STRCASEEQ('r','R',"rows",name)) {
2260       W_L(" rows=\"");
2261       W_V(value);
2262       W_L("\"");
2263     }
2264     else if (STRCASEEQ('c','C',"cols",name)) {
2265       W_L(" cols=\"");
2266       W_V(value);
2267       W_L("\"");
2268     }
2269   }
2270   W_L(">\r\n");
2271   return jhtml->out;
2272 }
2273
2274
2275 /**
2276  * It is a handler who processes the TEXTAREA tag.
2277  *
2278  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2279  *                     destination is specified.
2280  * @param node   [i]   The TEXTAREA tag node is specified.
2281  * @return The conversion result is returned.
2282  */
2283 static char*
2284 s_jhtml_end_textarea_tag(void* pdoc, Node* UNUSED(child)) 
2285 {
2286   jhtml_t*      jhtml;
2287   Doc*          doc;
2288   request_rec*  r;
2289
2290   jhtml = GET_JHTML(pdoc);
2291   doc   = jhtml->doc;
2292   r     = doc->r;
2293
2294   W_L("</textarea>\r\n");
2295   jhtml->textarea_flag--;
2296
2297   return jhtml->out;
2298 }
2299
2300
2301 /**
2302  * It is a handler who processes the B tag.
2303  *
2304  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2305  *                     destination is specified.
2306  * @param node   [i]   The B tag node is specified.
2307  * @return The conversion result is returned.
2308  */
2309 static char*
2310 s_jhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
2311 {
2312   jhtml_t*      jhtml;
2313   Doc*          doc;
2314   request_rec*  r;
2315
2316   jhtml = GET_JHTML(pdoc);
2317   doc   = jhtml->doc;
2318   r     = doc->r;
2319
2320   W_L("<b>");
2321   return jhtml->out;
2322 }
2323
2324
2325 /**
2326  * It is a handler who processes the B tag.
2327  *
2328  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2329  *                     destination is specified.
2330  * @param node   [i]   The B tag node is specified.
2331  * @return The conversion result is returned.
2332  */
2333 static char*
2334 s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
2335 {
2336   jhtml_t*      jhtml = GET_JHTML(pdoc);
2337   Doc*          doc   = jhtml->doc;
2338
2339   W_L("</b>\r\n");
2340   return jhtml->out;
2341 }
2342
2343 static char*
2344 s_jhtml_text_tag(void* pdoc, Node* child)
2345 {
2346   jhtml_t*     jhtml;
2347   Doc*         doc;
2348   char*        textval;
2349   char*        tmp;
2350   char*        tdst;
2351   char         one_byte[2];
2352   int          ii;
2353   int          tdst_len;
2354   request_rec* r;
2355
2356   jhtml = GET_JHTML(pdoc);
2357   doc   = jhtml->doc;
2358   r     = doc->r;
2359
2360   textval = qs_get_node_value(doc,child);
2361   textval = qs_trim_string(doc->buf.pool, textval);
2362   if (strlen(textval) == 0)
2363     return jhtml->out;
2364
2365   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2366   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2367
2368   tdst     = qs_alloc_zero_byte_string(r);
2369   memset(one_byte, 0, sizeof(one_byte));
2370   tdst_len = 0;
2371
2372   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2373     char* out;
2374     int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
2375     if (rtn) {
2376       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2377       ii+=(rtn - 1);
2378       continue;
2379     }
2380
2381     if (is_sjis_kanji(textval[ii])) {
2382       one_byte[0] = textval[ii+0];
2383       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2384       one_byte[0] = textval[ii+1];
2385       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2386       ii++;
2387     }
2388     else 
2389     if (jhtml->pre_flag) {
2390       one_byte[0] = textval[ii+0];
2391       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2392     }
2393     else
2394     if (jhtml->textarea_flag) {
2395       one_byte[0] = textval[ii+0];
2396       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2397     }
2398     else {
2399       if (textval[ii] != '\r' && textval[ii] != '\n') {
2400         one_byte[0] = textval[ii+0];
2401         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2402       }
2403     }
2404   }
2405   W_V(tdst);
2406   return jhtml->out;
2407 }
2408 /*
2409  * vim:ts=2 et
2410  */