OSDN Git Service

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