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