OSDN Git Service

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