OSDN Git Service

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