OSDN Git Service

Merge branch 'master' into branch_0.12.0
[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 #include "chxj_str_util.h"
25
26
27 #define GET_JHTML(X) ((jhtml_t *)(X))
28 #undef W_L
29 #undef W_V
30 #define W_L(X)          do { jhtml->out = BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, (X)); } while(0)
31 #define W_V(X)          do { jhtml->out = (X) ? BUFFERED_WRITE_VALUE(jhtml->out, &doc->buf, (X))  \
32                                               : BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, ""); } while(0)
33 #undef W_NLCODE
34 #define W_NLCODE()     do { char *nlcode = TO_NLCODE(jhtml->conf); W_V(nlcode); } while (0)
35
36 static char *s_jhtml_start_html_tag     (void *pdoc, Node *node);
37 static char *s_jhtml_end_html_tag       (void *pdoc, Node *node);
38 static char *s_jhtml_start_meta_tag     (void *pdoc, Node *node);
39 static char *s_jhtml_end_meta_tag       (void *pdoc, Node *node);
40 static char *s_jhtml_start_head_tag     (void *pdoc, Node *node);
41 static char *s_jhtml_end_head_tag       (void *pdoc, Node *node);
42 static char *s_jhtml_start_title_tag    (void *pdoc, Node *node);
43 static char *s_jhtml_end_title_tag      (void *pdoc, Node *node);
44 static char *s_jhtml_start_base_tag     (void *pdoc, Node *node);
45 static char *s_jhtml_end_base_tag       (void *pdoc, Node *node);
46 static char *s_jhtml_start_body_tag     (void *pdoc, Node *node);
47 static char *s_jhtml_end_body_tag       (void *pdoc, Node *node);
48 static char *s_jhtml_start_a_tag        (void *pdoc, Node *node);
49 static char *s_jhtml_end_a_tag          (void *pdoc, Node *node);
50 static char *s_jhtml_start_pre_tag      (void *pdoc, Node *node);
51 static char *s_jhtml_end_pre_tag        (void *pdoc, Node *node);
52 static char *s_jhtml_start_p_tag        (void *pdoc, Node *node);
53 static char *s_jhtml_end_p_tag          (void *pdoc, Node *node);
54 static char *s_jhtml_start_ul_tag       (void *pdoc, Node *node);
55 static char *s_jhtml_end_ul_tag         (void *pdoc, Node *node);
56 static char *s_jhtml_start_ol_tag       (void *pdoc, Node *node);
57 static char *s_jhtml_end_ol_tag         (void *pdoc, Node *node);
58 static char *s_jhtml_start_li_tag       (void *pdoc, Node *node);
59 static char *s_jhtml_end_li_tag         (void *pdoc, Node *node);
60 static char *s_jhtml_start_br_tag       (void *pdoc, Node *node);
61 static char *s_jhtml_end_br_tag         (void *pdoc, Node *node);
62 static char *s_jhtml_start_tr_tag       (void *pdoc, Node *node);
63 static char *s_jhtml_end_tr_tag         (void *pdoc, Node *node);
64 static char *s_jhtml_start_font_tag     (void *pdoc, Node *node);
65 static char *s_jhtml_end_font_tag       (void *pdoc, Node *node);
66 static char *s_jhtml_start_form_tag     (void *pdoc, Node *node);
67 static char *s_jhtml_end_form_tag       (void *pdoc, Node *node);
68 static char *s_jhtml_start_input_tag    (void *pdoc, Node *node);
69 static char *s_jhtml_end_input_tag      (void *pdoc, Node *node);
70 static char *s_jhtml_start_center_tag   (void *pdoc, Node *node);
71 static char *s_jhtml_end_center_tag     (void *pdoc, Node *node);
72 static char *s_jhtml_start_hr_tag       (void *pdoc, Node *node);
73 static char *s_jhtml_end_hr_tag         (void *pdoc, Node *node);
74 static char *s_jhtml_start_img_tag      (void *pdoc, Node *node);
75 static char *s_jhtml_end_img_tag        (void *pdoc, Node *node);
76 static char *s_jhtml_start_select_tag   (void *pdoc, Node *node);
77 static char *s_jhtml_end_select_tag     (void *pdoc, Node *node);
78 static char *s_jhtml_start_option_tag   (void *pdoc, Node *node);
79 static char *s_jhtml_end_option_tag     (void *pdoc, Node *node);
80 static char *s_jhtml_start_div_tag      (void *pdoc, Node *node);
81 static char *s_jhtml_end_div_tag        (void *pdoc, Node *node);
82 static char *s_jhtml_start_textarea_tag (void *pdoc, Node *node);
83 static char *s_jhtml_end_textarea_tag   (void *pdoc, Node *node);
84 static char *s_jhtml_start_b_tag        (void *pdoc, Node *node);
85 static char *s_jhtml_end_b_tag          (void *pdoc, Node *node);
86 static char *s_jhtml_chxjif_tag         (void *pdoc, Node *node); 
87 static char *s_jhtml_text_tag           (void *pdoc, Node *node);
88 static char *s_jhtml_start_blockquote_tag(void *pdoc, Node *node);
89 static char *s_jhtml_end_blockquote_tag  (void *pdoc, Node *node);
90 static char *s_jhtml_start_dir_tag      (void *pdoc, Node *node);
91 static char *s_jhtml_end_dir_tag        (void *pdoc, Node *node);
92 static char *s_jhtml_start_dl_tag       (void *pdoc, Node *node);
93 static char *s_jhtml_end_dl_tag         (void *pdoc, Node *node);
94 static char *s_jhtml_start_dt_tag       (void *pdoc, Node *node);
95 static char *s_jhtml_end_dt_tag         (void *pdoc, Node *node);
96 static char *s_jhtml_start_dd_tag       (void *pdoc, Node *node);
97 static char *s_jhtml_end_dd_tag         (void *pdoc, Node *node);
98 static char *s_jhtml_start_h1_tag       (void *pdoc, Node *node);
99 static char *s_jhtml_end_h1_tag         (void *pdoc, Node *node);
100 static char *s_jhtml_start_h2_tag       (void *pdoc, Node *node);
101 static char *s_jhtml_end_h2_tag         (void *pdoc, Node *node);
102 static char *s_jhtml_start_h3_tag       (void *pdoc, Node *node);
103 static char *s_jhtml_end_h3_tag         (void *pdoc, Node *node);
104 static char *s_jhtml_start_h4_tag       (void *pdoc, Node *node);
105 static char *s_jhtml_end_h4_tag         (void *pdoc, Node *node);
106 static char *s_jhtml_start_h5_tag       (void *pdoc, Node *node);
107 static char *s_jhtml_end_h5_tag         (void *pdoc, Node *node);
108 static char *s_jhtml_start_h6_tag       (void *pdoc, Node *node);
109 static char *s_jhtml_end_h6_tag         (void *pdoc, Node *node);
110 static char *s_jhtml_start_menu_tag     (void *pdoc, Node *node);
111 static char *s_jhtml_end_menu_tag       (void *pdoc, Node *node);
112 static char *s_jhtml_start_plaintext_tag       (void *pdoc, Node *node);
113 static char *s_jhtml_start_plaintext_tag_inner (void *pdoc, Node *node);
114 static char *s_jhtml_end_plaintext_tag         (void *pdoc, Node *node);
115 static char *s_jhtml_start_blink_tag  (void *pdoc, Node *node);
116 static char *s_jhtml_end_blink_tag    (void *pdoc, Node *node);
117 static char *s_jhtml_start_marquee_tag(void *pdoc, Node *node);
118 static char *s_jhtml_end_marquee_tag  (void *pdoc, Node *node);
119 static char *s_jhtml_newline_mark       (void *pdoc, Node *node);
120
121 static void  s_init_jhtml(jhtml_t *jhtml, Doc *doc, request_rec *r, device_table *spec);
122
123 static int   s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt);
124
125 static char *chxj_istyle_to_mode(apr_pool_t *p, const char *s);
126
127
128
129 tag_handler jhtml_handler[] = {
130   /* tagHTML */
131   {
132     s_jhtml_start_html_tag,
133     s_jhtml_end_html_tag,
134   },
135   /* tagMETA */
136   {
137     s_jhtml_start_meta_tag,
138     s_jhtml_end_meta_tag,
139   },
140   /* tagTEXTAREA */
141   {
142     s_jhtml_start_textarea_tag,
143     s_jhtml_end_textarea_tag,
144   },
145   /* tagP */
146   {
147     s_jhtml_start_p_tag,
148     s_jhtml_end_p_tag,
149   },
150   /* tagPRE */
151   {
152     s_jhtml_start_pre_tag,
153     s_jhtml_end_pre_tag,
154   },
155   /* tagUL */
156   {
157     s_jhtml_start_ul_tag,
158     s_jhtml_end_ul_tag,
159   },
160   /* tagLI */
161   {
162     s_jhtml_start_li_tag,
163     s_jhtml_end_li_tag,
164   },
165   /* tagOL */
166   {
167     s_jhtml_start_ol_tag,
168     s_jhtml_end_ol_tag,
169   },
170   /* tagH1 */
171   {
172     s_jhtml_start_h1_tag,
173     s_jhtml_end_h1_tag,
174   },
175   /* tagH2 */
176   {
177     s_jhtml_start_h2_tag,
178     s_jhtml_end_h2_tag,
179   },
180   /* tagH3 */
181   {
182     s_jhtml_start_h3_tag,
183     s_jhtml_end_h3_tag,
184   },
185   /* tagH4 */
186   {
187     s_jhtml_start_h4_tag,
188     s_jhtml_end_h4_tag,
189   },
190   /* tagH5 */
191   {
192     s_jhtml_start_h5_tag,
193     s_jhtml_end_h5_tag,
194   },
195   /* tagH6 */
196   {
197     s_jhtml_start_h6_tag,
198     s_jhtml_end_h6_tag,
199   },
200   /* tagHEAD */
201   {
202     s_jhtml_start_head_tag,
203     s_jhtml_end_head_tag,
204   },
205   /* tagTITLE */
206   {
207     s_jhtml_start_title_tag,
208     s_jhtml_end_title_tag,
209   },
210   /* tagBASE */
211   {
212     s_jhtml_start_base_tag,
213     s_jhtml_end_base_tag,
214   },
215   /* tagBODY */
216   {
217     s_jhtml_start_body_tag,
218     s_jhtml_end_body_tag,
219   },
220   /* tagA */
221   {
222     s_jhtml_start_a_tag,
223     s_jhtml_end_a_tag,
224   },
225   /* tagBR */
226   {
227     s_jhtml_start_br_tag,
228     s_jhtml_end_br_tag,
229   },
230   /* tagTABLE */
231   {
232     NULL,
233     NULL,
234   },
235   /* tagTR */
236   {
237     s_jhtml_start_tr_tag,
238     s_jhtml_end_tr_tag,
239   },
240   /* tagTD */
241   {
242     NULL,
243     NULL,
244   },
245   /* tagTBODY */
246   {
247     NULL,
248     NULL,
249   },
250   /* tagFONT */
251   {
252     s_jhtml_start_font_tag,
253     s_jhtml_end_font_tag,
254   },
255   /* tagFORM */
256   {
257     s_jhtml_start_form_tag,
258     s_jhtml_end_form_tag,
259   },
260   /* tagINPUT */
261   {
262     s_jhtml_start_input_tag,
263     s_jhtml_end_input_tag,
264   },
265   /* tagCENTER */
266   {
267     s_jhtml_start_center_tag,
268     s_jhtml_end_center_tag,
269   },
270   /* tagHR */
271   {
272     s_jhtml_start_hr_tag,
273     s_jhtml_end_hr_tag,
274   },
275   /* tagIMG */
276   {
277     s_jhtml_start_img_tag,
278     s_jhtml_end_img_tag,
279   },
280   /* tagSELECT */
281   {
282     s_jhtml_start_select_tag,
283     s_jhtml_end_select_tag,
284   },
285   /* tagOPTION */
286   {
287     s_jhtml_start_option_tag,
288     s_jhtml_end_option_tag,
289   },
290   /* tagDIV */
291   {
292     s_jhtml_start_div_tag,
293     s_jhtml_end_div_tag,
294   },
295   /* tagCHXJIF */
296   {
297     s_jhtml_chxjif_tag,
298     NULL,
299   },
300   /* tagNOBR */
301   {
302     NULL,
303     NULL,
304   },
305   /* tagSMALL */
306   {
307     NULL,
308     NULL,
309   },
310   /* tagSTYLE */
311   {
312     NULL,
313     NULL,
314   },
315   /* tagSPAN */
316   {
317     NULL,
318     NULL,
319   },
320   /* tagTEXT */
321   {
322     s_jhtml_text_tag,
323     NULL,
324   },
325   /* tagTH */
326   {
327     NULL,
328     NULL,
329   },
330   /* tagB */
331   {
332     s_jhtml_start_b_tag,
333     s_jhtml_end_b_tag,
334   },
335   /* tagFIELDSET */
336   {
337     NULL,
338     NULL,
339   },
340   /* tagDT */
341   {
342     s_jhtml_start_dt_tag,
343     s_jhtml_end_dt_tag,
344   },
345   /* tagLEGEND */
346   {
347     NULL,
348     NULL,
349   },
350   /* tagLABEL */
351   {
352     NULL,
353     NULL,
354   },
355   /* tagBLOCKQUOTE */
356   {
357     s_jhtml_start_blockquote_tag,
358     s_jhtml_end_blockquote_tag,
359   },
360   /* tagDIR */
361   {
362     s_jhtml_start_dir_tag,
363     s_jhtml_end_dir_tag,
364   },
365   /* tagDL */
366   {
367     s_jhtml_start_dl_tag,
368     s_jhtml_end_dl_tag,
369   },
370   /* tagDD */
371   {
372     s_jhtml_start_dd_tag,
373     s_jhtml_end_dd_tag,
374   },
375   /* tagMENU */
376   {
377     s_jhtml_start_menu_tag,
378     s_jhtml_end_menu_tag,
379   },
380   /* tagPLAINTEXT */
381   {
382     s_jhtml_start_plaintext_tag,
383     s_jhtml_end_plaintext_tag,
384   },
385   /* tagBLINK */
386   {
387     s_jhtml_start_blink_tag,
388     s_jhtml_end_blink_tag,
389   },
390   /* tagMARQUEE */
391   {
392     s_jhtml_start_marquee_tag,
393     s_jhtml_end_marquee_tag,
394   },
395   /* tagNLMARK */
396   {
397     s_jhtml_newline_mark,
398     NULL,
399   },
400 };
401
402
403 /**
404  * converts from CHTML5.0 to JHTML.
405  *
406  * @param r     [i]   Requet_rec is appointed.
407  * @param spec  [i]   The result of the device specification processing which 
408  *                    was done in advance is appointed.
409  * @param src   [i]   The character string before the converting is appointed.
410  * @return The character string after the converting is returned.
411  */
412 char *
413 chxj_convert_jhtml(
414   request_rec         *r,
415   device_table        *spec,
416   const char          *src,
417   apr_size_t          srclen,
418   apr_size_t          *dstlen,
419   chxjconvrule_entry  *entryp,
420   cookie_t            *cookie
421 )
422 {
423   char      *dst;
424   char      *ss;
425   jhtml_t   jhtml;
426   Doc       doc;
427
428   dst = NULL;
429
430   /*--------------------------------------------------------------------------*/
431   /* If qrcode xml                                                            */
432   /*--------------------------------------------------------------------------*/
433   *dstlen = srclen;
434   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
435   if (dst) {
436     DBG(r,"I found qrcode xml");
437     return dst;
438   }
439   DBG(r,"not found qrcode xml");
440
441   /*--------------------------------------------------------------------------*/
442   /* The CHTML structure is initialized.                                      */
443   /*--------------------------------------------------------------------------*/
444   s_init_jhtml(&jhtml, &doc, r, spec);
445
446   jhtml.entryp = entryp;
447   jhtml.cookie = cookie;
448
449   chxj_set_content_type(r, "text/html; charset=Windows-31J");
450
451   /*--------------------------------------------------------------------------*/
452   /* The character string of the input is analyzed.                           */
453   /*--------------------------------------------------------------------------*/
454   qs_init_malloc(&doc);
455   qs_init_root_node(&doc);
456
457   ss = apr_pcalloc(r->pool, srclen + 1);
458
459   memset(ss,   0, srclen + 1);
460   memcpy(ss, src, srclen);
461
462 #ifdef DUMP_LOG
463   chxj_dump_out("[src] CHTML -> JHTML", ss, srclen);
464 #endif
465
466   qs_parse_string(&doc,ss,strlen(ss));
467
468   chxj_buffered_write_init(r->pool, &doc.buf);
469   /*--------------------------------------------------------------------------*/
470   /* It converts it from CHTML to JHTML.                                      */
471   /*--------------------------------------------------------------------------*/
472   chxj_node_convert(spec,r,(void*)&jhtml, &doc, qs_get_root(&doc), 0);
473   jhtml.out = chxj_buffered_write_flush(jhtml.out, &doc.buf);
474   dst = apr_pstrdup(r->pool, jhtml.out);
475   chxj_buffered_write_terminate(&doc.buf);
476
477
478   qs_all_free(&doc,QX_LOGMARK);
479
480   if (! dst) 
481     return apr_pstrdup(r->pool,ss);
482
483   if (! strlen(dst)) 
484     dst = apr_psprintf(r->pool, "\n");
485
486   *dstlen = strlen(dst);
487
488 #ifdef DUMP_LOG
489   chxj_dump_out("[dst] CHTML -> JHTML", dst, *dstlen);
490 #endif
491
492   return dst;
493 }
494
495
496 /**
497  * The CHTML structure is initialized.
498  *
499  * @param jhtml [i/o] The pointer to the JHTML structure that wants to be
500  *                   initialized is specified.
501  * @param doc   [i]   The Doc structure that should be set to the initialized
502  *                   JHTML structure is specified.
503  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
504  * @param spec  [i]   The pointer to the device_table
505  */
506 static void
507 s_init_jhtml(jhtml_t *jhtml, Doc *doc, request_rec *r, device_table *spec)
508 {
509   memset(doc,   0, sizeof(Doc));
510   memset(jhtml, 0, sizeof(jhtml_t));
511
512   doc->r      = r;
513   jhtml->doc  = doc;
514   jhtml->spec = spec;
515   jhtml->out  = qs_alloc_zero_byte_string(r->pool);
516   jhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
517   jhtml->doc->parse_mode = PARSE_MODE_CHTML;
518 }
519
520
521 /**
522  * Corresponding EMOJI to a current character-code is retrieved. 
523  * The substitution character string is stored in the rslt pointer if agreeing.
524  *
525  * @param jhtml   [i]   The pointer to the CHTML structure is specified. 
526  * @param txt     [i]   The character string to want to examine whether it is 
527  *                      EMOJI is specified. 
528  * @param rslt    [o]   The pointer to the pointer that stores the result is 
529  *                      specified. 
530  * @return When corresponding EMOJI exists, it returns it excluding 0. 
531  */
532 static int
533 s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt)
534 {
535   emoji_t       *ee;
536   request_rec   *r;
537   device_table  *spec;
538   int           len;
539
540   spec = jhtml->spec;
541
542   len = strlen(txt);
543   r = jhtml->doc->r;
544
545   if (! spec) DBG(r,"spec is NULL");
546
547   for (ee = jhtml->conf->emoji;
548        ee;
549        ee = ee->next) {
550
551     unsigned char hex1byte;
552     unsigned char hex2byte;
553
554     if (! ee->imode) { 
555       DBG(r,"emoji->imode is NULL");
556       continue;
557     }
558
559     hex1byte = ee->imode->hex1byte & 0xff;
560     hex2byte = ee->imode->hex2byte & 0xff;
561
562     if (ee->imode->string
563     &&  strlen(ee->imode->string) > 0
564     &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
565       if (spec == NULL || spec->emoji_type == NULL) {
566         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
567         return strlen(ee->imode->string);
568       }
569
570       return 0;
571     }
572
573     if (len >= 2
574     && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
575     && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
576       if (spec == NULL || spec->emoji_type == NULL) {
577         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
578         return 2;
579       }
580
581       return 0;
582     }
583   }
584
585   return 0;
586 }
587
588
589 /**
590  * It is a handler who processes the HTML tag.
591  *
592  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
593  *                     destination is specified.
594  * @param node   [i]   The HTML tag node is specified.
595  * @return The conversion result is returned.
596  */
597 static char *
598 s_jhtml_start_html_tag(void *pdoc, Node *UNUSED(node)) 
599 {
600   jhtml_t       *jhtml;
601   Doc           *doc;
602   request_rec   *r;
603
604
605   jhtml  = GET_JHTML(pdoc);
606   doc    = jhtml->doc;
607   r      = doc->r;
608   DBG(r, "start s_jhtml_start_html_tag()");
609
610   /*--------------------------------------------------------------------------*/
611   /* start HTML tag                                                           */
612   /*--------------------------------------------------------------------------*/
613   W_L("<html>");
614
615   DBG(r, "end s_jhtml_start_html_tag()");
616
617   return jhtml->out;
618 }
619
620
621 /**
622  * It is a handler who processes the HTML tag.
623  *
624  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
625  *                     destination is specified.
626  * @param node   [i]   The HTML tag node is specified.
627  * @return The conversion result is returned.
628  */
629 static char *
630 s_jhtml_end_html_tag(void *pdoc, Node *UNUSED(child)) 
631 {
632   jhtml_t       *jhtml = GET_JHTML(pdoc);
633   Doc           *doc = jhtml->doc;
634
635   W_L("</html>");
636
637   return jhtml->out;
638 }
639
640
641 /**
642  * It is a handler who processes the META tag.
643  *
644  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
645  *                     destination is specified.
646  * @param node   [i]   The META tag node is specified.
647  * @return The conversion result is returned.
648  */
649 static char *
650 s_jhtml_start_meta_tag(void *pdoc, Node *node) 
651 {
652   jhtml_t      *jhtml;
653   Doc          *doc;
654   request_rec  *r;
655   Attr         *attr;
656   int          content_type_flag;
657   int          refresh_flag;
658
659   jhtml             = GET_JHTML(pdoc);
660   doc               = jhtml->doc;
661   r                 = doc->r;
662   refresh_flag      = 0;
663   content_type_flag = 0;
664
665   W_L("<meta");
666   /*--------------------------------------------------------------------------*/
667   /* Get Attributes                                                           */
668   /*--------------------------------------------------------------------------*/
669   for (attr = qs_get_attr(doc,node);
670        attr;
671        attr = qs_get_next_attr(doc,attr)) {
672     char *name   = qs_get_attr_name(doc,attr);
673     char *value  = qs_get_attr_value(doc,attr);
674     switch(*name) {
675     case 'h':
676     case 'H':
677       if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
678         /*----------------------------------------------------------------------*/
679         /* CHTML 2.0                                                            */
680         /*----------------------------------------------------------------------*/
681         W_L(" http-equiv=\"");
682         W_V(value);
683         W_L("\"");
684         if (STRCASEEQ('c','C',"content-type",value)) {
685           content_type_flag = 1;
686         }
687         if (STRCASEEQ('r','R',"refresh",value)) {
688           refresh_flag = 1;
689         }
690       }
691       break;
692
693     case 'c':
694     case 'C':
695       if (strcasecmp(name, "content") == 0 && value && *value) {
696         /*----------------------------------------------------------------------*/
697         /* CHTML 2.0                                                            */
698         /*----------------------------------------------------------------------*/
699         if (content_type_flag)  {
700           W_L(" ");
701           W_V(name);
702           W_L("=\"");
703           W_L("text/html; charset=Windows-31J");
704           W_L("\"");
705         }
706         else
707         if (refresh_flag) {
708           char *buf;
709           char *sec;
710           char *url;
711   
712           buf = apr_pstrdup(r->pool, value);
713   
714           url = strchr(buf, ';');
715           if (url) {
716             sec = apr_pstrdup(r->pool, buf);
717             sec[url-buf] = 0;
718             url++;
719             url = chxj_encoding_parameter(r, url);
720             url = chxj_add_cookie_parameter(r, url, jhtml->cookie);
721             W_L(" ");
722             W_V(name);
723             W_L("=\"");
724             W_V(sec);
725             W_L(";");
726             W_V(url);
727             W_L("\"");
728           }
729         }
730         else {
731           W_L(" ");
732           W_V(name);
733           W_L("=\"");
734           W_V(value);
735           W_L("\"");
736         }
737       }
738       break;
739     
740     default:
741       break;
742     }
743   }
744   W_L(">");
745   return jhtml->out;
746 }
747
748
749 /**
750  * It is a handler who processes the META tag.
751  *
752  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
753  *                     destination is specified.
754  * @param node   [i]   The META tag node is specified.
755  * @return The conversion result is returned.
756  */
757 static char *
758 s_jhtml_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
759 {
760   jhtml_t *jhtml = GET_JHTML(pdoc);
761
762   return jhtml->out;
763 }
764
765
766 /**
767  * It is a handler who processes the HEAD tag.
768  *
769  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
770  *                     destination is specified.
771  * @param node   [i]   The HEAD tag node is specified.
772  * @return The conversion result is returned.
773  */
774 static char *
775 s_jhtml_start_head_tag(void *pdoc, Node *UNUSED(node)) 
776 {
777   jhtml_t       *jhtml;
778   Doc           *doc;
779   request_rec   *r;
780
781   jhtml = GET_JHTML(pdoc);
782   doc   = jhtml->doc;
783   r     = doc->r;
784
785   W_L("<head>");
786   return jhtml->out;
787 }
788
789
790 /**
791  * It is a handler who processes the HEAD tag.
792  *
793  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
794  *                     destination is specified.
795  * @param node   [i]   The HEAD tag node is specified.
796  * @return The conversion result is returned.
797  */
798 static char *
799 s_jhtml_end_head_tag(void *pdoc, Node *UNUSED(child)) 
800 {
801   jhtml_t       *jhtml;
802   Doc           *doc;
803   request_rec   *r;
804
805   jhtml = GET_JHTML(pdoc);
806   doc   = jhtml->doc;
807   r     = doc->r;
808
809   W_L("</head>");
810   return jhtml->out;
811 }
812
813
814 /**
815  * It is a handler who processes the TITLE tag.
816  *
817  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
818  *                     destination is specified.
819  * @param node   [i]   The TITLE tag node is specified.
820  * @return The conversion result is returned.
821  */
822 static char *
823 s_jhtml_start_title_tag(void *pdoc, Node *UNUSED(node)) 
824 {
825   jhtml_t      *jhtml;
826   Doc          *doc;
827   request_rec  *r;
828
829   jhtml = GET_JHTML(pdoc);
830   doc   = jhtml->doc;
831   r     = doc->r;
832
833   W_L("<title>");
834   return jhtml->out;
835 }
836
837
838 /**
839  * It is a handler who processes the TITLE tag.
840  *
841  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
842  *                     destination is specified.
843  * @param node   [i]   The TITLE tag node is specified.
844  * @return The conversion result is returned.
845  */
846 static char *
847 s_jhtml_end_title_tag(void *pdoc, Node *UNUSED(child)) 
848 {
849   jhtml_t       *jhtml;
850   Doc           *doc;
851   request_rec   *r;
852
853   jhtml = GET_JHTML(pdoc);
854   doc   = jhtml->doc;
855   r     = doc->r;
856
857   W_L("</title>");
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_start_base_tag(void *pdoc, Node *node) 
872 {
873   jhtml_t       *jhtml;
874   Attr          *attr;
875   Doc           *doc;
876   request_rec   *r;
877
878   jhtml = GET_JHTML(pdoc);
879   doc   = jhtml->doc;
880   r     = doc->r;
881
882   W_L("<base");
883   /*--------------------------------------------------------------------------*/
884   /* Get Attributes                                                           */
885   /*--------------------------------------------------------------------------*/
886   for (attr = qs_get_attr(doc,node);
887        attr;
888        attr = qs_get_next_attr(doc,attr)) {
889     char *name  = qs_get_attr_name(doc,attr);
890     char *value = qs_get_attr_value(doc,attr);
891     if (STRCASEEQ('h','H',"href",name)) {
892       W_L(" href=\"");
893       W_V(value);
894       W_L("\"");
895     }
896   }
897   W_L(">");
898   return jhtml->out;
899 }
900
901
902 /**
903  * It is a handler who processes the BASE tag.
904  *
905  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
906  *                     destination is specified.
907  * @param node   [i]   The BASE tag node is specified.
908  * @return The conversion result is returned.
909  */
910 static char *
911 s_jhtml_end_base_tag(void *pdoc, Node *UNUSED(child)) 
912 {
913   jhtml_t *jhtml = GET_JHTML(pdoc);
914   return jhtml->out;
915 }
916
917
918 /**
919  * It is a handler who processes the BODY tag.
920  *
921  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
922  *                     destination is specified.
923  * @param node   [i]   The BODY tag node is specified.
924  * @return The conversion result is returned.
925  */
926 static char *
927 s_jhtml_start_body_tag(void *pdoc, Node *node) 
928 {
929   jhtml_t      *jhtml;
930   Doc          *doc;
931   request_rec  *r;
932   Attr         *attr;
933
934   jhtml = GET_JHTML(pdoc);
935   doc   = jhtml->doc;
936   r     = doc->r;
937
938   W_L("<body");
939   /*--------------------------------------------------------------------------*/
940   /* Get Attributes                                                           */
941   /*--------------------------------------------------------------------------*/
942   for (attr = qs_get_attr(doc,node);
943        attr;
944        attr = qs_get_next_attr(doc,attr)) {
945     char *name   = qs_get_attr_name(doc,attr);
946     char *value  = qs_get_attr_value(doc,attr);
947     if (STRCASEEQ('b','B',"bgcolor",name) && value && *value) {
948       /*----------------------------------------------------------------------*/
949       /* CHTML 2.0                                                            */
950       /*----------------------------------------------------------------------*/
951       W_L(" bgcolor=\"");
952       W_V(value);
953       W_L("\"");
954     }
955     else if (STRCASEEQ('t','T',"text",name) && value && *value) {
956       /*----------------------------------------------------------------------*/
957       /* CHTML 2.0                                                            */
958       /*----------------------------------------------------------------------*/
959       W_L(" text=\"");
960       W_V(value);
961       W_L("\"");
962     }
963     else if (STRCASEEQ('l','L',"link",name) && value && *value) {
964       /*----------------------------------------------------------------------*/
965       /* CHTML 2.0                                                            */
966       /*----------------------------------------------------------------------*/
967       W_L(" link=\"");
968       W_V(value);
969       W_L("\"");
970     }
971     else if (STRCASEEQ('a','A',"alink",name)) {
972       /*----------------------------------------------------------------------*/
973       /* CHTML 4.0                                                            */
974       /*----------------------------------------------------------------------*/
975       /* ignore */
976     }
977     else if (STRCASEEQ('v','V',"vlink",name)) {
978       /*----------------------------------------------------------------------*/
979       /* CHTML 4.0                                                            */
980       /*----------------------------------------------------------------------*/
981       /* ignore */
982     }
983   }
984   W_L(">");
985   return jhtml->out;
986 }
987
988
989 /**
990  * It is a handler who processes the BODY tag.
991  *
992  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
993  *                     destination is specified.
994  * @param node   [i]   The BODY tag node is specified.
995  * @return The conversion result is returned.
996  */
997 static char *
998 s_jhtml_end_body_tag(void *pdoc, Node *UNUSED(child)) 
999 {
1000   jhtml_t       *jhtml;
1001   Doc           *doc;
1002   request_rec   *r;
1003
1004   jhtml = GET_JHTML(pdoc);
1005   doc   = jhtml->doc;
1006   r     = doc->r;
1007
1008   W_L("</body>");
1009   return jhtml->out;
1010 }
1011
1012
1013 /**
1014  * It is a handler who processes the A tag.
1015  *
1016  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1017  *                     destination is specified.
1018  * @param node   [i]   The A tag node is specified.
1019  * @return The conversion result is returned.
1020  */
1021 static char *
1022 s_jhtml_start_a_tag(void *pdoc, Node *node) 
1023 {
1024   jhtml_t       *jhtml;
1025   Doc           *doc;
1026   request_rec   *r;
1027   Attr          *attr;
1028
1029   jhtml = GET_JHTML(pdoc);
1030   doc   = jhtml->doc;
1031   r     = doc->r;
1032
1033   W_L("<a");
1034   /*--------------------------------------------------------------------------*/
1035   /* Get Attributes                                                           */
1036   /*--------------------------------------------------------------------------*/
1037   for (attr = qs_get_attr(doc,node);
1038        attr; 
1039        attr = qs_get_next_attr(doc,attr)) {
1040     char *name  = qs_get_attr_name(doc,attr);
1041     char *value = qs_get_attr_value(doc,attr);
1042     if (STRCASEEQ('n','N',"name",name)) {
1043       /*----------------------------------------------------------------------*/
1044       /* CHTML1.0                                                             */
1045       /*----------------------------------------------------------------------*/
1046       W_L(" name=\"");
1047       W_V(value);
1048       W_L("\"");
1049     }
1050     else if (STRCASEEQ('h','H',"href",name)) {
1051       /*----------------------------------------------------------------------*/
1052       /* CHTML1.0                                                             */
1053       /*----------------------------------------------------------------------*/
1054       value = chxj_encoding_parameter(r, value);
1055       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1056       W_L(" href=\"");
1057       W_V(value);
1058       W_L("\"");
1059     }
1060     else if (STRCASEEQ('a','A',"accesskey",name)) {
1061       /*----------------------------------------------------------------------*/
1062       /* CHTML1.0                                                             */
1063       /*----------------------------------------------------------------------*/
1064       W_L(" accesskey=\"");
1065       W_V(value);
1066       W_L("\"");
1067     }
1068     else if (STRCASEEQ('c','C',"cti",name)) {
1069       /*----------------------------------------------------------------------*/
1070       /* CHTML 2.0                                                            */
1071       /*----------------------------------------------------------------------*/
1072       W_L(" cti=\"");
1073       W_V(value);
1074       W_L("\"");
1075     }
1076     else if (STRCASEEQ('i','I',"ijam",name)) {
1077       /*----------------------------------------------------------------------*/
1078       /* CHTML 3.0                                                            */
1079       /*----------------------------------------------------------------------*/
1080       /* ignore */
1081     }
1082     else if (STRCASEEQ('u','U',"utn",name)) {
1083       /*----------------------------------------------------------------------*/
1084       /* CHTML 3.0                                                            */
1085       /* It is special only for CHTML.                                        */
1086       /*----------------------------------------------------------------------*/
1087       W_L(" utn ");
1088     }
1089     else if (STRCASEEQ('t','T',"telbook",name)) {
1090       /*----------------------------------------------------------------------*/
1091       /* CHTML 3.0                                                            */
1092       /*----------------------------------------------------------------------*/
1093       /* not support */
1094     }
1095     else if (STRCASEEQ('k','K',"kana",name)) {
1096       /*----------------------------------------------------------------------*/
1097       /* CHTML 3.0                                                            */
1098       /*----------------------------------------------------------------------*/
1099       /* not support */
1100     }
1101     else if (STRCASEEQ('e','E',"email",name)) {
1102       /*----------------------------------------------------------------------*/
1103       /* CHTML 3.0                                                            */
1104       /*----------------------------------------------------------------------*/
1105       /* not support */
1106     }
1107     else if (STRCASEEQ('i','I',"ista",name)) {
1108       /*----------------------------------------------------------------------*/
1109       /* CHTML 4.0                                                            */
1110       /*----------------------------------------------------------------------*/
1111       /* ignore */
1112     }
1113     else if (STRCASEEQ('i','I',"ilet",name)) {
1114       /*----------------------------------------------------------------------*/
1115       /* CHTML 5.0                                                            */
1116       /*----------------------------------------------------------------------*/
1117       /* ignore */
1118     }
1119     else if (STRCASEEQ('i','I',"iswf",name)) {
1120       /*----------------------------------------------------------------------*/
1121       /* CHTML 5.0                                                            */
1122       /*----------------------------------------------------------------------*/
1123       /* ignore */
1124     }
1125     else if (STRCASEEQ('i','I',"irst",name)) {
1126       /*----------------------------------------------------------------------*/
1127       /* CHTML 5.0                                                            */
1128       /*----------------------------------------------------------------------*/
1129       /* ignore */
1130     }
1131   }
1132   W_L(">");
1133   return jhtml->out;
1134 }
1135
1136
1137 /**
1138  * It is a handler who processes the A tag.
1139  *
1140  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1141  *                     destination is specified.
1142  * @param node   [i]   The A tag node is specified.
1143  * @return The conversion result is returned.
1144  */
1145 static char *
1146 s_jhtml_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1147 {
1148   jhtml_t      *jhtml;
1149   Doc          *doc;
1150   request_rec  *r;
1151
1152   jhtml = GET_JHTML(pdoc);
1153   doc   = jhtml->doc;
1154   r     = doc->r;
1155
1156   W_L("</a>");
1157   return jhtml->out;
1158 }
1159
1160
1161 /**
1162  * It is a handler who processes the BR 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 BR tag node is specified.
1167  * @return The conversion result is returned.
1168  */
1169 static char *
1170 s_jhtml_start_br_tag(void *pdoc, Node *node)
1171 {
1172   jhtml_t      *jhtml;
1173   Doc          *doc;
1174   request_rec  *r;
1175   Attr         *attr;
1176
1177   jhtml = GET_JHTML(pdoc);
1178   doc   = jhtml->doc;
1179   r     = doc->r;
1180
1181   W_L("<br");
1182   /*--------------------------------------------------------------------------*/
1183   /* Get Attributes                                                           */
1184   /*--------------------------------------------------------------------------*/
1185   for (attr = qs_get_attr(doc,node);
1186        attr;
1187        attr = qs_get_next_attr(doc,attr)) {
1188     char *name  = qs_get_attr_name(doc,attr);
1189     char *value = qs_get_attr_value(doc,attr);
1190     if (STRCASEEQ('c','C',"clear",name)) {
1191       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1192         W_L(" clear=\"");
1193         W_V(value);
1194         W_L("\"");
1195       }
1196     }
1197   }
1198   W_L(">");
1199   return jhtml->out;
1200 }
1201
1202
1203 /**
1204  * It is a handler who processes the BR tag.
1205  *
1206  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1207  *                     destination is specified.
1208  * @param node   [i]   The BR tag node is specified.
1209  * @return The conversion result is returned.
1210  */
1211 static char *
1212 s_jhtml_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1213 {
1214   jhtml_t *jhtml = GET_JHTML(pdoc);
1215   return jhtml->out;
1216 }
1217
1218
1219 /**
1220  * It is a handler who processes the TR tag.
1221  *
1222  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1223  *                     destination is specified.
1224  * @param node   [i]   The TR tag node is specified.
1225  * @return The conversion result is returned.
1226  */
1227 static char *
1228 s_jhtml_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1229 {
1230   jhtml_t      *jhtml;
1231   Doc          *doc;
1232   request_rec  *r;
1233
1234   jhtml = GET_JHTML(pdoc);
1235   doc   = jhtml->doc;
1236   r     = doc->r;
1237
1238   W_L("<br>");
1239   return jhtml->out;
1240 }
1241
1242
1243 /**
1244  * It is a handler who processes the TR tag.
1245  *
1246  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1247  *                     destination is specified.
1248  * @param node   [i]   The TR tag node is specified.
1249  * @return The conversion result is returned.
1250  */
1251 static char *
1252 s_jhtml_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1253 {
1254   jhtml_t *jhtml = GET_JHTML(pdoc);
1255   return jhtml->out;
1256 }
1257
1258
1259 /**
1260  * It is a handler who processes the FONT tag.
1261  *
1262  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1263  *                     destination is specified.
1264  * @param node   [i]   The FONT tag node is specified.
1265  * @return The conversion result is returned.
1266  */
1267 static char *
1268 s_jhtml_start_font_tag(void *pdoc, Node *node) 
1269 {
1270   jhtml_t       *jhtml;
1271   Doc           *doc;
1272   request_rec   *r;
1273   Attr          *attr;
1274   char          *color = NULL;
1275
1276   jhtml = GET_JHTML(pdoc);
1277   doc   = jhtml->doc;
1278   r     = doc->r;
1279
1280   /*--------------------------------------------------------------------------*/
1281   /* Get Attributes                                                           */
1282   /*--------------------------------------------------------------------------*/
1283   for (attr = qs_get_attr(doc,node);
1284        attr; 
1285        attr = qs_get_next_attr(doc,attr)) {
1286     char *name  = qs_get_attr_name(doc,attr);
1287     char *value = qs_get_attr_value(doc,attr);
1288     if (STRCASEEQ('c','C',"color",name) && value && *value) {
1289       color = apr_pstrdup(doc->buf.pool, value);
1290       break;
1291     }
1292     else if (STRCASEEQ('s','S',"size",name)) {
1293       /*----------------------------------------------------------------------*/
1294       /* CHTML 5.0                                                            */
1295       /*----------------------------------------------------------------------*/
1296       /* ignore */
1297     }
1298   }
1299   if (color) {
1300     W_L("<font color=\"");
1301     W_V(color);
1302     W_L("\">");
1303     jhtml->font_flag++;
1304   }
1305   return jhtml->out;
1306 }
1307
1308
1309 /**
1310  * It is a handler who processes the FONT tag.
1311  *
1312  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1313  *                     destination is specified.
1314  * @param node   [i]   The FONT tag node is specified.
1315  * @return The conversion result is returned.
1316  */
1317 static char *
1318 s_jhtml_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1319 {
1320   jhtml_t      *jhtml;
1321   request_rec  *r;
1322   Doc          *doc;
1323
1324   jhtml = GET_JHTML(pdoc);
1325   doc   = jhtml->doc;
1326   r     = jhtml->doc->r;
1327
1328   if (jhtml->font_flag) {
1329     W_L("</font>");
1330     jhtml->font_flag--;
1331   }
1332   return jhtml->out;
1333 }
1334
1335
1336 /**
1337  * It is a handler who processes the FORM tag.
1338  *
1339  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1340  *                     destination is specified.
1341  * @param node   [i]   The FORM tag node is specified.
1342  * @return The conversion result is returned.
1343  */
1344 static char *
1345 s_jhtml_start_form_tag(void *pdoc, Node *node) 
1346 {
1347   jhtml_t      *jhtml;
1348   Doc          *doc;
1349   request_rec  *r;
1350   Attr         *attr;
1351
1352   jhtml = GET_JHTML(pdoc);
1353   doc   = jhtml->doc;
1354   r     = doc->r;
1355
1356   W_L("<form");
1357   /*--------------------------------------------------------------------------*/
1358   /* Get Attributes                                                           */
1359   /*--------------------------------------------------------------------------*/
1360   for (attr = qs_get_attr(doc,node);
1361        attr;
1362        attr = qs_get_next_attr(doc,attr)) {
1363     char *name  = qs_get_attr_name(doc,attr);
1364     char *value = qs_get_attr_value(doc,attr);
1365     if (STRCASEEQ('a','A',"action",name)) {
1366       /*----------------------------------------------------------------------*/
1367       /* CHTML 1.0                                                            */
1368       /*----------------------------------------------------------------------*/
1369       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1370       W_L(" action=\"");
1371       W_V(value);
1372       W_L("\"");
1373     }
1374     else if (STRCASEEQ('m','M',"method",name)) {
1375       /*----------------------------------------------------------------------*/
1376       /* CHTML 1.0                                                            */
1377       /*----------------------------------------------------------------------*/
1378       W_L(" method=\"");
1379       W_V(value);
1380       W_L("\"");
1381     }
1382     else if (STRCASEEQ('u','U',"utn",name)) {
1383       /*----------------------------------------------------------------------*/
1384       /* CHTML 3.0                                                            */
1385       /* It is special only for CHTML.                                        */
1386       /*----------------------------------------------------------------------*/
1387       /* ignore */
1388     }
1389   }
1390   W_L(">");
1391   return jhtml->out;
1392 }
1393
1394
1395 /**
1396  * It is a handler who processes the FORM tag.
1397  *
1398  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1399  *                     destination is specified.
1400  * @param node   [i]   The FORM tag node is specified.
1401  * @return The conversion result is returned.
1402  */
1403 static char *
1404 s_jhtml_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1405 {
1406   jhtml_t *jhtml = GET_JHTML(pdoc);
1407   Doc     *doc   = jhtml->doc;
1408   W_L("</form>");
1409   return jhtml->out;
1410 }
1411
1412
1413 /**
1414  * It is a handler who processes the INPUT tag.
1415  *
1416  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1417  *                     destination is specified.
1418  * @param node   [i]   The INPUT tag node is specified.
1419  * @return The conversion result is returned.
1420  */
1421 static char *
1422 s_jhtml_start_input_tag(void *pdoc, Node *node) 
1423 {
1424   jhtml_t       *jhtml;
1425   Doc           *doc;
1426   request_rec   *r;
1427   char          *max_length;
1428   char          *type;
1429   char          *name;
1430   char          *value;
1431   char          *istyle;
1432   char          *size;
1433   char          *checked;
1434   char          *accesskey;
1435
1436   jhtml       = GET_JHTML(pdoc);
1437   doc         = jhtml->doc;
1438   r           = doc->r;
1439   max_length  = NULL;
1440   type        = NULL;
1441   name        = NULL;
1442   value       = NULL;
1443   istyle      = NULL;
1444   size        = NULL;
1445   checked     = NULL;
1446   accesskey   = NULL;
1447
1448   W_L("<input");
1449   /*--------------------------------------------------------------------------*/
1450   /* Get Attributes                                                           */
1451   /*--------------------------------------------------------------------------*/
1452   type       = qs_get_type_attr(doc, node, doc->buf.pool);
1453   name       = qs_get_name_attr(doc, node, doc->buf.pool);
1454   value      = qs_get_value_attr(doc,node,doc->buf.pool);
1455   istyle     = qs_get_istyle_attr(doc,node,doc->buf.pool);
1456   max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
1457   checked    = qs_get_checked_attr(doc,node,doc->buf.pool);
1458   accesskey  = qs_get_accesskey_attr(doc, node, doc->buf.pool);
1459   size       = qs_get_size_attr(doc, node, doc->buf.pool);
1460
1461   if (type) {
1462     if (type && (STRCASEEQ('t','T',"text",    type) ||
1463                  STRCASEEQ('p','P',"password",type) ||
1464                  STRCASEEQ('c','C',"checkbox",type) ||
1465                  STRCASEEQ('r','R',"radio",   type) ||
1466                  STRCASEEQ('h','H',"hidden",  type) ||
1467                  STRCASEEQ('s','S',"submit",  type) ||
1468                  STRCASEEQ('r','R',"reset",   type))) {
1469       W_L(" type=\"");
1470       W_V(type);
1471       W_L("\"");
1472     }
1473   }
1474   if (size && *size) {
1475     W_L(" size=\"");
1476     W_V(size);
1477     W_L("\"");
1478   }
1479   if (name && *name) {
1480     W_L(" name=\"");
1481     W_V(name);
1482     W_L("\"");
1483   }
1484   if (value && *value) {
1485     W_L(" value=\"");
1486     W_V(value);
1487     W_L("\"");
1488   }
1489   if (accesskey && *accesskey) {
1490     W_L(" accesskey=\"");
1491     W_V(accesskey);
1492     W_L("\"");
1493   }
1494   if (istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1495     /*------------------------------------------------------------------------*/
1496     /* CHTML 2.0                                                              */
1497     /*------------------------------------------------------------------------*/
1498     if (type && STRCASEEQ('p','P',"password", type) && ! jhtml->entryp->pc_flag ) {
1499       W_L(" mode=\"");
1500       W_L("numeric");
1501       W_L("\"");
1502     }
1503     else {
1504       char *vv = chxj_istyle_to_mode(doc->buf.pool,istyle);
1505       W_L(" mode=\"");
1506       W_V(vv);
1507       W_L("\"");
1508     }
1509   }
1510   else if (type && STRCASEEQ('p','P',"password",type)) {
1511     W_L(" mode=\"");
1512     W_L("numeric");
1513     W_L("\"");
1514   }
1515   /*--------------------------------------------------------------------------*/
1516   /* The figure is default for the password.                                  */
1517   /*--------------------------------------------------------------------------*/
1518   if (max_length && *max_length) {
1519     if (chxj_chk_numeric(max_length) == 0) {
1520       W_L(" maxlength=\"");
1521       W_V(max_length);
1522       W_L("\"");
1523     }
1524   }
1525
1526   if (checked) {
1527     W_L(" checked");
1528   }
1529   W_L(">");
1530   return jhtml->out;
1531 }
1532
1533
1534 /**
1535  * It is a handler who processes the INPUT tag.
1536  *
1537  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1538  *                     destination is specified.
1539  * @param node   [i]   The INPUT tag node is specified.
1540  * @return The conversion result is returned.
1541  */
1542 static char *
1543 s_jhtml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1544 {
1545   jhtml_t *jhtml = GET_JHTML(pdoc);
1546   return jhtml->out;
1547 }
1548
1549
1550 /**
1551  * It is a handler who processes the CENTER tag.
1552  *
1553  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1554  *                     destination is specified.
1555  * @param node   [i]   The CENTER tag node is specified.
1556  * @return The conversion result is returned.
1557  */
1558 static char *
1559 s_jhtml_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1560 {
1561   jhtml_t *jhtml = GET_JHTML(pdoc);
1562   Doc     *doc   = jhtml->doc;
1563   W_L("<center>");
1564   return jhtml->out;
1565 }
1566
1567
1568 /**
1569  * It is a handler who processes the CENTER tag.
1570  *
1571  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1572  *                     destination is specified.
1573  * @param node   [i]   The CENTER tag node is specified.
1574  * @return The conversion result is returned.
1575  */
1576 static char *
1577 s_jhtml_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1578 {
1579   jhtml_t     *jhtml;
1580   Doc         *doc;
1581   request_rec *r;
1582
1583   jhtml = GET_JHTML(pdoc);
1584   doc   = jhtml->doc;
1585   r     = doc->r;
1586
1587   W_L("</center>");
1588   return jhtml->out;
1589 }
1590
1591
1592 /**
1593  * It is a handler who processes the li tag.
1594  *
1595  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1596  *                     destination is specified.
1597  * @param node   [i]   The li tag node is specified.
1598  * @return The conversion result is returned.
1599  */
1600 static char *
1601 s_jhtml_start_li_tag(void *pdoc, Node *node)
1602 {
1603   jhtml_t       *jhtml;
1604   Doc           *doc;
1605   request_rec   *r;
1606   Attr          *attr;
1607
1608   jhtml = GET_JHTML(pdoc);
1609   doc   = jhtml->doc;
1610   r     = doc->r;
1611
1612   W_L("<li");
1613   /*--------------------------------------------------------------------------*/
1614   /* Get Attributes                                                           */
1615   /*--------------------------------------------------------------------------*/
1616   for (attr = qs_get_attr(doc,node);
1617        attr;
1618        attr = qs_get_next_attr(doc,attr)) {
1619     char *name = qs_get_attr_name(doc,attr);
1620     char *value = qs_get_attr_value(doc,attr);
1621     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1622       W_L(" type=\"");
1623       W_V(value);
1624       W_L("\"");
1625     }
1626     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1627       W_L(" value=\"");
1628       W_V(value);
1629       W_L("\"");
1630     }
1631   }
1632   W_L(">");
1633   return jhtml->out;
1634 }
1635
1636
1637 /**
1638  * It is a handler who processes the li tag.
1639  *
1640  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1641  *                     destination is specified.
1642  * @param node   [i]   The li tag node is specified.
1643  * @return The conversion result is returned.
1644  */
1645 static char *
1646 s_jhtml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
1647 {
1648   jhtml_t     *jhtml;
1649   Doc         *doc;
1650   request_rec *r;
1651
1652   jhtml = GET_JHTML(pdoc);
1653   doc   = jhtml->doc;
1654   r     = doc->r;
1655
1656   W_L("</li>");
1657   return jhtml->out;
1658 }
1659
1660
1661 /**
1662  * It is a handler who processes the OL tag.
1663  *
1664  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1665  *                     destination is specified.
1666  * @param node   [i]   The OL tag node is specified.
1667  * @return The conversion result is returned.
1668  */
1669 static char *
1670 s_jhtml_start_ol_tag(void *pdoc, Node *node)
1671 {
1672   jhtml_t     *jhtml;
1673   Doc         *doc;
1674   request_rec *r;
1675   Attr        *attr;
1676
1677   jhtml = GET_JHTML(pdoc);
1678   doc   = jhtml->doc;
1679   r     = doc->r;
1680
1681   W_L("<ol");
1682   /*--------------------------------------------------------------------------*/
1683   /* Get Attributes                                                           */
1684   /*--------------------------------------------------------------------------*/
1685   for (attr = qs_get_attr(doc,node);
1686        attr;
1687        attr = qs_get_next_attr(doc,attr)) {
1688     char *name = qs_get_attr_name(doc,attr);
1689     char *value = qs_get_attr_value(doc,attr);
1690     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1691       W_L(" type=\"");
1692       W_V(value);
1693       W_L("\"");
1694     }
1695     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1696       W_L(" start=\"");
1697       W_V(value);
1698       W_L("\"");
1699     }
1700   }
1701   W_L(">");
1702   return jhtml->out;
1703 }
1704
1705
1706 /**
1707  * It is a handler who processes the OL tag.
1708  *
1709  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1710  *                     destination is specified.
1711  * @param node   [i]   The OL tag node is specified.
1712  * @return The conversion result is returned.
1713  */
1714 static char *
1715 s_jhtml_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
1716 {
1717   jhtml_t     *jhtml;
1718   Doc         *doc;
1719   request_rec *r;
1720
1721   jhtml = GET_JHTML(pdoc);
1722   doc   = jhtml->doc;
1723   r     = doc->r;
1724
1725   W_L("</ol>");
1726   return jhtml->out;
1727 }
1728
1729
1730 /**
1731  * It is a handler who processes the P tag.
1732  *
1733  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1734  *                     destination is specified.
1735  * @param node   [i]   The P tag node is specified.
1736  * @return The conversion result is returned.
1737  */
1738 static char *
1739 s_jhtml_start_p_tag(void *pdoc, Node *node)
1740 {
1741   jhtml_t     *jhtml;
1742   Doc         *doc;
1743   request_rec *r;
1744   char        *align = NULL;
1745   Attr        *attr;
1746
1747   jhtml = GET_JHTML(pdoc);
1748   doc   = jhtml->doc;
1749   r     = doc->r;
1750
1751   W_L("<p");
1752   for (attr = qs_get_attr(doc,node);
1753        attr;
1754        attr = qs_get_next_attr(doc,attr)) {
1755     char *nm  = qs_get_attr_name(doc,attr);
1756     char *val = qs_get_attr_value(doc,attr);
1757     if (STRCASEEQ('a','A',"align", nm)) {
1758       /*----------------------------------------------------------------------*/
1759       /* CHTML 1.0 (W3C version 3.2)                                          */
1760       /*----------------------------------------------------------------------*/
1761       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
1762         align = apr_pstrdup(doc->buf.pool, val);
1763         break;
1764       }
1765     }
1766   }
1767   if (align) {
1768     W_L(" align=\"");
1769     W_V(align);
1770     W_L("\"");
1771   }
1772   W_L(">");
1773   return jhtml->out;
1774 }
1775
1776
1777 /**
1778  * It is a handler who processes the P tag.
1779  *
1780  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1781  *                     destination is specified.
1782  * @param node   [i]   The P tag node is specified.
1783  * @return The conversion result is returned.
1784  */
1785 static char *
1786 s_jhtml_end_p_tag(void *pdoc, Node *UNUSED(child)) 
1787 {
1788   jhtml_t   *jhtml = GET_JHTML(pdoc);
1789   Doc       *doc   = jhtml->doc;
1790
1791   W_L("</p>");
1792   return jhtml->out;
1793 }
1794
1795
1796 /**
1797  * It is a handler who processes the PRE tag.
1798  *
1799  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1800  *                     destination is specified.
1801  * @param node   [i]   The PRE tag node is specified.
1802  * @return The conversion result is returned.
1803  */
1804 static char *
1805 s_jhtml_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
1806 {
1807   jhtml_t  *jhtml = GET_JHTML(pdoc);
1808   Doc      *doc   = jhtml->doc;
1809
1810   jhtml->pre_flag++;
1811   W_L("<pre>");
1812   return jhtml->out;
1813 }
1814
1815
1816 /**
1817  * It is a handler who processes the PRE tag.
1818  *
1819  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1820  *                     destination is specified.
1821  * @param node   [i]   The PRE tag node is specified.
1822  * @return The conversion result is returned.
1823  */
1824 static char *
1825 s_jhtml_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
1826 {
1827   jhtml_t *jhtml = GET_JHTML(pdoc);
1828   Doc     *doc   = jhtml->doc;
1829
1830   W_L("</pre>");
1831   jhtml->pre_flag--;
1832
1833   return jhtml->out;
1834 }
1835
1836
1837 /**
1838  * It is a handler who processes the UL tag.
1839  *
1840  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1841  *                     destination is specified.
1842  * @param node   [i]   The UL tag node is specified.
1843  * @return The conversion result is returned.
1844  */
1845 static char *
1846 s_jhtml_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
1847 {
1848   jhtml_t *jhtml = GET_JHTML(pdoc);
1849   Doc     *doc   = jhtml->doc;
1850
1851   W_L("<ul>");
1852   return jhtml->out;
1853 }
1854
1855
1856 /**
1857  * It is a handler who processes the UL tag.
1858  *
1859  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1860  *                     destination is specified.
1861  * @param node   [i]   The UL tag node is specified.
1862  * @return The conversion result is returned.
1863  */
1864 static char *
1865 s_jhtml_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1866 {
1867   jhtml_t *jhtml = GET_JHTML(pdoc);
1868   Doc     *doc   = jhtml->doc;
1869
1870   W_L("</ul>");
1871   return jhtml->out;
1872 }
1873
1874
1875 /**
1876  * It is a handler who processes the HR tag.
1877  *
1878  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1879  *                     destination is specified.
1880  * @param node   [i]   The HR tag node is specified.
1881  * @return The conversion result is returned.
1882  */
1883 static char *
1884 s_jhtml_start_hr_tag(void *pdoc, Node *node) 
1885 {
1886   jhtml_t *jhtml = GET_JHTML(pdoc);
1887   Doc     *doc   = jhtml->doc;
1888   Attr    *attr;
1889
1890   W_L("<hr");
1891   for (attr = qs_get_attr(doc,node);
1892        attr; 
1893        attr = qs_get_next_attr(doc,attr)) {
1894     char *name = qs_get_attr_name(doc,attr);
1895     char *value = qs_get_attr_value(doc,attr);
1896     if (STRCASEEQ('a','A',"align",name)) {
1897       /*----------------------------------------------------------------------*/
1898       /* CHTML 1.0                                                            */
1899       /*----------------------------------------------------------------------*/
1900       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1901         W_L(" align=\"");
1902         W_V(value);
1903         W_L("\"");
1904       }
1905     }
1906     else if (STRCASEEQ('s','S',"size",name) && value && *value) {
1907       /*----------------------------------------------------------------------*/
1908       /* CHTML 1.0                                                            */
1909       /*----------------------------------------------------------------------*/
1910       W_L(" size=\"");
1911       W_V(value);
1912       W_L("\"");
1913     }
1914     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
1915       /*----------------------------------------------------------------------*/
1916       /* CHTML 1.0                                                            */
1917       /*----------------------------------------------------------------------*/
1918       W_L(" width=\"");
1919       W_V(value);
1920       W_L("\"");
1921     }
1922     else if (STRCASEEQ('n','N',"noshade",name)) {
1923       /*----------------------------------------------------------------------*/
1924       /* CHTML 1.0                                                            */
1925       /*----------------------------------------------------------------------*/
1926       W_L(" noshade");
1927     }
1928     else if (STRCASEEQ('c','C',"color",name) && value && *value) {
1929       /*----------------------------------------------------------------------*/
1930       /* CHTML 4.0                                                            */
1931       /*----------------------------------------------------------------------*/
1932       W_L(" color=\"");
1933       W_V(value);
1934       W_L("\"");
1935     }
1936   }
1937   W_L(">");
1938   return jhtml->out;
1939 }
1940
1941
1942 /**
1943  * It is a handler who processes the HR tag.
1944  *
1945  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1946  *                     destination is specified.
1947  * @param node   [i]   The HR tag node is specified.
1948  * @return The conversion result is returned.
1949  */
1950 static char *
1951 s_jhtml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1952 {
1953   jhtml_t *jhtml = GET_JHTML(pdoc);
1954   return jhtml->out;
1955 }
1956
1957
1958 /**
1959  * It is a handler who processes the IMG tag.
1960  *
1961  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1962  *                     destination is specified.
1963  * @param node   [i]   The IMG tag node is specified.
1964  * @return The conversion result is returned.
1965  */
1966 static char *
1967 s_jhtml_start_img_tag(void *pdoc, Node *node) 
1968 {
1969   jhtml_t       *jhtml = GET_JHTML(pdoc);
1970   Doc           *doc   = jhtml->doc;
1971   request_rec   *r     = doc->r;
1972   Attr          *attr;
1973 #ifndef IMG_NOT_CONVERT_FILENAME
1974   device_table  *spec = jhtml->spec;
1975 #endif
1976
1977   W_L("<img");
1978   /*--------------------------------------------------------------------------*/
1979   /* Get Attributes                                                           */
1980   /*--------------------------------------------------------------------------*/
1981   for (attr = qs_get_attr(doc,node);
1982        attr;
1983        attr = qs_get_next_attr(doc,attr)) {
1984     char *name  = qs_get_attr_name(doc,attr);
1985     char *value = qs_get_attr_value(doc,attr);
1986     if (STRCASEEQ('s','S',"src",name)) {
1987       /*----------------------------------------------------------------------*/
1988       /* CHTML 1.0                                                            */
1989       /*----------------------------------------------------------------------*/
1990 #ifdef IMG_NOT_CONVERT_FILENAME
1991       value = chxj_encoding_parameter(r, value);
1992       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1993       if (value) {
1994         value = apr_psprintf(r->pool,
1995                              "%s%c%s=true",
1996                              value,
1997                              (strchr(value, '?')) ? '&' : '?',
1998                              CHXJ_COOKIE_NOUPDATE_PARAM);
1999       }
2000       W_L(" src=\"");
2001       W_V(value);
2002       W_L("\"");
2003 #else
2004       value = chxj_img_conv(r, spec, value);
2005       value = chxj_encoding_parameter(r, value);
2006       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
2007       if (value) {
2008         value = apr_psprintf(r->pool,
2009                              "%s%c%s=true",
2010                              value,
2011                              (strchr(value, '?')) ? '&' : '?',
2012                              CHXJ_COOKIE_NOUPDATE_PARAM);
2013       }
2014       W_L(" src=\"");
2015       W_V(value);
2016       W_L("\"");
2017 #endif
2018     }
2019     else if (STRCASEEQ('a','A',"align",name)) {
2020       /*----------------------------------------------------------------------*/
2021       /* CHTML 1.0                                                            */
2022       /*----------------------------------------------------------------------*/
2023       if (value) {
2024         if (STRCASEEQ('t','T',"top",   value) ||
2025             STRCASEEQ('m','M',"middle",value) ||
2026             STRCASEEQ('b','B',"bottom",value) ||
2027             STRCASEEQ('l','L',"left",  value) ||
2028             STRCASEEQ('r','R',"right", value)) {
2029           W_L(" align=\"");
2030           W_V(value);
2031           W_L("\"");
2032         }
2033         else if (STRCASEEQ('c','C',"center",value)) {
2034           W_L(" align=\"");
2035           W_L("middle");
2036           W_L("\"");
2037         }
2038       }
2039     }
2040     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
2041       /*----------------------------------------------------------------------*/
2042       /* CHTML 1.0                                                            */
2043       /*----------------------------------------------------------------------*/
2044       W_L(" width=\"");
2045       W_V(value);
2046       W_L("\"");
2047     }
2048     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2049       /*----------------------------------------------------------------------*/
2050       /* CHTML 1.0                                                            */
2051       /*----------------------------------------------------------------------*/
2052       W_L(" height=\"");
2053       W_V(value);
2054       W_L("\"");
2055     }
2056     else if (STRCASEEQ('h','H',"hspace",name)) {
2057       /*----------------------------------------------------------------------*/
2058       /* CHTML 1.0                                                            */
2059       /*----------------------------------------------------------------------*/
2060       /* ignore */
2061     }
2062     else if (STRCASEEQ('v','V',"vspace",name)) {
2063       /*----------------------------------------------------------------------*/
2064       /* CHTML 1.0                                                            */
2065       /*----------------------------------------------------------------------*/
2066       /* ignore */
2067     }
2068     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2069       /*----------------------------------------------------------------------*/
2070       /* CHTML 1.0                                                            */
2071       /*----------------------------------------------------------------------*/
2072       W_L(" alt=\"");
2073       W_V(value);
2074       W_L("\"");
2075     }
2076   }
2077   W_L(">");
2078   return jhtml->out;
2079 }
2080
2081
2082 /**
2083  * It is a handler who processes the IMG tag.
2084  *
2085  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2086  *                     destination is specified.
2087  * @param node   [i]   The IMG tag node is specified.
2088  * @return The conversion result is returned.
2089  */
2090 static char *
2091 s_jhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2092 {
2093   jhtml_t *jhtml = GET_JHTML(pdoc);
2094   return jhtml->out;
2095 }
2096
2097
2098 /**
2099  * It is a handler who processes the SELECT tag.
2100  *
2101  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2102  *                     destination is specified.
2103  * @param node   [i]   The SELECT tag node is specified.
2104  * @return The conversion result is returned.
2105  */
2106 static char *
2107 s_jhtml_start_select_tag(void *pdoc, Node *child)
2108 {
2109   jhtml_t *jhtml    = GET_JHTML(pdoc);
2110   Doc     *doc      = jhtml->doc;
2111   Attr    *attr;
2112   char    *size     = NULL;
2113   char    *name     = NULL;
2114   char    *multiple = NULL;
2115
2116   W_L("<select");
2117   for (attr = qs_get_attr(doc,child);
2118        attr;
2119        attr = qs_get_next_attr(doc,attr)) {
2120     char *nm  = qs_get_attr_name(doc,attr);
2121     char *val = qs_get_attr_value(doc,attr);
2122     if (STRCASEEQ('s','S',"size",nm)) {
2123       /*----------------------------------------------------------------------*/
2124       /* CHTML 1.0 version 2.0                                                */
2125       /*----------------------------------------------------------------------*/
2126       size = apr_pstrdup(doc->buf.pool, val);
2127     }
2128     else if (STRCASEEQ('n','N',"name",nm)) {
2129       /*----------------------------------------------------------------------*/
2130       /* CHTML 1.0 version 2.0                                                */
2131       /*----------------------------------------------------------------------*/
2132       name = apr_pstrdup(doc->buf.pool, val);
2133     }
2134     else if (STRCASEEQ('m','M',"multiple", nm)) {
2135       /*----------------------------------------------------------------------*/
2136       /* CHTML 1.0 version 2.0                                                */
2137       /*----------------------------------------------------------------------*/
2138       multiple = apr_pstrdup(doc->buf.pool, val);
2139     }
2140   }
2141   if (size && *size) {
2142     W_L(" size=\"");
2143     W_V(size);
2144     W_L("\"");
2145   }
2146   if (name && *name) {
2147     W_L(" name=\"");
2148     W_V(name);
2149     W_L("\"");
2150   }
2151   if (multiple) {
2152     W_L(" multiple");
2153   }
2154   W_L(">");
2155   return jhtml->out;
2156 }
2157
2158
2159 /**
2160  * It is a handler who processes the SELECT tag.
2161  *
2162  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2163  *                     destination is specified.
2164  * @param node   [i]   The SELECT tag node is specified.
2165  * @return The conversion result is returned.
2166  */
2167 static char *
2168 s_jhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
2169 {
2170   jhtml_t *jhtml = GET_JHTML(pdoc);
2171   Doc     *doc   = jhtml->doc;
2172
2173   W_L("</select>");
2174   return jhtml->out;
2175 }
2176
2177 /**
2178  * It is a handler who processes the OPTION tag.
2179  *
2180  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2181  *                     destination is specified.
2182  * @param node   [i]   The OPTION tag node is specified.
2183  * @return The conversion result is returned.
2184  */
2185 static char *
2186 s_jhtml_start_option_tag(void *pdoc, Node *child)
2187 {
2188   jhtml_t *jhtml = GET_JHTML(pdoc);
2189   Doc     *doc   = jhtml->doc;
2190   Attr    *attr;
2191
2192   char *selected   = NULL;
2193   char *value      = NULL;
2194
2195   W_L("<option");
2196   for (attr = qs_get_attr(doc,child);
2197        attr;
2198        attr = qs_get_next_attr(doc,attr)) {
2199     char *nm  = qs_get_attr_name(doc,attr);
2200     char *val = qs_get_attr_value(doc,attr);
2201     if (STRCASEEQ('s','S',"selected",nm)) {
2202       /*----------------------------------------------------------------------*/
2203       /* CHTML 1.0 version 2.0                                                */
2204       /*----------------------------------------------------------------------*/
2205       selected = apr_pstrdup(doc->buf.pool, val);
2206     }
2207     else if (STRCASEEQ('v','V',"value",nm)) {
2208       /*----------------------------------------------------------------------*/
2209       /* CHTML 1.0 version 2.0                                                */
2210       /*----------------------------------------------------------------------*/
2211       value = apr_pstrdup(doc->buf.pool, val);
2212     }
2213   }
2214   if (value && *value) {
2215     W_L(" value=\"");
2216     W_V(value);
2217     W_L("\"");
2218   }
2219   if (selected) {
2220     W_L(" selected");
2221   }
2222   W_L(">");
2223   return jhtml->out;
2224 }
2225
2226
2227 /**
2228  * It is a handler who processes the OPTION tag.
2229  *
2230  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2231  *                     destination is specified.
2232  * @param node   [i]   The OPTION tag node is specified.
2233  * @return The conversion result is returned.
2234  */
2235 static char *
2236 s_jhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
2237 {
2238   jhtml_t *jhtml = GET_JHTML(pdoc);
2239   /* Don't close */
2240   return jhtml->out;
2241 }
2242
2243
2244 /**
2245  * It is a handler who processes the DIV tag.
2246  *
2247  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2248  *                     destination is specified.
2249  * @param node   [i]   The DIV tag node is specified.
2250  * @return The conversion result is returned.
2251  */
2252 static char *
2253 s_jhtml_start_div_tag(void *pdoc, Node *child)
2254 {
2255   jhtml_t      *jhtml;
2256   Doc          *doc;
2257   request_rec  *r;
2258   Attr         *attr;
2259   char         *align = NULL;
2260
2261   jhtml = GET_JHTML(pdoc);
2262   doc   = jhtml->doc;
2263   r     = doc->r;
2264
2265   W_L("<div");
2266   for (attr = qs_get_attr(doc,child);
2267        attr;
2268        attr = qs_get_next_attr(doc,attr)) {
2269     char *nm  = qs_get_attr_name(doc,attr);
2270     char *val = qs_get_attr_value(doc,attr);
2271     if (STRCASEEQ('a','A',"align",nm)) {
2272       /*----------------------------------------------------------------------*/
2273       /* CHTML 1.0 (W3C version 3.2)                                          */
2274       /*----------------------------------------------------------------------*/
2275       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2276         align = apr_pstrdup(doc->buf.pool, val);
2277       }
2278     }
2279   }
2280   if (align) {
2281     W_L(" align=\"");
2282     W_V(align);
2283     W_L("\"");
2284   }
2285   W_L(">");
2286   return jhtml->out;
2287 }
2288
2289
2290 /**
2291  * It is a handler who processes the DIV tag.
2292  *
2293  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2294  *                     destination is specified.
2295  * @param node   [i]   The DIV tag node is specified.
2296  * @return The conversion result is returned.
2297  */
2298 static char *
2299 s_jhtml_end_div_tag(void *pdoc, Node *UNUSED(child))
2300 {
2301   jhtml_t      *jhtml;
2302   Doc          *doc;
2303   request_rec  *r;
2304
2305   jhtml = GET_JHTML(pdoc);
2306   doc   = jhtml->doc;
2307   r     = doc->r;
2308
2309   W_L("</div>");
2310   return jhtml->out;
2311 }
2312
2313
2314 static char *
2315 chxj_istyle_to_mode(apr_pool_t *p, const char *s)
2316 {
2317   char *tmp;
2318
2319   if (s) {
2320     switch (s[0]) {
2321     case '1': return apr_psprintf(p, "hiragana");
2322     case '2': return apr_psprintf(p, "hankakukana");
2323     case '3': return apr_psprintf(p, "alphabet");
2324     case '4': return apr_psprintf(p, "numeric");
2325     default: 
2326       tmp = apr_palloc(p, 1);
2327       tmp[0] = '\0';
2328       return apr_pstrdup(p, tmp);
2329     }
2330   }
2331
2332   tmp = apr_palloc(p, 1);
2333   tmp[0] = '\0';
2334   return apr_pstrdup(p,tmp);
2335 }
2336
2337
2338 static char *
2339 s_jhtml_chxjif_tag(void *pdoc, Node *node)
2340 {
2341   jhtml_t *jhtml;
2342   Doc     *doc;
2343   Node    *child;
2344   request_rec *r;
2345
2346   jhtml = GET_JHTML(pdoc);
2347   doc   = jhtml->doc;
2348   r     = doc->r;
2349
2350   for (child = qs_get_child_node(doc, node);
2351        child;
2352        child = qs_get_next_node(doc, child)) {
2353     W_V(child->otext);
2354     s_jhtml_chxjif_tag(jhtml, child);
2355   }
2356   return NULL;
2357 }
2358
2359
2360 /**
2361  * It is a handler who processes the TEXTARE 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 TEXTAREA tag node is specified.
2366  * @return The conversion result is returned.
2367  */
2368 static char *
2369 s_jhtml_start_textarea_tag(void *pdoc, Node *node) 
2370 {
2371   jhtml_t       *jhtml;
2372   Doc           *doc;
2373   request_rec   *r;
2374   Attr          *attr;
2375
2376   jhtml = GET_JHTML(pdoc);
2377   doc   = jhtml->doc;
2378   r     = doc->r;
2379
2380   jhtml->textarea_flag++;
2381   W_L("<textarea");
2382   for (attr = qs_get_attr(doc,node);
2383        attr;
2384        attr = qs_get_next_attr(doc,attr)) {
2385     char *name  = qs_get_attr_name(doc,attr);
2386     char *value = qs_get_attr_value(doc,attr);
2387     if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
2388       W_L(" accesskey=\"");
2389       W_V(value);
2390       W_L("\"");
2391     }
2392     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
2393       char *vv = chxj_istyle_to_mode(doc->buf.pool,value);
2394       W_L(" mode=\"");
2395       W_V(vv);
2396       W_L("\"");
2397     }
2398     else if (STRCASEEQ('n','N',"name", name) && value && *value) {
2399       W_L(" name=\"");
2400       W_V(value);
2401       W_L("\"");
2402     }
2403     else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
2404       W_L(" rows=\"");
2405       W_V(value);
2406       W_L("\"");
2407     }
2408     else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
2409       W_L(" cols=\"");
2410       W_V(value);
2411       W_L("\"");
2412     }
2413   }
2414   W_L(">");
2415   return jhtml->out;
2416 }
2417
2418
2419 /**
2420  * It is a handler who processes the TEXTAREA tag.
2421  *
2422  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2423  *                     destination is specified.
2424  * @param node   [i]   The TEXTAREA tag node is specified.
2425  * @return The conversion result is returned.
2426  */
2427 static char *
2428 s_jhtml_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
2429 {
2430   jhtml_t       *jhtml;
2431   Doc           *doc;
2432   request_rec   *r;
2433
2434   jhtml = GET_JHTML(pdoc);
2435   doc   = jhtml->doc;
2436   r     = doc->r;
2437
2438   W_L("</textarea>");
2439   jhtml->textarea_flag--;
2440
2441   return jhtml->out;
2442 }
2443
2444
2445 /**
2446  * It is a handler who processes the B tag.
2447  *
2448  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2449  *                     destination is specified.
2450  * @param node   [i]   The B tag node is specified.
2451  * @return The conversion result is returned.
2452  */
2453 static char*
2454 s_jhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
2455 {
2456   jhtml_t*      jhtml;
2457   Doc*          doc;
2458   request_rec*  r;
2459
2460   jhtml = GET_JHTML(pdoc);
2461   doc   = jhtml->doc;
2462   r     = doc->r;
2463
2464   W_L("<b>");
2465   return jhtml->out;
2466 }
2467
2468
2469 /**
2470  * It is a handler who processes the B tag.
2471  *
2472  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2473  *                     destination is specified.
2474  * @param node   [i]   The B tag node is specified.
2475  * @return The conversion result is returned.
2476  */
2477 static char*
2478 s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
2479 {
2480   jhtml_t*      jhtml = GET_JHTML(pdoc);
2481   Doc*          doc   = jhtml->doc;
2482
2483   W_L("</b>");
2484   return jhtml->out;
2485 }
2486
2487 static char*
2488 s_jhtml_text_tag(void* pdoc, Node* child)
2489 {
2490   jhtml_t*     jhtml;
2491   Doc*         doc;
2492   char*        textval;
2493   char*        tmp;
2494   char*        tdst;
2495   char         one_byte[2];
2496   int          ii;
2497   int          tdst_len;
2498   request_rec* r;
2499
2500   jhtml = GET_JHTML(pdoc);
2501   doc   = jhtml->doc;
2502   r     = doc->r;
2503
2504   textval = qs_get_node_value(doc,child);
2505   if (strlen(textval) == 0) {
2506     return jhtml->out;
2507   }
2508
2509   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2510   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2511
2512   tdst     = qs_alloc_zero_byte_string(r->pool);
2513   memset(one_byte, 0, sizeof(one_byte));
2514   tdst_len = 0;
2515
2516   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2517     char* out;
2518     int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
2519     if (rtn) {
2520       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2521       ii+=(rtn - 1);
2522       continue;
2523     }
2524
2525     if (is_sjis_kanji(textval[ii])) {
2526       one_byte[0] = textval[ii+0];
2527       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2528       one_byte[0] = textval[ii+1];
2529       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2530       ii++;
2531     }
2532     else 
2533     if (jhtml->pre_flag) {
2534       one_byte[0] = textval[ii+0];
2535       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2536     }
2537     else
2538     if (jhtml->textarea_flag) {
2539       one_byte[0] = textval[ii+0];
2540       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2541     }
2542     else {
2543       if (textval[ii] != '\r' && textval[ii] != '\n') {
2544         one_byte[0] = textval[ii+0];
2545         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2546       }
2547     }
2548   }
2549   W_V(tdst);
2550   return jhtml->out;
2551 }
2552
2553
2554 /**
2555  * It is a handler who processes the BLOCKQUOTE tag.
2556  *
2557  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2558  *                     destination is specified.
2559  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2560  * @return The conversion result is returned.
2561  */
2562 static char *
2563 s_jhtml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
2564 {
2565   jhtml_t *jhtml = GET_JHTML(pdoc);
2566   Doc     *doc   = jhtml->doc;
2567   W_L("<blockquote>");
2568   return jhtml->out;
2569 }
2570
2571
2572 /**
2573  * It is a handler who processes the BLOCKQUOTE tag.
2574  *
2575  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2576  *                     destination is specified.
2577  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2578  * @return The conversion result is returned.
2579  */
2580 static char *
2581 s_jhtml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
2582 {
2583   jhtml_t *jhtml = GET_JHTML(pdoc);
2584   Doc     *doc   = jhtml->doc;
2585   W_L("</blockquote>");
2586   return jhtml->out;
2587 }
2588
2589
2590 /**
2591  * It is a handler who processes the DIR tag.
2592  *
2593  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2594  *                     destination is specified.
2595  * @param node   [i]   The DIR tag node is specified.
2596  * @return The conversion result is returned.
2597  */
2598 static char *
2599 s_jhtml_start_dir_tag(void *pdoc, Node *UNUSED(child))
2600 {
2601   jhtml_t *jhtml = GET_JHTML(pdoc);
2602   Doc *doc = jhtml->doc;
2603   W_L("<dir>");
2604   return jhtml->out;
2605 }
2606
2607
2608 /**
2609  * It is a handler who processes the DIR tag.
2610  *
2611  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2612  *                     destination is specified.
2613  * @param node   [i]   The DIR tag node is specified.
2614  * @return The conversion result is returned.
2615  */
2616 static char *
2617 s_jhtml_end_dir_tag(void *pdoc, Node *UNUSED(child))
2618 {
2619   jhtml_t *jhtml = GET_JHTML(pdoc);
2620   Doc *doc = jhtml->doc;
2621   W_L("</dir>");
2622   return jhtml->out;
2623 }
2624
2625
2626 /**
2627  * It is a handler who processes the DL tag.
2628  *
2629  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2630  *                     destination is specified.
2631  * @param node   [i]   The DL tag node is specified.
2632  * @return The conversion result is returned.
2633  */
2634 static char *
2635 s_jhtml_start_dl_tag(void *pdoc, Node *UNUSED(child))
2636 {
2637   jhtml_t *jhtml = GET_JHTML(pdoc);
2638   Doc *doc = jhtml->doc;
2639   W_L("<dl>");
2640   return jhtml->out;
2641 }
2642
2643
2644 /**
2645  * It is a handler who processes the DL tag.
2646  *
2647  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2648  *                     destination is specified.
2649  * @param node   [i]   The DL tag node is specified.
2650  * @return The conversion result is returned.
2651  */
2652 static char *
2653 s_jhtml_end_dl_tag(void *pdoc, Node *UNUSED(child))
2654 {
2655   jhtml_t *jhtml = GET_JHTML(pdoc);
2656   Doc *doc = jhtml->doc;
2657   W_L("</dl>");
2658   return jhtml->out;
2659 }
2660
2661
2662 /**
2663  * It is a handler who processes the DT tag.
2664  *
2665  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2666  *                     destination is specified.
2667  * @param node   [i]   The DT tag node is specified.
2668  * @return The conversion result is returned.
2669  */
2670 static char *
2671 s_jhtml_start_dt_tag(void *pdoc, Node *UNUSED(child))
2672 {
2673   jhtml_t *jhtml = GET_JHTML(pdoc);
2674   Doc     *doc   = jhtml->doc;
2675   W_L("<dt>");
2676   return jhtml->out;
2677 }
2678
2679
2680 /**
2681  * It is a handler who processes the DT tag.
2682  *
2683  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2684  *                     destination is specified.
2685  * @param node   [i]   The DT tag node is specified.
2686  * @return The conversion result is returned.
2687  */
2688 static char *
2689 s_jhtml_end_dt_tag(void *pdoc, Node *UNUSED(child))
2690 {
2691   jhtml_t *jhtml = GET_JHTML(pdoc);
2692   return jhtml->out;
2693 }
2694
2695
2696 /**
2697  * It is a handler who processes the DD tag.
2698  *
2699  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2700  *                     destination is specified.
2701  * @param node   [i]   The DD tag node is specified.
2702  * @return The conversion result is returned.
2703  */
2704 static char *
2705 s_jhtml_start_dd_tag(void *pdoc, Node *UNUSED(child))
2706 {
2707   jhtml_t *jhtml = GET_JHTML(pdoc);
2708   Doc *doc = jhtml->doc;
2709   W_L("<dd>");
2710   return jhtml->out;
2711 }
2712
2713
2714 /**
2715  * It is a handler who processes the DD tag.
2716  *
2717  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2718  *                     destination is specified.
2719  * @param node   [i]   The DD tag node is specified.
2720  * @return The conversion result is returned.
2721  */
2722 static char *
2723 s_jhtml_end_dd_tag(void *pdoc, Node *UNUSED(child))
2724 {
2725   jhtml_t *jhtml = GET_JHTML(pdoc);
2726   return jhtml->out;
2727 }
2728
2729
2730 /**
2731  * It is a handler who processes the H1 tag.
2732  *
2733  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2734  *                     destination is specified.
2735  * @param node   [i]   The H1 tag node is specified.
2736  * @return The conversion result is returned.
2737  */
2738 static char *
2739 s_jhtml_start_h1_tag(void *pdoc, Node *node)
2740 {
2741   jhtml_t       *jhtml;
2742   Doc           *doc;
2743   request_rec   *r;
2744   Attr          *attr;
2745   char          *align = NULL;
2746
2747   jhtml   = GET_JHTML(pdoc);
2748   doc     = jhtml->doc;
2749   r       = doc->r;
2750
2751   for (attr = qs_get_attr(doc,node);
2752        attr;
2753        attr = qs_get_next_attr(doc,attr)) {
2754     char *name  = qs_get_attr_name(doc,attr);
2755     char *value = qs_get_attr_value(doc,attr);
2756     if (STRCASEEQ('a','A',"align", name)) {
2757       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2758         jhtml->h1_align_flag++;
2759         align = apr_pstrdup(doc->buf.pool, value);
2760         break;
2761       }
2762     }
2763   }
2764   if (align) {
2765     W_L("<div align=\"");
2766     W_V(align);
2767     W_L("\">");
2768   }
2769   return jhtml->out;
2770 }
2771
2772
2773 /**
2774  * It is a handler who processes the H1 tag.
2775  *
2776  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2777  *                     destination is specified.
2778  * @param node   [i]   The H1 tag node is specified.
2779  * @return The conversion result is returned.
2780  */
2781 static char *
2782 s_jhtml_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2783 {
2784   jhtml_t*    jhtml;
2785   Doc*          doc;
2786   request_rec*  r;
2787
2788   jhtml = GET_JHTML(pdoc);
2789   doc     = jhtml->doc;
2790   r       = doc->r;
2791   
2792   if (jhtml->h1_align_flag) {
2793     jhtml->h1_align_flag--;
2794     W_L("</div>");
2795   }
2796   return jhtml->out;
2797 }
2798
2799
2800 /**
2801  * It is a handler who processes the H2 tag.
2802  *
2803  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2804  *                     destination is specified.
2805  * @param node   [i]   The H1 tag node is specified.
2806  * @return The conversion result is returned.
2807  */
2808 static char *
2809 s_jhtml_start_h2_tag(void *pdoc, Node *node)
2810 {
2811   jhtml_t       *jhtml;
2812   Doc           *doc;
2813   request_rec   *r;
2814   Attr          *attr;
2815   char          *align = NULL;
2816
2817   jhtml   = GET_JHTML(pdoc);
2818   doc     = jhtml->doc;
2819   r       = doc->r;
2820
2821   for (attr = qs_get_attr(doc,node);
2822        attr;
2823        attr = qs_get_next_attr(doc,attr)) {
2824     char* name;
2825     char* value;
2826     name  = qs_get_attr_name(doc,attr);
2827     value = qs_get_attr_value(doc,attr);
2828     if (STRCASEEQ('a','A',"align", name)) {
2829       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2830         jhtml->h2_align_flag++;
2831         align = apr_pstrdup(doc->buf.pool, value);
2832         break;
2833       }
2834     }
2835   }
2836   if (align) {
2837     W_L("<div align=\"");
2838     W_V(align);
2839     W_L("\">");
2840   }
2841   return jhtml->out;
2842 }
2843
2844
2845 /**
2846  * It is a handler who processes the H2 tag.
2847  *
2848  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2849  *                     destination is specified.
2850  * @param node   [i]   The H1 tag node is specified.
2851  * @return The conversion result is returned.
2852  */
2853 static char *
2854 s_jhtml_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2855 {
2856   jhtml_t*    jhtml;
2857   Doc*          doc;
2858   request_rec*  r;
2859
2860   jhtml = GET_JHTML(pdoc);
2861   doc     = jhtml->doc;
2862   r       = doc->r;
2863   
2864   if (jhtml->h2_align_flag) {
2865     jhtml->h2_align_flag--;
2866     W_L("</div>");
2867   }
2868   return jhtml->out;
2869 }
2870
2871
2872 /**
2873  * It is a handler who processes the H3 tag.
2874  *
2875  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2876  *                     destination is specified.
2877  * @param node   [i]   The H1 tag node is specified.
2878  * @return The conversion result is returned.
2879  */
2880 static char *
2881 s_jhtml_start_h3_tag(void *pdoc, Node *node)
2882 {
2883   jhtml_t       *jhtml;
2884   Doc           *doc;
2885   request_rec   *r;
2886   Attr          *attr;
2887   char          *align = NULL;
2888
2889   jhtml   = GET_JHTML(pdoc);
2890   doc     = jhtml->doc;
2891   r       = doc->r;
2892
2893   for (attr = qs_get_attr(doc,node);
2894        attr;
2895        attr = qs_get_next_attr(doc,attr)) {
2896     char* name;
2897     char* value;
2898     name  = qs_get_attr_name(doc,attr);
2899     value = qs_get_attr_value(doc,attr);
2900     if (STRCASEEQ('a','A',"align", name)) {
2901       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2902         jhtml->h3_align_flag++;
2903         align = apr_pstrdup(doc->buf.pool, value);
2904         break;
2905       }
2906     }
2907   }
2908   if (align) {
2909     W_L("<div align=\"");
2910     W_V(align);
2911     W_L("\">");
2912   }
2913   return jhtml->out;
2914 }
2915
2916
2917 /**
2918  * It is a handler who processes the H3 tag.
2919  *
2920  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2921  *                     destination is specified.
2922  * @param node   [i]   The H1 tag node is specified.
2923  * @return The conversion result is returned.
2924  */
2925 static char *
2926 s_jhtml_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2927 {
2928   jhtml_t*    jhtml;
2929   Doc*          doc;
2930   request_rec*  r;
2931
2932   jhtml = GET_JHTML(pdoc);
2933   doc     = jhtml->doc;
2934   r       = doc->r;
2935   
2936   if (jhtml->h3_align_flag) {
2937     jhtml->h3_align_flag--;
2938     W_L("</div>");
2939   }
2940   return jhtml->out;
2941 }
2942
2943
2944 /**
2945  * It is a handler who processes the H4 tag.
2946  *
2947  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2948  *                     destination is specified.
2949  * @param node   [i]   The H1 tag node is specified.
2950  * @return The conversion result is returned.
2951  */
2952 static char *
2953 s_jhtml_start_h4_tag(void *pdoc, Node *node)
2954 {
2955   jhtml_t       *jhtml;
2956   Doc           *doc;
2957   request_rec   *r;
2958   Attr          *attr;
2959   char          *align = NULL;
2960
2961   jhtml   = GET_JHTML(pdoc);
2962   doc     = jhtml->doc;
2963   r       = doc->r;
2964
2965   for (attr = qs_get_attr(doc,node);
2966        attr;
2967        attr = qs_get_next_attr(doc,attr)) {
2968     char *name  = qs_get_attr_name(doc,attr);
2969     char *value = qs_get_attr_value(doc,attr);
2970     if (STRCASEEQ('a','A',"align", name)) {
2971       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2972         jhtml->h4_align_flag++;
2973         align = apr_pstrdup(doc->buf.pool, value);
2974         break;
2975       }
2976     }
2977   }
2978   if (align) {
2979     W_L("<div align=\"");
2980     W_V(align);
2981     W_L("\">");
2982   }
2983   return jhtml->out;
2984 }
2985
2986
2987 /**
2988  * It is a handler who processes the H4 tag.
2989  *
2990  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2991  *                     destination is specified.
2992  * @param node   [i]   The H1 tag node is specified.
2993  * @return The conversion result is returned.
2994  */
2995 static char *
2996 s_jhtml_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2997 {
2998   jhtml_t      *jhtml;
2999   Doc          *doc;
3000   request_rec  *r;
3001
3002   jhtml = GET_JHTML(pdoc);
3003   doc     = jhtml->doc;
3004   r       = doc->r;
3005   
3006   if (jhtml->h4_align_flag) {
3007     jhtml->h4_align_flag--;
3008     W_L("</div>");
3009   }
3010   return jhtml->out;
3011 }
3012
3013
3014 /**
3015  * It is a handler who processes the H5 tag.
3016  *
3017  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3018  *                     destination is specified.
3019  * @param node   [i]   The H1 tag node is specified.
3020  * @return The conversion result is returned.
3021  */
3022 static char *
3023 s_jhtml_start_h5_tag(void *pdoc, Node *node)
3024 {
3025   jhtml_t       *jhtml;
3026   Doc           *doc;
3027   request_rec   *r;
3028   Attr          *attr;
3029   char          *align = NULL;
3030
3031   jhtml   = GET_JHTML(pdoc);
3032   doc     = jhtml->doc;
3033   r       = doc->r;
3034
3035   for (attr = qs_get_attr(doc,node);
3036        attr;
3037        attr = qs_get_next_attr(doc,attr)) {
3038     char *name  = qs_get_attr_name(doc,attr);
3039     char *value = qs_get_attr_value(doc,attr);
3040     if (STRCASEEQ('a','A',"align", name)) {
3041       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3042         jhtml->h5_align_flag++;
3043         align = apr_pstrdup(doc->buf.pool, value);
3044         break;
3045       }
3046     }
3047   }
3048   if (align) {
3049     W_L("<div align=\"");
3050     W_V(align);
3051     W_L("\">");
3052   }
3053   return jhtml->out;
3054 }
3055
3056
3057 /**
3058  * It is a handler who processes the H5 tag.
3059  *
3060  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3061  *                     destination is specified.
3062  * @param node   [i]   The H1 tag node is specified.
3063  * @return The conversion result is returned.
3064  */
3065 static char *
3066 s_jhtml_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
3067 {
3068   jhtml_t*    jhtml;
3069   Doc*          doc;
3070   request_rec*  r;
3071
3072   jhtml = GET_JHTML(pdoc);
3073   doc     = jhtml->doc;
3074   r       = doc->r;
3075   
3076   if (jhtml->h5_align_flag) {
3077     jhtml->h5_align_flag--;
3078     W_L("</div>");
3079   }
3080   return jhtml->out;
3081 }
3082
3083
3084 /**
3085  * It is a handler who processes the H6 tag.
3086  *
3087  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3088  *                     destination is specified.
3089  * @param node   [i]   The H1 tag node is specified.
3090  * @return The conversion result is returned.
3091  */
3092 static char *
3093 s_jhtml_start_h6_tag(void *pdoc, Node *node)
3094 {
3095   jhtml_t       *jhtml;
3096   Doc           *doc;
3097   request_rec   *r;
3098   Attr          *attr;
3099   char          *align = NULL;
3100
3101   jhtml   = GET_JHTML(pdoc);
3102   doc     = jhtml->doc;
3103   r       = doc->r;
3104
3105   for (attr = qs_get_attr(doc,node);
3106        attr;
3107        attr = qs_get_next_attr(doc,attr)) {
3108     char *name  = qs_get_attr_name(doc,attr);
3109     char *value = qs_get_attr_value(doc,attr);
3110     if (STRCASEEQ('a','A',"align", name)) {
3111       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3112         jhtml->h6_align_flag++;
3113         align = apr_pstrdup(doc->buf.pool, value);
3114         break;
3115       }
3116     }
3117   }
3118   if (align) {
3119     W_L("<div align=\"");
3120     W_V(align);
3121     W_L("\">");
3122   }
3123   return jhtml->out;
3124 }
3125
3126
3127 /**
3128  * It is a handler who processes the H6 tag.
3129  *
3130  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3131  *                     destination is specified.
3132  * @param node   [i]   The H1 tag node is specified.
3133  * @return The conversion result is returned.
3134  */
3135 static char *
3136 s_jhtml_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
3137 {
3138   jhtml_t     *jhtml;
3139   Doc         *doc;
3140   request_rec *r;
3141
3142   jhtml = GET_JHTML(pdoc);
3143   doc     = jhtml->doc;
3144   r       = doc->r;
3145   
3146   if (jhtml->h6_align_flag) {
3147     jhtml->h6_align_flag--;
3148     W_L("</div>");
3149   }
3150   return jhtml->out;
3151 }
3152
3153
3154 /**
3155  * It is a handler who processes the MENU tag.
3156  *
3157  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3158  *                     destination is specified.
3159  * @param node   [i]   The MENU tag node is specified.
3160  * @return The conversion result is returned.
3161  */
3162 static char *
3163 s_jhtml_start_menu_tag(void *pdoc, Node *UNUSED(child))
3164 {
3165   jhtml_t *jhtml = GET_JHTML(pdoc);
3166   Doc     *doc = jhtml->doc;
3167   W_L("<menu>");
3168   return jhtml->out;
3169 }
3170
3171
3172 /**
3173  * It is a handler who processes the MENU tag.
3174  *
3175  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3176  *                     destination is specified.
3177  * @param node   [i]   The MENU tag node is specified.
3178  * @return The conversion result is returned.
3179  */
3180 static char *
3181 s_jhtml_end_menu_tag(void *pdoc, Node *UNUSED(child))
3182 {
3183   jhtml_t *jhtml = GET_JHTML(pdoc);
3184   Doc     *doc = jhtml->doc;
3185   W_L("</menu>");
3186   return jhtml->out;
3187 }
3188
3189
3190 /**
3191  * It is a handler who processes the PLAINTEXT tag.
3192  *
3193  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3194  *                     destination is specified.
3195  * @param node   [i]   The PLAINTEXT tag node is specified.
3196  * @return The conversion result is returned.
3197  */
3198 static char *
3199 s_jhtml_start_plaintext_tag(void *pdoc, Node *node)
3200 {
3201   jhtml_t *jhtml;
3202   Doc *doc;
3203
3204   jhtml = GET_JHTML(pdoc);
3205   doc     = jhtml->doc;
3206   W_L("<plaintext>");
3207   s_jhtml_start_plaintext_tag_inner(pdoc,node);
3208   return jhtml->out;
3209 }
3210
3211 static char *
3212 s_jhtml_start_plaintext_tag_inner(void *pdoc, Node *node)
3213 {
3214   jhtml_t *jhtml;
3215   Doc *doc;
3216   Node *child;
3217   jhtml = GET_JHTML(pdoc);
3218   doc     = jhtml->doc;
3219   for (child = qs_get_child_node(doc, node);
3220        child;
3221        child = qs_get_next_node(doc, child)) {
3222     W_V(child->otext);
3223     s_jhtml_start_plaintext_tag_inner(pdoc, child);
3224   }
3225   return jhtml->out;
3226 }
3227
3228
3229 /**
3230  * It is a handler who processes the PLAINTEXT tag.
3231  *
3232  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3233  *                     destination is specified.
3234  * @param node   [i]   The PLAINTEXT tag node is specified.
3235  * @return The conversion result is returned.
3236  */
3237 static char *
3238 s_jhtml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3239 {
3240   jhtml_t *jhtml = GET_JHTML(pdoc);
3241   return jhtml->out;
3242 }
3243
3244
3245 /**
3246  * It is a handler who processes the BLINK tag.
3247  *
3248  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3249  *                     destination is specified.
3250  * @param node   [i]   The BLINK tag node is specified.
3251  * @return The conversion result is returned.
3252  */
3253 static char *
3254 s_jhtml_start_blink_tag(void *pdoc, Node *UNUSED(child))
3255 {
3256   jhtml_t *jhtml = GET_JHTML(pdoc);
3257   Doc     *doc = jhtml->doc;
3258   W_L("<blink>");
3259   return jhtml->out;
3260 }
3261
3262
3263 /**
3264  * It is a handler who processes the BLINK tag.
3265  *
3266  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3267  *                     destination is specified.
3268  * @param node   [i]   The BLINK tag node is specified.
3269  * @return The conversion result is returned.
3270  */
3271 static char *
3272 s_jhtml_end_blink_tag(void *pdoc, Node *UNUSED(child))
3273 {
3274   jhtml_t *jhtml = GET_JHTML(pdoc);
3275   Doc     *doc = jhtml->doc;
3276   W_L("</blink>");
3277   return jhtml->out;
3278 }
3279
3280
3281 /**
3282  * It is a handler who processes the MARQUEE tag.
3283  *
3284  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3285  *                     destination is specified.
3286  * @param node   [i]   The MARQUEE tag node is specified.
3287  * @return The conversion result is returned.
3288  */
3289 static char *
3290 s_jhtml_start_marquee_tag(void *pdoc, Node *node)
3291 {
3292   jhtml_t *jhtml = GET_JHTML(pdoc);
3293   Doc *doc = jhtml->doc;
3294   Attr *attr;
3295   W_L("<marquee");
3296   /*--------------------------------------------------------------------------*/
3297   /* Get Attributes                                                           */
3298   /*--------------------------------------------------------------------------*/
3299   for (attr = qs_get_attr(doc,node);
3300        attr;
3301        attr = qs_get_next_attr(doc,attr)) {
3302     char *name   = qs_get_attr_name(doc,attr);
3303     char *value  = qs_get_attr_value(doc,attr);
3304     if (STRCASEEQ('d','D',"direction", name)) {
3305       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3306         W_L(" direction=\"");
3307         W_V(value);
3308         W_L("\"");
3309       }
3310     }
3311     else if (STRCASEEQ('b','B',"behavior",name)) {
3312       /* ignore */
3313     }
3314     else if (STRCASEEQ('l','L',"loop",name)) {
3315       /* ignore */
3316     }
3317   }
3318   W_L(">");
3319   return jhtml->out;
3320 }
3321
3322
3323 /**
3324  * It is a handler who processes the MARQUEE tag.
3325  *
3326  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3327  *                     destination is specified.
3328  * @param node   [i]   The MARQUEE tag node is specified.
3329  * @return The conversion result is returned.
3330  */
3331 static char *
3332 s_jhtml_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3333 {
3334   jhtml_t *jhtml = GET_JHTML(pdoc);
3335   Doc *doc = jhtml->doc;
3336   W_L("</marquee>");
3337   return jhtml->out;
3338 }
3339
3340
3341 /**
3342  * It is handler who processes the New Line Code.
3343  */
3344 static char *
3345 s_jhtml_newline_mark(void *pdoc, Node *UNUSED(node))
3346 {
3347   jhtml_t *jhtml = GET_JHTML(pdoc);
3348   Doc *doc = jhtml->doc;
3349   W_NLCODE();
3350   return jhtml->out;
3351 }
3352 /*
3353  * vim:ts=2 et
3354  */