OSDN Git Service

* Added features.
[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     else if (STRCASEEQ('n','N',"name",name)) {
1384       W_L(" name=\"");
1385       W_V(value);
1386       W_L("\"");
1387     }
1388   }
1389   W_L(">");
1390   /*-------------------------------------------------------------------------*/
1391   /* ``action=""''                                                           */
1392   /*-------------------------------------------------------------------------*/
1393   if (! dc) {
1394     dcflag = 1;
1395   }
1396   /*-------------------------------------------------------------------------*/
1397   /* Add cookie parameter                                                    */
1398   /*-------------------------------------------------------------------------*/
1399   if (jhtml->cookie && jhtml->cookie->cookie_id && dcflag == 1) {
1400     char *vv = apr_psprintf(doc->buf.pool, "<input type='hidden' name='%s' value='%s'>",
1401                             CHXJ_COOKIE_PARAM,
1402                             chxj_url_decode(r, jhtml->cookie->cookie_id));
1403     W_V(vv);
1404   }
1405   return jhtml->out;
1406 }
1407
1408
1409 /**
1410  * It is a handler who processes the FORM tag.
1411  *
1412  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1413  *                     destination is specified.
1414  * @param node   [i]   The FORM tag node is specified.
1415  * @return The conversion result is returned.
1416  */
1417 static char *
1418 s_jhtml_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1419 {
1420   jhtml_t *jhtml = GET_JHTML(pdoc);
1421   Doc     *doc   = jhtml->doc;
1422   W_L("</form>");
1423   return jhtml->out;
1424 }
1425
1426
1427 /**
1428  * It is a handler who processes the INPUT tag.
1429  *
1430  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1431  *                     destination is specified.
1432  * @param node   [i]   The INPUT tag node is specified.
1433  * @return The conversion result is returned.
1434  */
1435 static char *
1436 s_jhtml_start_input_tag(void *pdoc, Node *node) 
1437 {
1438   jhtml_t       *jhtml;
1439   Doc           *doc;
1440   request_rec   *r;
1441   char          *max_length;
1442   char          *type;
1443   char          *name;
1444   char          *value;
1445   char          *istyle;
1446   char          *size;
1447   char          *checked;
1448   char          *accesskey;
1449
1450   jhtml       = GET_JHTML(pdoc);
1451   doc         = jhtml->doc;
1452   r           = doc->r;
1453   max_length  = NULL;
1454   type        = NULL;
1455   name        = NULL;
1456   value       = NULL;
1457   istyle      = NULL;
1458   size        = NULL;
1459   checked     = NULL;
1460   accesskey   = NULL;
1461
1462   W_L("<input");
1463   /*--------------------------------------------------------------------------*/
1464   /* Get Attributes                                                           */
1465   /*--------------------------------------------------------------------------*/
1466   type       = qs_get_type_attr(doc, node, r);
1467   name       = qs_get_name_attr(doc, node, r);
1468   value      = qs_get_value_attr(doc,node,r);
1469   istyle     = qs_get_istyle_attr(doc,node,r);
1470   max_length = qs_get_maxlength_attr(doc,node,r);
1471   checked    = qs_get_checked_attr(doc,node,r);
1472   accesskey  = qs_get_accesskey_attr(doc, node, r);
1473   size       = qs_get_size_attr(doc, node, r);
1474
1475   if (type) {
1476     if (type && (STRCASEEQ('t','T',"text",    type) ||
1477                  STRCASEEQ('p','P',"password",type) ||
1478                  STRCASEEQ('c','C',"checkbox",type) ||
1479                  STRCASEEQ('r','R',"radio",   type) ||
1480                  STRCASEEQ('h','H',"hidden",  type) ||
1481                  STRCASEEQ('s','S',"submit",  type) ||
1482                  STRCASEEQ('r','R',"reset",   type))) {
1483       W_L(" type=\"");
1484       W_V(type);
1485       W_L("\"");
1486     }
1487   }
1488   if (size && *size) {
1489     W_L(" size=\"");
1490     W_V(size);
1491     W_L("\"");
1492   }
1493   if (name && *name) {
1494     W_L(" name=\"");
1495     W_V(name);
1496     W_L("\"");
1497   }
1498   if (value && *value) {
1499     W_L(" value=\"");
1500     W_V(chxj_add_slash_to_doublequote(doc->pool,value));
1501     W_L("\"");
1502   }
1503   if (accesskey && *accesskey) {
1504     W_L(" accesskey=\"");
1505     W_V(accesskey);
1506     W_L("\"");
1507   }
1508   if (istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1509     /*------------------------------------------------------------------------*/
1510     /* CHTML 2.0                                                              */
1511     /*------------------------------------------------------------------------*/
1512     if (type && STRCASEEQ('p','P',"password", type) && ! jhtml->entryp->pc_flag ) {
1513       W_L(" mode=\"");
1514       W_L("numeric");
1515       W_L("\"");
1516     }
1517     else {
1518       char *vv = chxj_istyle_to_mode(doc->buf.pool,istyle);
1519       W_L(" mode=\"");
1520       W_V(vv);
1521       W_L("\"");
1522     }
1523   }
1524   else if (type && STRCASEEQ('p','P',"password",type)) {
1525     W_L(" mode=\"");
1526     W_L("numeric");
1527     W_L("\"");
1528   }
1529   /*--------------------------------------------------------------------------*/
1530   /* The figure is default for the password.                                  */
1531   /*--------------------------------------------------------------------------*/
1532   if (max_length && *max_length) {
1533     if (chxj_chk_numeric(max_length) == 0) {
1534       W_L(" maxlength=\"");
1535       W_V(max_length);
1536       W_L("\"");
1537     }
1538   }
1539
1540   if (checked) {
1541     W_L(" checked");
1542   }
1543   W_L(">");
1544   return jhtml->out;
1545 }
1546
1547
1548 /**
1549  * It is a handler who processes the INPUT tag.
1550  *
1551  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1552  *                     destination is specified.
1553  * @param node   [i]   The INPUT tag node is specified.
1554  * @return The conversion result is returned.
1555  */
1556 static char *
1557 s_jhtml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1558 {
1559   jhtml_t *jhtml = GET_JHTML(pdoc);
1560   return jhtml->out;
1561 }
1562
1563
1564 /**
1565  * It is a handler who processes the CENTER tag.
1566  *
1567  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1568  *                     destination is specified.
1569  * @param node   [i]   The CENTER tag node is specified.
1570  * @return The conversion result is returned.
1571  */
1572 static char *
1573 s_jhtml_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1574 {
1575   jhtml_t *jhtml = GET_JHTML(pdoc);
1576   Doc     *doc   = jhtml->doc;
1577   W_L("<center>");
1578   return jhtml->out;
1579 }
1580
1581
1582 /**
1583  * It is a handler who processes the CENTER tag.
1584  *
1585  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1586  *                     destination is specified.
1587  * @param node   [i]   The CENTER tag node is specified.
1588  * @return The conversion result is returned.
1589  */
1590 static char *
1591 s_jhtml_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1592 {
1593   jhtml_t     *jhtml;
1594   Doc         *doc;
1595   request_rec *r;
1596
1597   jhtml = GET_JHTML(pdoc);
1598   doc   = jhtml->doc;
1599   r     = doc->r;
1600
1601   W_L("</center>");
1602   return jhtml->out;
1603 }
1604
1605
1606 /**
1607  * It is a handler who processes the li tag.
1608  *
1609  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1610  *                     destination is specified.
1611  * @param node   [i]   The li tag node is specified.
1612  * @return The conversion result is returned.
1613  */
1614 static char *
1615 s_jhtml_start_li_tag(void *pdoc, Node *node)
1616 {
1617   jhtml_t       *jhtml;
1618   Doc           *doc;
1619   request_rec   *r;
1620   Attr          *attr;
1621
1622   jhtml = GET_JHTML(pdoc);
1623   doc   = jhtml->doc;
1624   r     = doc->r;
1625
1626   W_L("<li");
1627   /*--------------------------------------------------------------------------*/
1628   /* Get Attributes                                                           */
1629   /*--------------------------------------------------------------------------*/
1630   for (attr = qs_get_attr(doc,node);
1631        attr;
1632        attr = qs_get_next_attr(doc,attr)) {
1633     char *name = qs_get_attr_name(doc,attr);
1634     char *value = qs_get_attr_value(doc,attr);
1635     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1636       W_L(" type=\"");
1637       W_V(value);
1638       W_L("\"");
1639     }
1640     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1641       W_L(" value=\"");
1642       W_V(value);
1643       W_L("\"");
1644     }
1645   }
1646   W_L(">");
1647   return jhtml->out;
1648 }
1649
1650
1651 /**
1652  * It is a handler who processes the li tag.
1653  *
1654  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1655  *                     destination is specified.
1656  * @param node   [i]   The li tag node is specified.
1657  * @return The conversion result is returned.
1658  */
1659 static char *
1660 s_jhtml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
1661 {
1662   jhtml_t     *jhtml;
1663   Doc         *doc;
1664   request_rec *r;
1665
1666   jhtml = GET_JHTML(pdoc);
1667   doc   = jhtml->doc;
1668   r     = doc->r;
1669
1670   W_L("</li>");
1671   return jhtml->out;
1672 }
1673
1674
1675 /**
1676  * It is a handler who processes the OL tag.
1677  *
1678  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1679  *                     destination is specified.
1680  * @param node   [i]   The OL tag node is specified.
1681  * @return The conversion result is returned.
1682  */
1683 static char *
1684 s_jhtml_start_ol_tag(void *pdoc, Node *node)
1685 {
1686   jhtml_t     *jhtml;
1687   Doc         *doc;
1688   request_rec *r;
1689   Attr        *attr;
1690
1691   jhtml = GET_JHTML(pdoc);
1692   doc   = jhtml->doc;
1693   r     = doc->r;
1694
1695   W_L("<ol");
1696   /*--------------------------------------------------------------------------*/
1697   /* Get Attributes                                                           */
1698   /*--------------------------------------------------------------------------*/
1699   for (attr = qs_get_attr(doc,node);
1700        attr;
1701        attr = qs_get_next_attr(doc,attr)) {
1702     char *name = qs_get_attr_name(doc,attr);
1703     char *value = qs_get_attr_value(doc,attr);
1704     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1705       W_L(" type=\"");
1706       W_V(value);
1707       W_L("\"");
1708     }
1709     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1710       W_L(" start=\"");
1711       W_V(value);
1712       W_L("\"");
1713     }
1714   }
1715   W_L(">");
1716   return jhtml->out;
1717 }
1718
1719
1720 /**
1721  * It is a handler who processes the OL tag.
1722  *
1723  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1724  *                     destination is specified.
1725  * @param node   [i]   The OL tag node is specified.
1726  * @return The conversion result is returned.
1727  */
1728 static char *
1729 s_jhtml_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
1730 {
1731   jhtml_t     *jhtml;
1732   Doc         *doc;
1733   request_rec *r;
1734
1735   jhtml = GET_JHTML(pdoc);
1736   doc   = jhtml->doc;
1737   r     = doc->r;
1738
1739   W_L("</ol>");
1740   return jhtml->out;
1741 }
1742
1743
1744 /**
1745  * It is a handler who processes the P tag.
1746  *
1747  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1748  *                     destination is specified.
1749  * @param node   [i]   The P tag node is specified.
1750  * @return The conversion result is returned.
1751  */
1752 static char *
1753 s_jhtml_start_p_tag(void *pdoc, Node *node)
1754 {
1755   jhtml_t     *jhtml;
1756   Doc         *doc;
1757   request_rec *r;
1758   char        *align = NULL;
1759   Attr        *attr;
1760
1761   jhtml = GET_JHTML(pdoc);
1762   doc   = jhtml->doc;
1763   r     = doc->r;
1764
1765   W_L("<p");
1766   for (attr = qs_get_attr(doc,node);
1767        attr;
1768        attr = qs_get_next_attr(doc,attr)) {
1769     char *nm  = qs_get_attr_name(doc,attr);
1770     char *val = qs_get_attr_value(doc,attr);
1771     if (STRCASEEQ('a','A',"align", nm)) {
1772       /*----------------------------------------------------------------------*/
1773       /* CHTML 1.0 (W3C version 3.2)                                          */
1774       /*----------------------------------------------------------------------*/
1775       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
1776         align = apr_pstrdup(doc->buf.pool, val);
1777         break;
1778       }
1779     }
1780   }
1781   if (align) {
1782     W_L(" align=\"");
1783     W_V(align);
1784     W_L("\"");
1785   }
1786   W_L(">");
1787   return jhtml->out;
1788 }
1789
1790
1791 /**
1792  * It is a handler who processes the P tag.
1793  *
1794  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1795  *                     destination is specified.
1796  * @param node   [i]   The P tag node is specified.
1797  * @return The conversion result is returned.
1798  */
1799 static char *
1800 s_jhtml_end_p_tag(void *pdoc, Node *UNUSED(child)) 
1801 {
1802   jhtml_t   *jhtml = GET_JHTML(pdoc);
1803   Doc       *doc   = jhtml->doc;
1804
1805   W_L("</p>");
1806   return jhtml->out;
1807 }
1808
1809
1810 /**
1811  * It is a handler who processes the PRE tag.
1812  *
1813  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1814  *                     destination is specified.
1815  * @param node   [i]   The PRE tag node is specified.
1816  * @return The conversion result is returned.
1817  */
1818 static char *
1819 s_jhtml_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
1820 {
1821   jhtml_t  *jhtml = GET_JHTML(pdoc);
1822   Doc      *doc   = jhtml->doc;
1823
1824   jhtml->pre_flag++;
1825   W_L("<pre>");
1826   return jhtml->out;
1827 }
1828
1829
1830 /**
1831  * It is a handler who processes the PRE tag.
1832  *
1833  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1834  *                     destination is specified.
1835  * @param node   [i]   The PRE tag node is specified.
1836  * @return The conversion result is returned.
1837  */
1838 static char *
1839 s_jhtml_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
1840 {
1841   jhtml_t *jhtml = GET_JHTML(pdoc);
1842   Doc     *doc   = jhtml->doc;
1843
1844   W_L("</pre>");
1845   jhtml->pre_flag--;
1846
1847   return jhtml->out;
1848 }
1849
1850
1851 /**
1852  * It is a handler who processes the UL tag.
1853  *
1854  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1855  *                     destination is specified.
1856  * @param node   [i]   The UL tag node is specified.
1857  * @return The conversion result is returned.
1858  */
1859 static char *
1860 s_jhtml_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
1861 {
1862   jhtml_t *jhtml = GET_JHTML(pdoc);
1863   Doc     *doc   = jhtml->doc;
1864
1865   W_L("<ul>");
1866   return jhtml->out;
1867 }
1868
1869
1870 /**
1871  * It is a handler who processes the UL tag.
1872  *
1873  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1874  *                     destination is specified.
1875  * @param node   [i]   The UL tag node is specified.
1876  * @return The conversion result is returned.
1877  */
1878 static char *
1879 s_jhtml_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1880 {
1881   jhtml_t *jhtml = GET_JHTML(pdoc);
1882   Doc     *doc   = jhtml->doc;
1883
1884   W_L("</ul>");
1885   return jhtml->out;
1886 }
1887
1888
1889 /**
1890  * It is a handler who processes the HR tag.
1891  *
1892  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1893  *                     destination is specified.
1894  * @param node   [i]   The HR tag node is specified.
1895  * @return The conversion result is returned.
1896  */
1897 static char *
1898 s_jhtml_start_hr_tag(void *pdoc, Node *node) 
1899 {
1900   jhtml_t *jhtml = GET_JHTML(pdoc);
1901   Doc     *doc   = jhtml->doc;
1902   Attr    *attr;
1903
1904   W_L("<hr");
1905   for (attr = qs_get_attr(doc,node);
1906        attr; 
1907        attr = qs_get_next_attr(doc,attr)) {
1908     char *name = qs_get_attr_name(doc,attr);
1909     char *value = qs_get_attr_value(doc,attr);
1910     if (STRCASEEQ('a','A',"align",name)) {
1911       /*----------------------------------------------------------------------*/
1912       /* CHTML 1.0                                                            */
1913       /*----------------------------------------------------------------------*/
1914       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1915         W_L(" align=\"");
1916         W_V(value);
1917         W_L("\"");
1918       }
1919     }
1920     else if (STRCASEEQ('s','S',"size",name) && value && *value) {
1921       /*----------------------------------------------------------------------*/
1922       /* CHTML 1.0                                                            */
1923       /*----------------------------------------------------------------------*/
1924       W_L(" size=\"");
1925       W_V(value);
1926       W_L("\"");
1927     }
1928     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
1929       /*----------------------------------------------------------------------*/
1930       /* CHTML 1.0                                                            */
1931       /*----------------------------------------------------------------------*/
1932       W_L(" width=\"");
1933       W_V(value);
1934       W_L("\"");
1935     }
1936     else if (STRCASEEQ('n','N',"noshade",name)) {
1937       /*----------------------------------------------------------------------*/
1938       /* CHTML 1.0                                                            */
1939       /*----------------------------------------------------------------------*/
1940       W_L(" noshade");
1941     }
1942     else if (STRCASEEQ('c','C',"color",name) && value && *value) {
1943       /*----------------------------------------------------------------------*/
1944       /* CHTML 4.0                                                            */
1945       /*----------------------------------------------------------------------*/
1946       W_L(" color=\"");
1947       W_V(value);
1948       W_L("\"");
1949     }
1950   }
1951   W_L(">");
1952   return jhtml->out;
1953 }
1954
1955
1956 /**
1957  * It is a handler who processes the HR tag.
1958  *
1959  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1960  *                     destination is specified.
1961  * @param node   [i]   The HR tag node is specified.
1962  * @return The conversion result is returned.
1963  */
1964 static char *
1965 s_jhtml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1966 {
1967   jhtml_t *jhtml = GET_JHTML(pdoc);
1968   return jhtml->out;
1969 }
1970
1971
1972 /**
1973  * It is a handler who processes the IMG tag.
1974  *
1975  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1976  *                     destination is specified.
1977  * @param node   [i]   The IMG tag node is specified.
1978  * @return The conversion result is returned.
1979  */
1980 static char *
1981 s_jhtml_start_img_tag(void *pdoc, Node *node) 
1982 {
1983   jhtml_t       *jhtml = GET_JHTML(pdoc);
1984   Doc           *doc   = jhtml->doc;
1985   request_rec   *r     = doc->r;
1986   Attr          *attr;
1987 #ifndef IMG_NOT_CONVERT_FILENAME
1988   device_table  *spec = jhtml->spec;
1989 #endif
1990
1991   W_L("<img");
1992   /*--------------------------------------------------------------------------*/
1993   /* Get Attributes                                                           */
1994   /*--------------------------------------------------------------------------*/
1995   for (attr = qs_get_attr(doc,node);
1996        attr;
1997        attr = qs_get_next_attr(doc,attr)) {
1998     char *name  = qs_get_attr_name(doc,attr);
1999     char *value = qs_get_attr_value(doc,attr);
2000     if (STRCASEEQ('s','S',"src",name)) {
2001       /*----------------------------------------------------------------------*/
2002       /* CHTML 1.0                                                            */
2003       /*----------------------------------------------------------------------*/
2004 #ifdef IMG_NOT_CONVERT_FILENAME
2005       value = chxj_encoding_parameter(r, value);
2006       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
2007       if (value) {
2008         value = apr_psprintf(r->pool,
2009                              "%s%c%s=true",
2010                              value,
2011                              (strchr(value, '?')) ? '&' : '?',
2012                              CHXJ_COOKIE_NOUPDATE_PARAM);
2013       }
2014       W_L(" src=\"");
2015       W_V(value);
2016       W_L("\"");
2017 #else
2018       value = chxj_img_conv(r, spec, value);
2019       value = chxj_encoding_parameter(r, value);
2020       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
2021       if (value) {
2022         value = apr_psprintf(r->pool,
2023                              "%s%c%s=true",
2024                              value,
2025                              (strchr(value, '?')) ? '&' : '?',
2026                              CHXJ_COOKIE_NOUPDATE_PARAM);
2027       }
2028       W_L(" src=\"");
2029       W_V(value);
2030       W_L("\"");
2031 #endif
2032     }
2033     else if (STRCASEEQ('a','A',"align",name)) {
2034       /*----------------------------------------------------------------------*/
2035       /* CHTML 1.0                                                            */
2036       /*----------------------------------------------------------------------*/
2037       if (value && (STRCASEEQ('t','T',"top",   value) ||
2038                     STRCASEEQ('m','M',"middle",value) ||
2039                     STRCASEEQ('b','B',"bottom",value) ||
2040                     STRCASEEQ('l','L',"left",  value) ||
2041                     STRCASEEQ('r','R',"right", value))) {
2042         W_L(" align=\"");
2043         W_V(value);
2044         W_L("\"");
2045       }
2046     }
2047     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
2048       /*----------------------------------------------------------------------*/
2049       /* CHTML 1.0                                                            */
2050       /*----------------------------------------------------------------------*/
2051       W_L(" width=\"");
2052       W_V(value);
2053       W_L("\"");
2054     }
2055     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2056       /*----------------------------------------------------------------------*/
2057       /* CHTML 1.0                                                            */
2058       /*----------------------------------------------------------------------*/
2059       W_L(" height=\"");
2060       W_V(value);
2061       W_L("\"");
2062     }
2063     else if (STRCASEEQ('h','H',"hspace",name)) {
2064       /*----------------------------------------------------------------------*/
2065       /* CHTML 1.0                                                            */
2066       /*----------------------------------------------------------------------*/
2067       /* ignore */
2068     }
2069     else if (STRCASEEQ('v','V',"vspace",name)) {
2070       /*----------------------------------------------------------------------*/
2071       /* CHTML 1.0                                                            */
2072       /*----------------------------------------------------------------------*/
2073       /* ignore */
2074     }
2075     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2076       /*----------------------------------------------------------------------*/
2077       /* CHTML 1.0                                                            */
2078       /*----------------------------------------------------------------------*/
2079       W_L(" alt=\"");
2080       W_V(value);
2081       W_L("\"");
2082     }
2083   }
2084   W_L(">");
2085   return jhtml->out;
2086 }
2087
2088
2089 /**
2090  * It is a handler who processes the IMG tag.
2091  *
2092  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2093  *                     destination is specified.
2094  * @param node   [i]   The IMG tag node is specified.
2095  * @return The conversion result is returned.
2096  */
2097 static char *
2098 s_jhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2099 {
2100   jhtml_t *jhtml = GET_JHTML(pdoc);
2101   return jhtml->out;
2102 }
2103
2104
2105 /**
2106  * It is a handler who processes the SELECT tag.
2107  *
2108  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2109  *                     destination is specified.
2110  * @param node   [i]   The SELECT tag node is specified.
2111  * @return The conversion result is returned.
2112  */
2113 static char *
2114 s_jhtml_start_select_tag(void *pdoc, Node *child)
2115 {
2116   jhtml_t *jhtml    = GET_JHTML(pdoc);
2117   Doc     *doc      = jhtml->doc;
2118   Attr    *attr;
2119   char    *size     = NULL;
2120   char    *name     = NULL;
2121   char    *multiple = NULL;
2122
2123   W_L("<select");
2124   for (attr = qs_get_attr(doc,child);
2125        attr;
2126        attr = qs_get_next_attr(doc,attr)) {
2127     char *nm  = qs_get_attr_name(doc,attr);
2128     char *val = qs_get_attr_value(doc,attr);
2129     if (STRCASEEQ('s','S',"size",nm)) {
2130       /*----------------------------------------------------------------------*/
2131       /* CHTML 1.0 version 2.0                                                */
2132       /*----------------------------------------------------------------------*/
2133       size = apr_pstrdup(doc->buf.pool, val);
2134     }
2135     else if (STRCASEEQ('n','N',"name",nm)) {
2136       /*----------------------------------------------------------------------*/
2137       /* CHTML 1.0 version 2.0                                                */
2138       /*----------------------------------------------------------------------*/
2139       name = apr_pstrdup(doc->buf.pool, val);
2140     }
2141     else if (STRCASEEQ('m','M',"multiple", nm)) {
2142       /*----------------------------------------------------------------------*/
2143       /* CHTML 1.0 version 2.0                                                */
2144       /*----------------------------------------------------------------------*/
2145       multiple = apr_pstrdup(doc->buf.pool, val);
2146     }
2147   }
2148   if (size && *size) {
2149     W_L(" size=\"");
2150     W_V(size);
2151     W_L("\"");
2152   }
2153   if (name && *name) {
2154     W_L(" name=\"");
2155     W_V(name);
2156     W_L("\"");
2157   }
2158   if (multiple) {
2159     W_L(" multiple");
2160   }
2161   W_L(">");
2162   return jhtml->out;
2163 }
2164
2165
2166 /**
2167  * It is a handler who processes the SELECT tag.
2168  *
2169  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2170  *                     destination is specified.
2171  * @param node   [i]   The SELECT tag node is specified.
2172  * @return The conversion result is returned.
2173  */
2174 static char *
2175 s_jhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
2176 {
2177   jhtml_t *jhtml = GET_JHTML(pdoc);
2178   Doc     *doc   = jhtml->doc;
2179
2180   W_L("</select>");
2181   return jhtml->out;
2182 }
2183
2184 /**
2185  * It is a handler who processes the OPTION tag.
2186  *
2187  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2188  *                     destination is specified.
2189  * @param node   [i]   The OPTION tag node is specified.
2190  * @return The conversion result is returned.
2191  */
2192 static char *
2193 s_jhtml_start_option_tag(void *pdoc, Node *child)
2194 {
2195   jhtml_t *jhtml = GET_JHTML(pdoc);
2196   Doc     *doc   = jhtml->doc;
2197   Attr    *attr;
2198
2199   char *selected   = NULL;
2200   char *value      = NULL;
2201
2202   W_L("<option");
2203   for (attr = qs_get_attr(doc,child);
2204        attr;
2205        attr = qs_get_next_attr(doc,attr)) {
2206     char *nm  = qs_get_attr_name(doc,attr);
2207     char *val = qs_get_attr_value(doc,attr);
2208     if (STRCASEEQ('s','S',"selected",nm)) {
2209       /*----------------------------------------------------------------------*/
2210       /* CHTML 1.0 version 2.0                                                */
2211       /*----------------------------------------------------------------------*/
2212       selected = apr_pstrdup(doc->buf.pool, val);
2213     }
2214     else if (STRCASEEQ('v','V',"value",nm)) {
2215       /*----------------------------------------------------------------------*/
2216       /* CHTML 1.0 version 2.0                                                */
2217       /*----------------------------------------------------------------------*/
2218       value = apr_pstrdup(doc->buf.pool, val);
2219     }
2220   }
2221   if (value && *value) {
2222     W_L(" value=\"");
2223     W_V(value);
2224     W_L("\"");
2225   }
2226   if (selected) {
2227     W_L(" selected");
2228   }
2229   W_L(">");
2230   return jhtml->out;
2231 }
2232
2233
2234 /**
2235  * It is a handler who processes the OPTION tag.
2236  *
2237  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2238  *                     destination is specified.
2239  * @param node   [i]   The OPTION tag node is specified.
2240  * @return The conversion result is returned.
2241  */
2242 static char *
2243 s_jhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
2244 {
2245   jhtml_t *jhtml = GET_JHTML(pdoc);
2246   /* Don't close */
2247   return jhtml->out;
2248 }
2249
2250
2251 /**
2252  * It is a handler who processes the DIV tag.
2253  *
2254  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2255  *                     destination is specified.
2256  * @param node   [i]   The DIV tag node is specified.
2257  * @return The conversion result is returned.
2258  */
2259 static char *
2260 s_jhtml_start_div_tag(void *pdoc, Node *child)
2261 {
2262   jhtml_t      *jhtml;
2263   Doc          *doc;
2264   request_rec  *r;
2265   Attr         *attr;
2266   char         *align = NULL;
2267
2268   jhtml = GET_JHTML(pdoc);
2269   doc   = jhtml->doc;
2270   r     = doc->r;
2271
2272   W_L("<div");
2273   for (attr = qs_get_attr(doc,child);
2274        attr;
2275        attr = qs_get_next_attr(doc,attr)) {
2276     char *nm  = qs_get_attr_name(doc,attr);
2277     char *val = qs_get_attr_value(doc,attr);
2278     if (STRCASEEQ('a','A',"align",nm)) {
2279       /*----------------------------------------------------------------------*/
2280       /* CHTML 1.0 (W3C version 3.2)                                          */
2281       /*----------------------------------------------------------------------*/
2282       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2283         align = apr_pstrdup(doc->buf.pool, val);
2284       }
2285     }
2286   }
2287   if (align) {
2288     W_L(" align=\"");
2289     W_V(align);
2290     W_L("\"");
2291   }
2292   W_L(">");
2293   return jhtml->out;
2294 }
2295
2296
2297 /**
2298  * It is a handler who processes the DIV tag.
2299  *
2300  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2301  *                     destination is specified.
2302  * @param node   [i]   The DIV tag node is specified.
2303  * @return The conversion result is returned.
2304  */
2305 static char *
2306 s_jhtml_end_div_tag(void *pdoc, Node *UNUSED(child))
2307 {
2308   jhtml_t      *jhtml;
2309   Doc          *doc;
2310   request_rec  *r;
2311
2312   jhtml = GET_JHTML(pdoc);
2313   doc   = jhtml->doc;
2314   r     = doc->r;
2315
2316   W_L("</div>");
2317   return jhtml->out;
2318 }
2319
2320
2321 static char *
2322 chxj_istyle_to_mode(apr_pool_t *p, const char *s)
2323 {
2324   char *tmp;
2325
2326   if (s) {
2327     switch (s[0]) {
2328     case '1': return apr_psprintf(p, "hiragana");
2329     case '2': return apr_psprintf(p, "hankakukana");
2330     case '3': return apr_psprintf(p, "alphabet");
2331     case '4': return apr_psprintf(p, "numeric");
2332     default: 
2333       tmp = apr_palloc(p, 1);
2334       tmp[0] = '\0';
2335       return apr_pstrdup(p, tmp);
2336     }
2337   }
2338
2339   tmp = apr_palloc(p, 1);
2340   tmp[0] = '\0';
2341   return apr_pstrdup(p,tmp);
2342 }
2343
2344
2345 static char *
2346 s_jhtml_chxjif_tag(void *pdoc, Node *node)
2347 {
2348   jhtml_t *jhtml;
2349   Doc     *doc;
2350   Node    *child;
2351   request_rec *r;
2352
2353   jhtml = GET_JHTML(pdoc);
2354   doc   = jhtml->doc;
2355   r     = doc->r;
2356
2357   for (child = qs_get_child_node(doc, node);
2358        child;
2359        child = qs_get_next_node(doc, child)) {
2360     W_V(child->otext);
2361     s_jhtml_chxjif_tag(jhtml, child);
2362   }
2363   return NULL;
2364 }
2365
2366
2367 /**
2368  * It is a handler who processes the TEXTARE tag.
2369  *
2370  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2371  *                     destination is specified.
2372  * @param node   [i]   The TEXTAREA tag node is specified.
2373  * @return The conversion result is returned.
2374  */
2375 static char *
2376 s_jhtml_start_textarea_tag(void *pdoc, Node *node) 
2377 {
2378   jhtml_t       *jhtml;
2379   Doc           *doc;
2380   request_rec   *r;
2381   Attr          *attr;
2382
2383   jhtml = GET_JHTML(pdoc);
2384   doc   = jhtml->doc;
2385   r     = doc->r;
2386
2387   jhtml->textarea_flag++;
2388   W_L("<textarea");
2389   for (attr = qs_get_attr(doc,node);
2390        attr;
2391        attr = qs_get_next_attr(doc,attr)) {
2392     char *name  = qs_get_attr_name(doc,attr);
2393     char *value = qs_get_attr_value(doc,attr);
2394     if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
2395       W_L(" accesskey=\"");
2396       W_V(value);
2397       W_L("\"");
2398     }
2399     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
2400       char *vv = chxj_istyle_to_mode(doc->buf.pool,value);
2401       W_L(" mode=\"");
2402       W_V(vv);
2403       W_L("\"");
2404     }
2405     else if (STRCASEEQ('n','N',"name", name) && value && *value) {
2406       W_L(" name=\"");
2407       W_V(value);
2408       W_L("\"");
2409     }
2410     else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
2411       W_L(" rows=\"");
2412       W_V(value);
2413       W_L("\"");
2414     }
2415     else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
2416       W_L(" cols=\"");
2417       W_V(value);
2418       W_L("\"");
2419     }
2420   }
2421   W_L(">");
2422   return jhtml->out;
2423 }
2424
2425
2426 /**
2427  * It is a handler who processes the TEXTAREA tag.
2428  *
2429  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2430  *                     destination is specified.
2431  * @param node   [i]   The TEXTAREA tag node is specified.
2432  * @return The conversion result is returned.
2433  */
2434 static char *
2435 s_jhtml_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
2436 {
2437   jhtml_t       *jhtml;
2438   Doc           *doc;
2439   request_rec   *r;
2440
2441   jhtml = GET_JHTML(pdoc);
2442   doc   = jhtml->doc;
2443   r     = doc->r;
2444
2445   W_L("</textarea>");
2446   jhtml->textarea_flag--;
2447
2448   return jhtml->out;
2449 }
2450
2451
2452 /**
2453  * It is a handler who processes the B tag.
2454  *
2455  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2456  *                     destination is specified.
2457  * @param node   [i]   The B tag node is specified.
2458  * @return The conversion result is returned.
2459  */
2460 static char*
2461 s_jhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
2462 {
2463   jhtml_t*      jhtml;
2464   Doc*          doc;
2465   request_rec*  r;
2466
2467   jhtml = GET_JHTML(pdoc);
2468   doc   = jhtml->doc;
2469   r     = doc->r;
2470
2471   W_L("<b>");
2472   return jhtml->out;
2473 }
2474
2475
2476 /**
2477  * It is a handler who processes the B tag.
2478  *
2479  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2480  *                     destination is specified.
2481  * @param node   [i]   The B tag node is specified.
2482  * @return The conversion result is returned.
2483  */
2484 static char*
2485 s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
2486 {
2487   jhtml_t*      jhtml = GET_JHTML(pdoc);
2488   Doc*          doc   = jhtml->doc;
2489
2490   W_L("</b>\r\n");
2491   return jhtml->out;
2492 }
2493
2494 static char*
2495 s_jhtml_text_tag(void* pdoc, Node* child)
2496 {
2497   jhtml_t*     jhtml;
2498   Doc*         doc;
2499   char*        textval;
2500   char*        tmp;
2501   char*        tdst;
2502   char         one_byte[2];
2503   int          ii;
2504   int          tdst_len;
2505   request_rec* r;
2506
2507   jhtml = GET_JHTML(pdoc);
2508   doc   = jhtml->doc;
2509   r     = doc->r;
2510   DBG(r, "start s_jhtml_text_tag()");
2511
2512   textval = qs_get_node_value(doc,child);
2513   if (strlen(textval) == 0) {
2514     return jhtml->out;
2515   }
2516
2517   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2518   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2519
2520   tdst     = qs_alloc_zero_byte_string(r);
2521   memset(one_byte, 0, sizeof(one_byte));
2522   tdst_len = 0;
2523
2524   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2525     char* out;
2526     int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
2527     if (rtn) {
2528       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2529       ii+=(rtn - 1);
2530       continue;
2531     }
2532
2533     if (is_sjis_kanji(textval[ii])) {
2534       one_byte[0] = textval[ii+0];
2535       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2536       one_byte[0] = textval[ii+1];
2537       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2538       ii++;
2539     }
2540     else 
2541     if (jhtml->pre_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 (jhtml->textarea_flag) {
2547       one_byte[0] = textval[ii+0];
2548       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2549     }
2550     else {
2551       if (textval[ii] != '\r' && textval[ii] != '\n') {
2552         one_byte[0] = textval[ii+0];
2553         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2554       }
2555     }
2556   }
2557   W_V(tdst);
2558   DBG(r, "end s_jhtml_text_tag()");
2559   return jhtml->out;
2560 }
2561
2562
2563 /**
2564  * It is a handler who processes the BLOCKQUOTE tag.
2565  *
2566  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2567  *                     destination is specified.
2568  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2569  * @return The conversion result is returned.
2570  */
2571 static char *
2572 s_jhtml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
2573 {
2574   jhtml_t *jhtml = GET_JHTML(pdoc);
2575   Doc     *doc   = jhtml->doc;
2576   W_L("<blockquote>");
2577   return jhtml->out;
2578 }
2579
2580
2581 /**
2582  * It is a handler who processes the BLOCKQUOTE tag.
2583  *
2584  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2585  *                     destination is specified.
2586  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2587  * @return The conversion result is returned.
2588  */
2589 static char *
2590 s_jhtml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
2591 {
2592   jhtml_t *jhtml = GET_JHTML(pdoc);
2593   Doc     *doc   = jhtml->doc;
2594   W_L("</blockquote>");
2595   return jhtml->out;
2596 }
2597
2598
2599 /**
2600  * It is a handler who processes the DIR tag.
2601  *
2602  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2603  *                     destination is specified.
2604  * @param node   [i]   The DIR tag node is specified.
2605  * @return The conversion result is returned.
2606  */
2607 static char *
2608 s_jhtml_start_dir_tag(void *pdoc, Node *UNUSED(child))
2609 {
2610   jhtml_t *jhtml = GET_JHTML(pdoc);
2611   Doc *doc = jhtml->doc;
2612   W_L("<dir>");
2613   return jhtml->out;
2614 }
2615
2616
2617 /**
2618  * It is a handler who processes the DIR tag.
2619  *
2620  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2621  *                     destination is specified.
2622  * @param node   [i]   The DIR tag node is specified.
2623  * @return The conversion result is returned.
2624  */
2625 static char *
2626 s_jhtml_end_dir_tag(void *pdoc, Node *UNUSED(child))
2627 {
2628   jhtml_t *jhtml = GET_JHTML(pdoc);
2629   Doc *doc = jhtml->doc;
2630   W_L("</dir>");
2631   return jhtml->out;
2632 }
2633
2634
2635 /**
2636  * It is a handler who processes the DL tag.
2637  *
2638  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2639  *                     destination is specified.
2640  * @param node   [i]   The DL tag node is specified.
2641  * @return The conversion result is returned.
2642  */
2643 static char *
2644 s_jhtml_start_dl_tag(void *pdoc, Node *UNUSED(child))
2645 {
2646   jhtml_t *jhtml = GET_JHTML(pdoc);
2647   Doc *doc = jhtml->doc;
2648   W_L("<dl>");
2649   return jhtml->out;
2650 }
2651
2652
2653 /**
2654  * It is a handler who processes the DL tag.
2655  *
2656  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2657  *                     destination is specified.
2658  * @param node   [i]   The DL tag node is specified.
2659  * @return The conversion result is returned.
2660  */
2661 static char *
2662 s_jhtml_end_dl_tag(void *pdoc, Node *UNUSED(child))
2663 {
2664   jhtml_t *jhtml = GET_JHTML(pdoc);
2665   Doc *doc = jhtml->doc;
2666   W_L("</dl>");
2667   return jhtml->out;
2668 }
2669
2670
2671 /**
2672  * It is a handler who processes the DT tag.
2673  *
2674  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2675  *                     destination is specified.
2676  * @param node   [i]   The DT tag node is specified.
2677  * @return The conversion result is returned.
2678  */
2679 static char *
2680 s_jhtml_start_dt_tag(void *pdoc, Node *UNUSED(child))
2681 {
2682   jhtml_t *jhtml = GET_JHTML(pdoc);
2683   Doc     *doc   = jhtml->doc;
2684   W_L("<dt>");
2685   return jhtml->out;
2686 }
2687
2688
2689 /**
2690  * It is a handler who processes the DT tag.
2691  *
2692  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2693  *                     destination is specified.
2694  * @param node   [i]   The DT tag node is specified.
2695  * @return The conversion result is returned.
2696  */
2697 static char *
2698 s_jhtml_end_dt_tag(void *pdoc, Node *UNUSED(child))
2699 {
2700   jhtml_t *jhtml = GET_JHTML(pdoc);
2701   return jhtml->out;
2702 }
2703
2704
2705 /**
2706  * It is a handler who processes the DD tag.
2707  *
2708  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2709  *                     destination is specified.
2710  * @param node   [i]   The DD tag node is specified.
2711  * @return The conversion result is returned.
2712  */
2713 static char *
2714 s_jhtml_start_dd_tag(void *pdoc, Node *UNUSED(child))
2715 {
2716   jhtml_t *jhtml = GET_JHTML(pdoc);
2717   Doc *doc = jhtml->doc;
2718   W_L("<dd>");
2719   return jhtml->out;
2720 }
2721
2722
2723 /**
2724  * It is a handler who processes the DD tag.
2725  *
2726  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2727  *                     destination is specified.
2728  * @param node   [i]   The DD tag node is specified.
2729  * @return The conversion result is returned.
2730  */
2731 static char *
2732 s_jhtml_end_dd_tag(void *pdoc, Node *UNUSED(child))
2733 {
2734   jhtml_t *jhtml = GET_JHTML(pdoc);
2735   return jhtml->out;
2736 }
2737
2738
2739 /**
2740  * It is a handler who processes the H1 tag.
2741  *
2742  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2743  *                     destination is specified.
2744  * @param node   [i]   The H1 tag node is specified.
2745  * @return The conversion result is returned.
2746  */
2747 static char *
2748 s_jhtml_start_h1_tag(void *pdoc, Node *node)
2749 {
2750   jhtml_t       *jhtml;
2751   Doc           *doc;
2752   request_rec   *r;
2753   Attr          *attr;
2754   char          *align = NULL;
2755
2756   jhtml   = GET_JHTML(pdoc);
2757   doc     = jhtml->doc;
2758   r       = doc->r;
2759
2760   for (attr = qs_get_attr(doc,node);
2761        attr;
2762        attr = qs_get_next_attr(doc,attr)) {
2763     char* name;
2764     char* value;
2765     name  = qs_get_attr_name(doc,attr);
2766     value = qs_get_attr_value(doc,attr);
2767     if (STRCASEEQ('a','A',"align", name)) {
2768       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2769         jhtml->h1_align_flag++;
2770         align = apr_pstrdup(doc->buf.pool, value);
2771         break;
2772       }
2773     }
2774   }
2775   if (align) {
2776     W_L("<div align=\"");
2777     W_V(align);
2778     W_L("\">");
2779   }
2780   return jhtml->out;
2781 }
2782
2783
2784 /**
2785  * It is a handler who processes the H1 tag.
2786  *
2787  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2788  *                     destination is specified.
2789  * @param node   [i]   The H1 tag node is specified.
2790  * @return The conversion result is returned.
2791  */
2792 static char *
2793 s_jhtml_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2794 {
2795   jhtml_t*    jhtml;
2796   Doc*          doc;
2797   request_rec*  r;
2798
2799   jhtml = GET_JHTML(pdoc);
2800   doc     = jhtml->doc;
2801   r       = doc->r;
2802   
2803   if (jhtml->h1_align_flag) {
2804     jhtml->h1_align_flag--;
2805     W_L("</div>");
2806   }
2807   return jhtml->out;
2808 }
2809
2810
2811 /**
2812  * It is a handler who processes the H2 tag.
2813  *
2814  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2815  *                     destination is specified.
2816  * @param node   [i]   The H1 tag node is specified.
2817  * @return The conversion result is returned.
2818  */
2819 static char *
2820 s_jhtml_start_h2_tag(void *pdoc, Node *node)
2821 {
2822   jhtml_t       *jhtml;
2823   Doc           *doc;
2824   request_rec   *r;
2825   Attr          *attr;
2826   char          *align = NULL;
2827
2828   jhtml   = GET_JHTML(pdoc);
2829   doc     = jhtml->doc;
2830   r       = doc->r;
2831
2832   for (attr = qs_get_attr(doc,node);
2833        attr;
2834        attr = qs_get_next_attr(doc,attr)) {
2835     char* name;
2836     char* value;
2837     name  = qs_get_attr_name(doc,attr);
2838     value = qs_get_attr_value(doc,attr);
2839     if (STRCASEEQ('a','A',"align", name)) {
2840       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2841         jhtml->h2_align_flag++;
2842         align = apr_pstrdup(doc->buf.pool, value);
2843         break;
2844       }
2845     }
2846   }
2847   if (align) {
2848     W_L("<div align=\"");
2849     W_V(align);
2850     W_L("\">");
2851   }
2852   return jhtml->out;
2853 }
2854
2855
2856 /**
2857  * It is a handler who processes the H2 tag.
2858  *
2859  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2860  *                     destination is specified.
2861  * @param node   [i]   The H1 tag node is specified.
2862  * @return The conversion result is returned.
2863  */
2864 static char *
2865 s_jhtml_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2866 {
2867   jhtml_t*    jhtml;
2868   Doc*          doc;
2869   request_rec*  r;
2870
2871   jhtml = GET_JHTML(pdoc);
2872   doc     = jhtml->doc;
2873   r       = doc->r;
2874   
2875   if (jhtml->h2_align_flag) {
2876     jhtml->h2_align_flag--;
2877     W_L("</div>");
2878   }
2879   return jhtml->out;
2880 }
2881
2882
2883 /**
2884  * It is a handler who processes the H3 tag.
2885  *
2886  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2887  *                     destination is specified.
2888  * @param node   [i]   The H1 tag node is specified.
2889  * @return The conversion result is returned.
2890  */
2891 static char *
2892 s_jhtml_start_h3_tag(void *pdoc, Node *node)
2893 {
2894   jhtml_t       *jhtml;
2895   Doc           *doc;
2896   request_rec   *r;
2897   Attr          *attr;
2898   char          *align = NULL;
2899
2900   jhtml   = GET_JHTML(pdoc);
2901   doc     = jhtml->doc;
2902   r       = doc->r;
2903
2904   for (attr = qs_get_attr(doc,node);
2905        attr;
2906        attr = qs_get_next_attr(doc,attr)) {
2907     char* name;
2908     char* value;
2909     name  = qs_get_attr_name(doc,attr);
2910     value = qs_get_attr_value(doc,attr);
2911     if (STRCASEEQ('a','A',"align", name)) {
2912       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2913         jhtml->h3_align_flag++;
2914         align = apr_pstrdup(doc->buf.pool, value);
2915         break;
2916       }
2917     }
2918   }
2919   if (align) {
2920     W_L("<div align=\"");
2921     W_V(align);
2922     W_L("\">");
2923   }
2924   return jhtml->out;
2925 }
2926
2927
2928 /**
2929  * It is a handler who processes the H3 tag.
2930  *
2931  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2932  *                     destination is specified.
2933  * @param node   [i]   The H1 tag node is specified.
2934  * @return The conversion result is returned.
2935  */
2936 static char *
2937 s_jhtml_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2938 {
2939   jhtml_t*    jhtml;
2940   Doc*          doc;
2941   request_rec*  r;
2942
2943   jhtml = GET_JHTML(pdoc);
2944   doc     = jhtml->doc;
2945   r       = doc->r;
2946   
2947   if (jhtml->h3_align_flag) {
2948     jhtml->h3_align_flag--;
2949     W_L("</div>");
2950   }
2951   return jhtml->out;
2952 }
2953
2954
2955 /**
2956  * It is a handler who processes the H4 tag.
2957  *
2958  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2959  *                     destination is specified.
2960  * @param node   [i]   The H1 tag node is specified.
2961  * @return The conversion result is returned.
2962  */
2963 static char *
2964 s_jhtml_start_h4_tag(void *pdoc, Node *node)
2965 {
2966   jhtml_t       *jhtml;
2967   Doc           *doc;
2968   request_rec   *r;
2969   Attr          *attr;
2970   char          *align = NULL;
2971
2972   jhtml   = GET_JHTML(pdoc);
2973   doc     = jhtml->doc;
2974   r       = doc->r;
2975
2976   for (attr = qs_get_attr(doc,node);
2977        attr;
2978        attr = qs_get_next_attr(doc,attr)) {
2979     char* name;
2980     char* value;
2981     name  = qs_get_attr_name(doc,attr);
2982     value = qs_get_attr_value(doc,attr);
2983     if (STRCASEEQ('a','A',"align", name)) {
2984       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2985         jhtml->h4_align_flag++;
2986         align = apr_pstrdup(doc->buf.pool, value);
2987         break;
2988       }
2989     }
2990   }
2991   if (align) {
2992     W_L("<div align=\"");
2993     W_V(align);
2994     W_L("\">");
2995   }
2996   return jhtml->out;
2997 }
2998
2999
3000 /**
3001  * It is a handler who processes the H4 tag.
3002  *
3003  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3004  *                     destination is specified.
3005  * @param node   [i]   The H1 tag node is specified.
3006  * @return The conversion result is returned.
3007  */
3008 static char *
3009 s_jhtml_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
3010 {
3011   jhtml_t*    jhtml;
3012   Doc*          doc;
3013   request_rec*  r;
3014
3015   jhtml = GET_JHTML(pdoc);
3016   doc     = jhtml->doc;
3017   r       = doc->r;
3018   
3019   if (jhtml->h4_align_flag) {
3020     jhtml->h4_align_flag--;
3021     W_L("</div>");
3022   }
3023   return jhtml->out;
3024 }
3025
3026
3027 /**
3028  * It is a handler who processes the H5 tag.
3029  *
3030  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3031  *                     destination is specified.
3032  * @param node   [i]   The H1 tag node is specified.
3033  * @return The conversion result is returned.
3034  */
3035 static char *
3036 s_jhtml_start_h5_tag(void *pdoc, Node *node)
3037 {
3038   jhtml_t       *jhtml;
3039   Doc           *doc;
3040   request_rec   *r;
3041   Attr          *attr;
3042   char          *align = NULL;
3043
3044   jhtml   = GET_JHTML(pdoc);
3045   doc     = jhtml->doc;
3046   r       = doc->r;
3047
3048   for (attr = qs_get_attr(doc,node);
3049        attr;
3050        attr = qs_get_next_attr(doc,attr)) {
3051     char* name;
3052     char* value;
3053     name  = qs_get_attr_name(doc,attr);
3054     value = qs_get_attr_value(doc,attr);
3055     if (STRCASEEQ('a','A',"align", name)) {
3056       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3057         jhtml->h5_align_flag++;
3058         align = apr_pstrdup(doc->buf.pool, value);
3059         break;
3060       }
3061     }
3062   }
3063   if (align) {
3064     W_L("<div align=\"");
3065     W_V(align);
3066     W_L("\">");
3067   }
3068   return jhtml->out;
3069 }
3070
3071
3072 /**
3073  * It is a handler who processes the H5 tag.
3074  *
3075  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3076  *                     destination is specified.
3077  * @param node   [i]   The H1 tag node is specified.
3078  * @return The conversion result is returned.
3079  */
3080 static char *
3081 s_jhtml_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
3082 {
3083   jhtml_t*    jhtml;
3084   Doc*          doc;
3085   request_rec*  r;
3086
3087   jhtml = GET_JHTML(pdoc);
3088   doc     = jhtml->doc;
3089   r       = doc->r;
3090   
3091   if (jhtml->h5_align_flag) {
3092     jhtml->h5_align_flag--;
3093     W_L("</div>");
3094   }
3095   return jhtml->out;
3096 }
3097
3098
3099 /**
3100  * It is a handler who processes the H6 tag.
3101  *
3102  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3103  *                     destination is specified.
3104  * @param node   [i]   The H1 tag node is specified.
3105  * @return The conversion result is returned.
3106  */
3107 static char *
3108 s_jhtml_start_h6_tag(void *pdoc, Node *node)
3109 {
3110   jhtml_t       *jhtml;
3111   Doc           *doc;
3112   request_rec   *r;
3113   Attr          *attr;
3114   char          *align = NULL;
3115
3116   jhtml   = GET_JHTML(pdoc);
3117   doc     = jhtml->doc;
3118   r       = doc->r;
3119
3120   for (attr = qs_get_attr(doc,node);
3121        attr;
3122        attr = qs_get_next_attr(doc,attr)) {
3123     char* name;
3124     char* value;
3125     name  = qs_get_attr_name(doc,attr);
3126     value = qs_get_attr_value(doc,attr);
3127     if (STRCASEEQ('a','A',"align", name)) {
3128       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3129         jhtml->h6_align_flag++;
3130         align = apr_pstrdup(doc->buf.pool, value);
3131         break;
3132       }
3133     }
3134   }
3135   if (align) {
3136     W_L("<div align=\"");
3137     W_V(align);
3138     W_L("\">");
3139   }
3140   return jhtml->out;
3141 }
3142
3143
3144 /**
3145  * It is a handler who processes the H6 tag.
3146  *
3147  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3148  *                     destination is specified.
3149  * @param node   [i]   The H1 tag node is specified.
3150  * @return The conversion result is returned.
3151  */
3152 static char *
3153 s_jhtml_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
3154 {
3155   jhtml_t*    jhtml;
3156   Doc*          doc;
3157   request_rec*  r;
3158
3159   jhtml = GET_JHTML(pdoc);
3160   doc     = jhtml->doc;
3161   r       = doc->r;
3162   
3163   if (jhtml->h6_align_flag) {
3164     jhtml->h6_align_flag--;
3165     W_L("</div>");
3166   }
3167   return jhtml->out;
3168 }
3169
3170
3171 /**
3172  * It is a handler who processes the MENU tag.
3173  *
3174  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3175  *                     destination is specified.
3176  * @param node   [i]   The MENU tag node is specified.
3177  * @return The conversion result is returned.
3178  */
3179 static char *
3180 s_jhtml_start_menu_tag(void *pdoc, Node *UNUSED(child))
3181 {
3182   jhtml_t *jhtml = GET_JHTML(pdoc);
3183   Doc     *doc = jhtml->doc;
3184   W_L("<menu>");
3185   return jhtml->out;
3186 }
3187
3188
3189 /**
3190  * It is a handler who processes the MENU tag.
3191  *
3192  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3193  *                     destination is specified.
3194  * @param node   [i]   The MENU tag node is specified.
3195  * @return The conversion result is returned.
3196  */
3197 static char *
3198 s_jhtml_end_menu_tag(void *pdoc, Node *UNUSED(child))
3199 {
3200   jhtml_t *jhtml = GET_JHTML(pdoc);
3201   Doc     *doc = jhtml->doc;
3202   W_L("</menu>");
3203   return jhtml->out;
3204 }
3205
3206
3207 /**
3208  * It is a handler who processes the PLAINTEXT tag.
3209  *
3210  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3211  *                     destination is specified.
3212  * @param node   [i]   The PLAINTEXT tag node is specified.
3213  * @return The conversion result is returned.
3214  */
3215 static char *
3216 s_jhtml_start_plaintext_tag(void *pdoc, Node *node)
3217 {
3218   jhtml_t *jhtml;
3219   Doc *doc;
3220
3221   jhtml = GET_JHTML(pdoc);
3222   doc     = jhtml->doc;
3223   W_L("<plaintext>");
3224   s_jhtml_start_plaintext_tag_inner(pdoc,node);
3225   return jhtml->out;
3226 }
3227
3228 static char *
3229 s_jhtml_start_plaintext_tag_inner(void *pdoc, Node *node)
3230 {
3231   jhtml_t *jhtml;
3232   Doc *doc;
3233   Node *child;
3234   jhtml = GET_JHTML(pdoc);
3235   doc     = jhtml->doc;
3236   for (child = qs_get_child_node(doc, node);
3237        child;
3238        child = qs_get_next_node(doc, child)) {
3239     W_V(child->otext);
3240     s_jhtml_start_plaintext_tag_inner(pdoc, child);
3241   }
3242   return jhtml->out;
3243 }
3244
3245
3246 /**
3247  * It is a handler who processes the PLAINTEXT tag.
3248  *
3249  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3250  *                     destination is specified.
3251  * @param node   [i]   The PLAINTEXT tag node is specified.
3252  * @return The conversion result is returned.
3253  */
3254 static char *
3255 s_jhtml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3256 {
3257   jhtml_t *jhtml = GET_JHTML(pdoc);
3258   return jhtml->out;
3259 }
3260
3261
3262 /**
3263  * It is a handler who processes the BLINK tag.
3264  *
3265  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3266  *                     destination is specified.
3267  * @param node   [i]   The BLINK tag node is specified.
3268  * @return The conversion result is returned.
3269  */
3270 static char *
3271 s_jhtml_start_blink_tag(void *pdoc, Node *UNUSED(child))
3272 {
3273   jhtml_t *jhtml = GET_JHTML(pdoc);
3274   Doc     *doc = jhtml->doc;
3275   W_L("<blink>");
3276   return jhtml->out;
3277 }
3278
3279
3280 /**
3281  * It is a handler who processes the BLINK tag.
3282  *
3283  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3284  *                     destination is specified.
3285  * @param node   [i]   The BLINK tag node is specified.
3286  * @return The conversion result is returned.
3287  */
3288 static char *
3289 s_jhtml_end_blink_tag(void *pdoc, Node *UNUSED(child))
3290 {
3291   jhtml_t *jhtml = GET_JHTML(pdoc);
3292   Doc     *doc = jhtml->doc;
3293   W_L("</blink>");
3294   return jhtml->out;
3295 }
3296
3297
3298 /**
3299  * It is a handler who processes the MARQUEE tag.
3300  *
3301  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3302  *                     destination is specified.
3303  * @param node   [i]   The MARQUEE tag node is specified.
3304  * @return The conversion result is returned.
3305  */
3306 static char *
3307 s_jhtml_start_marquee_tag(void *pdoc, Node *node)
3308 {
3309   jhtml_t *jhtml = GET_JHTML(pdoc);
3310   Doc *doc = jhtml->doc;
3311   Attr *attr;
3312   W_L("<marquee");
3313   /*--------------------------------------------------------------------------*/
3314   /* Get Attributes                                                           */
3315   /*--------------------------------------------------------------------------*/
3316   for (attr = qs_get_attr(doc,node);
3317        attr;
3318        attr = qs_get_next_attr(doc,attr)) {
3319     char *name   = qs_get_attr_name(doc,attr);
3320     char *value  = qs_get_attr_value(doc,attr);
3321     if (STRCASEEQ('d','D',"direction", name)) {
3322       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3323         W_L(" direction=\"");
3324         W_V(value);
3325         W_L("\"");
3326       }
3327     }
3328     else if (STRCASEEQ('b','B',"behavior",name)) {
3329       /* ignore */
3330     }
3331     else if (STRCASEEQ('l','L',"loop",name)) {
3332       /* ignore */
3333     }
3334   }
3335   W_L(">");
3336   return jhtml->out;
3337 }
3338
3339
3340 /**
3341  * It is a handler who processes the MARQUEE tag.
3342  *
3343  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3344  *                     destination is specified.
3345  * @param node   [i]   The MARQUEE tag node is specified.
3346  * @return The conversion result is returned.
3347  */
3348 static char *
3349 s_jhtml_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3350 {
3351   jhtml_t *jhtml = GET_JHTML(pdoc);
3352   Doc *doc = jhtml->doc;
3353   W_L("</marquee>");
3354   return jhtml->out;
3355 }
3356 /*
3357  * vim:ts=2 et
3358  */