OSDN Git Service

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