OSDN Git Service

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