OSDN Git Service

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