OSDN Git Service

* Added features.
[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
1250   W_L("<form");
1251   /*--------------------------------------------------------------------------*/
1252   /* Get Attributes                                                           */
1253   /*--------------------------------------------------------------------------*/
1254   for (attr = qs_get_attr(doc,node);
1255        attr;
1256        attr = qs_get_next_attr(doc,attr)) {
1257     char *name = qs_get_attr_name(doc,attr);
1258     char *value = qs_get_attr_value(doc,attr);
1259     if (STRCASEEQ('a','A',"action",name)) {
1260       value = chxj_encoding_parameter(r, value);
1261       value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
1262       W_L(" action=\"");
1263       W_V(value);
1264       W_L("\"");
1265     }
1266     else if (STRCASEEQ('m','M',"method",name)) {
1267       W_L(" method=\"");
1268       W_V(value);
1269       W_L("\"");
1270     }
1271     else if (STRCASEEQ('u','U',"utn",name)) {
1272       /* ignore */
1273     }
1274     else if (STRCASEEQ('n','N',"name",name)) {
1275       W_L(" name=\"");
1276       W_V(value);
1277       W_L("\"");
1278     }
1279   }
1280   W_L(">");
1281   return xhtml->out;
1282 }
1283
1284
1285 /**
1286  * It is a handler who processes the FORM tag.
1287  *
1288  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1289  *                     destination is specified.
1290  * @param node   [i]   The FORM tag node is specified.
1291  * @return The conversion result is returned.
1292  */
1293 static char *
1294 s_xhtml_1_0_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1295 {
1296   xhtml_t *xhtml = GET_XHTML(pdoc);
1297   Doc     *doc   = xhtml->doc;
1298
1299   W_L("</form>");
1300   return xhtml->out;
1301 }
1302
1303
1304 /**
1305  * It is a handler who processes the INPUT tag.
1306  *
1307  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1308  *                     destination is specified.
1309  * @param node   [i]   The INPUT tag node is specified.
1310  * @return The conversion result is returned.
1311  */
1312 static char *
1313 s_xhtml_1_0_start_input_tag(void *pdoc, Node *node) 
1314 {
1315   xhtml_t     *xhtml       = GET_XHTML(pdoc);
1316   Doc         *doc         = xhtml->doc;
1317   request_rec *r           = doc->r;
1318   char        *max_length  = NULL;
1319   char        *type        = NULL;
1320   char        *name        = NULL;
1321   char        *value       = NULL;
1322   char        *istyle      = NULL;
1323   char        *size        = NULL;
1324   char        *checked     = NULL;
1325   char        *accesskey   = NULL;
1326
1327   W_L("<input");
1328   /*--------------------------------------------------------------------------*/
1329   /* Get Attributes                                                           */
1330   /*--------------------------------------------------------------------------*/
1331   type       = qs_get_type_attr(doc, node, r);
1332   name       = qs_get_name_attr(doc, node, r);
1333   value      = qs_get_value_attr(doc,node,r);
1334   istyle     = qs_get_istyle_attr(doc,node,r);
1335   max_length = qs_get_maxlength_attr(doc,node,r);
1336   checked    = qs_get_checked_attr(doc,node,r);
1337   accesskey  = qs_get_accesskey_attr(doc, node, r);
1338   size       = qs_get_size_attr(doc, node, r);
1339
1340   if (type) {
1341     type = qs_trim_string(doc->buf.pool, type);
1342     if (type && (STRCASEEQ('t','T',"text",    type) ||
1343                  STRCASEEQ('p','P',"password",type) ||
1344                  STRCASEEQ('c','C',"checkbox",type) ||
1345                  STRCASEEQ('r','R',"radio",   type) ||
1346                  STRCASEEQ('h','H',"hidden",  type) ||
1347                  STRCASEEQ('s','S',"submit",  type) ||
1348                  STRCASEEQ('r','R',"reset",   type))) {
1349       W_L(" type=\"");
1350       W_V(type);
1351       W_L("\"");
1352     }
1353   }
1354   if (size && *size) {
1355     W_L(" size=\"");
1356     W_V(size);
1357     W_L("\"");
1358   }
1359   if (name && *name) {
1360     W_L(" name=\"");
1361     W_V(name);
1362     W_L("\"");
1363   }
1364   if (value && *value) {
1365     W_L(" value=\"");
1366     W_V(chxj_add_slash_to_doublequote(doc->pool,value));
1367     W_L("\"");
1368   }
1369   if (accesskey && *accesskey) {
1370     W_L(" accesskey=\"");
1371     W_V(accesskey);
1372     W_L("\"");
1373   }
1374   if (istyle && *istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1375     char *fmt = qs_conv_istyle_to_format(r,istyle);
1376     if (max_length && *max_length) {
1377       int ii;
1378       for (ii=0; (unsigned int)ii<strlen(max_length); ii++) {
1379         if (max_length[ii] < '0' || max_length[ii] > '9') {
1380           max_length = apr_psprintf(r->pool, "0");
1381           break;
1382         }
1383       }
1384
1385       if (strcmp(max_length, "0")) {
1386         char *vv = apr_psprintf(r->pool, " FORMAT=\"%d%s\"", atoi(max_length), fmt);
1387         W_V(vv);
1388       }
1389     }
1390     else {
1391       W_L(" FORMAT=\"");
1392       W_L("*");
1393       W_V(fmt);
1394       W_L("\"");
1395     }
1396   }
1397   else {
1398     if (max_length && *max_length) {
1399       if (chxj_chk_numeric(max_length) != 0) {
1400         max_length = apr_psprintf(r->pool, "0");
1401       }
1402       if (strcmp(max_length, "0")) {
1403         char *vv = apr_psprintf(r->pool, " FORMAT=\"%dm\"", atoi(max_length));
1404         W_V(vv);
1405       }
1406     }
1407   }
1408   /*--------------------------------------------------------------------------*/
1409   /* The figure is default for the password.                                  */
1410   /*--------------------------------------------------------------------------*/
1411   if (type && (istyle == NULL || *istyle == 0) && STRCASEEQ('p','P',"password", type) && ! xhtml->entryp->pc_flag) {
1412     if (max_length) {
1413       W_L(" FORMAT=\"");
1414       W_V(max_length);
1415       W_L("N\"");
1416     }
1417     else {
1418       W_L(" FORMAT=\"*N\"");
1419     }
1420   }
1421   if (checked) {
1422     W_L(" checked=\"checked\"");
1423   }
1424   W_L(" />");
1425   return xhtml->out;
1426 }
1427
1428
1429 /**
1430  * It is a handler who processes the INPUT tag.
1431  *
1432  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1433  *                     destination is specified.
1434  * @param node   [i]   The INPUT tag node is specified.
1435  * @return The conversion result is returned.
1436  */
1437 static char *
1438 s_xhtml_1_0_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1439 {
1440   xhtml_t *xhtml = GET_XHTML(pdoc);
1441
1442   return xhtml->out;
1443 }
1444
1445
1446 /**
1447  * It is a handler who processes the CENTER tag.
1448  *
1449  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1450  *                     destination is specified.
1451  * @param node   [i]   The CENTER tag node is specified.
1452  * @return The conversion result is returned.
1453  */
1454 static char *
1455 s_xhtml_1_0_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1456 {
1457   xhtml_t *xhtml = GET_XHTML(pdoc);
1458   Doc     *doc   = xhtml->doc;
1459
1460   W_L("<center>");
1461   return xhtml->out;
1462 }
1463
1464
1465 /**
1466  * It is a handler who processes the CENTER tag.
1467  *
1468  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1469  *                     destination is specified.
1470  * @param node   [i]   The CENTER tag node is specified.
1471  * @return The conversion result is returned.
1472  */
1473 static char *
1474 s_xhtml_1_0_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1475 {
1476   xhtml_t *xhtml = GET_XHTML(pdoc);
1477   Doc     *doc   = xhtml->doc;
1478
1479   W_L("</center>");
1480   return xhtml->out;
1481 }
1482
1483
1484 /**
1485  * It is a handler who processes the HR tag.
1486  *
1487  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1488  *                     destination is specified.
1489  * @param node   [i]   The HR tag node is specified.
1490  * @return The conversion result is returned.
1491  */
1492 static char *
1493 s_xhtml_1_0_start_hr_tag(void *pdoc, Node *node)
1494 {
1495   xhtml_t *xhtml = GET_XHTML(pdoc);
1496   Doc     *doc   = xhtml->doc;
1497   Attr    *attr;
1498
1499   W_L("<hr");
1500  
1501   for (attr = qs_get_attr(doc,node);
1502        attr; 
1503        attr = qs_get_next_attr(doc,attr)) {
1504     char *name = qs_get_attr_name(doc,attr);
1505     char *value = qs_get_attr_value(doc,attr);
1506     if (STRCASEEQ('a','A',"align", name)) {
1507       /*----------------------------------------------------------------------*/
1508       /* CHTML 1.0                                                            */
1509       /*----------------------------------------------------------------------*/
1510       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1511         W_L(" align=\"");
1512         W_V(value);
1513         W_L("\"");
1514       }
1515     }
1516     else if (STRCASEEQ('s','S',"size", name)) {
1517       /*----------------------------------------------------------------------*/
1518       /* CHTML 1.0                                                            */
1519       /*----------------------------------------------------------------------*/
1520       if (value && *value) {
1521         W_L(" size=\"");
1522         W_V(value);
1523         W_L("\"");
1524       }
1525     }
1526     else if (STRCASEEQ('w','W',"width", name)) {
1527       /*----------------------------------------------------------------------*/
1528       /* CHTML 1.0                                                            */
1529       /*----------------------------------------------------------------------*/
1530       if (value && *value) {
1531         W_L(" width=\"");
1532         W_V(value);
1533         W_L("\"");
1534       }
1535     }
1536     else if (STRCASEEQ('n','N',"noshade", name)) {
1537       /*----------------------------------------------------------------------*/
1538       /* CHTML 1.0                                                            */
1539       /*----------------------------------------------------------------------*/
1540       /* ignore */
1541     }
1542     else if (STRCASEEQ('c','C',"color", name)) {
1543       /*----------------------------------------------------------------------*/
1544       /* CHTML 4.0                                                            */
1545       /*----------------------------------------------------------------------*/
1546       /* ignore */
1547     }
1548   }
1549   W_L(" />");
1550   return xhtml->out;
1551 }
1552
1553
1554 /**
1555  * It is a handler who processes the HR tag.
1556  *
1557  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1558  *                     destination is specified.
1559  * @param node   [i]   The HR tag node is specified.
1560  * @return The conversion result is returned.
1561  */
1562 static char *
1563 s_xhtml_1_0_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1564 {
1565   xhtml_t *xhtml = GET_XHTML(pdoc);
1566
1567   return xhtml->out;
1568 }
1569
1570
1571 /**
1572  * It is a handler who processes the PRE tag.
1573  *
1574  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1575  *                     destination is specified.
1576  * @param node   [i]   The PRE tag node is specified.
1577  * @return The conversion result is returned.
1578  */
1579 static char *
1580 s_xhtml_1_0_start_pre_tag(void* pdoc, Node* UNUSED(node)) 
1581 {
1582   xhtml_t *xhtml = GET_XHTML(pdoc);
1583   Doc     *doc   = xhtml->doc;
1584
1585   xhtml->pre_flag++;
1586   W_L("<pre>");
1587   return xhtml->out;
1588 }
1589
1590
1591 /**
1592  * It is a handler who processes the PRE tag.
1593  *
1594  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1595  *                     destination is specified.
1596  * @param node   [i]   The PRE tag node is specified.
1597  * @return The conversion result is returned.
1598  */
1599 static char *
1600 s_xhtml_1_0_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
1601 {
1602   xhtml_t *xhtml = GET_XHTML(pdoc);
1603   Doc     *doc   = xhtml->doc;
1604
1605   W_L("</pre>");
1606   xhtml->pre_flag--;
1607
1608   return xhtml->out;
1609 }
1610
1611
1612 /**
1613  * It is a handler who processes the P tag.
1614  *
1615  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1616  *                     destination is specified.
1617  * @param node   [i]   The P tag node is specified.
1618  * @return The conversion result is returned.
1619  */
1620 static char *
1621 s_xhtml_1_0_start_p_tag(void *pdoc, Node *node) 
1622 {
1623   xhtml_t *xhtml = GET_XHTML(pdoc);
1624   Doc     *doc   = xhtml->doc;
1625   Attr    *attr;
1626   char    *align = NULL;
1627
1628   W_L("<p");
1629   for (attr = qs_get_attr(doc,node);
1630        attr;
1631        attr = qs_get_next_attr(doc,attr)) {
1632     char *nm  = qs_get_attr_name(doc,attr);
1633     char *val = qs_get_attr_value(doc,attr);
1634     if (STRCASEEQ('a','A',"align", nm)) {
1635       /*----------------------------------------------------------------------*/
1636       /* CHTML 1.0 (W3C version 3.2)                                          */
1637       /*----------------------------------------------------------------------*/
1638       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
1639         align = apr_pstrdup(doc->buf.pool, val);
1640         break;
1641       }
1642     }
1643   }
1644   if (align) {
1645     W_L(" align=\"");
1646     W_V(align);
1647     W_L("\"");
1648   }
1649   W_L(">");
1650   return xhtml->out;
1651 }
1652
1653
1654 /**
1655  * It is a handler who processes the P tag.
1656  *
1657  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1658  *                     destination is specified.
1659  * @param node   [i]   The P tag node is specified.
1660  * @return The conversion result is returned.
1661  */
1662 static char *
1663 s_xhtml_1_0_end_p_tag(void *pdoc, Node *UNUSED(child)) 
1664 {
1665   xhtml_t *xhtml = GET_XHTML(pdoc);
1666   Doc     *doc   = xhtml->doc;
1667
1668   W_L("</p>");
1669   return xhtml->out;
1670 }
1671
1672
1673 /**
1674  * It is a handler who processes the UL tag.
1675  *
1676  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1677  *                     destination is specified.
1678  * @param node   [i]   The UL tag node is specified.
1679  * @return The conversion result is returned.
1680  */
1681 static char *
1682 s_xhtml_1_0_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
1683 {
1684   xhtml_t *xhtml = GET_XHTML(pdoc);
1685   Doc     *doc   = xhtml->doc;
1686
1687   W_L("<ul>");
1688   return xhtml->out;
1689 }
1690
1691
1692 /**
1693  * It is a handler who processes the UL tag.
1694  *
1695  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1696  *                     destination is specified.
1697  * @param node   [i]   The UL tag node is specified.
1698  * @return The conversion result is returned.
1699  */
1700 static char *
1701 s_xhtml_1_0_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1702 {
1703   xhtml_t *xhtml = GET_XHTML(pdoc);
1704   Doc     *doc   = xhtml->doc;
1705
1706   W_L("</ul>");
1707   return xhtml->out;
1708 }
1709
1710
1711 /**
1712  * It is a handler who processes the H1 tag.
1713  *
1714  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1715  *                     destination is specified.
1716  * @param node   [i]   The H1 tag node is specified.
1717  * @return The conversion result is returned.
1718  */
1719 static char *
1720 s_xhtml_1_0_start_h1_tag(void *pdoc, Node *node) 
1721 {
1722   xhtml_t *xhtml = GET_XHTML(pdoc);
1723   Doc     *doc   = xhtml->doc;
1724   Attr    *attr;
1725
1726   W_L("<h1");
1727   for (attr = qs_get_attr(doc,node);
1728        attr;
1729        attr = qs_get_next_attr(doc,attr)) {
1730     char* name;
1731     char* value;
1732     name  = qs_get_attr_name(doc,attr);
1733     value = qs_get_attr_value(doc,attr);
1734     if (STRCASEEQ('a','A',"align", name)) {
1735       if (value) {
1736         if (STRCASEEQ('l','L',"left",value)) {
1737           W_L(" style=\"");
1738           W_L("text-align:left");
1739           W_L("\"");
1740         }
1741         else if (STRCASEEQ('r','R',"right",value)) {
1742           W_L(" style=\"");
1743           W_L("text-align:right");
1744           W_L("\"");
1745         }
1746         else if (STRCASEEQ('c','C',"center",value)) {
1747           W_L(" style=\"");
1748           W_L("text-align:center");
1749           W_L("\"");
1750         }
1751         break;
1752       }
1753     }
1754   }
1755   W_L(">");
1756   return xhtml->out;
1757 }
1758
1759
1760 /**
1761  * It is a handler who processes the H1 tag.
1762  *
1763  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1764  *                     destination is specified.
1765  * @param node   [i]   The H1 tag node is specified.
1766  * @return The conversion result is returned.
1767  */
1768 static char *
1769 s_xhtml_1_0_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
1770 {
1771   xhtml_t *xhtml = GET_XHTML(pdoc);
1772   Doc     *doc   = xhtml->doc;
1773
1774   W_L("</h1>");
1775   return xhtml->out;
1776 }
1777
1778
1779 /**
1780  * It is a handler who processes the H2 tag.
1781  *
1782  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1783  *                     destination is specified.
1784  * @param node   [i]   The H2 tag node is specified.
1785  * @return The conversion result is returned.
1786  */
1787 static char *
1788 s_xhtml_1_0_start_h2_tag(void *pdoc, Node *node)
1789 {
1790   xhtml_t *xhtml = GET_XHTML(pdoc);
1791   Doc     *doc = xhtml->doc;
1792   Attr    *attr;
1793
1794   W_L("<h2");
1795   for (attr = qs_get_attr(doc,node);
1796        attr;
1797        attr = qs_get_next_attr(doc,attr)) {
1798     char* name;
1799     char* value;
1800     name  = qs_get_attr_name(doc,attr);
1801     value = qs_get_attr_value(doc,attr);
1802     if (STRCASEEQ('a','A',"align", name)) {
1803       if (value) {
1804         if (STRCASEEQ('l','L',"left",value)) {
1805           W_L(" style=\"");
1806           W_L("text-align:left");
1807           W_L("\"");
1808         }
1809         else if (STRCASEEQ('r','R',"right",value)) {
1810           W_L(" style=\"");
1811           W_L("text-align:right");
1812           W_L("\"");
1813         }
1814         else if (STRCASEEQ('c','C',"center",value)) {
1815           W_L(" style=\"");
1816           W_L("text-align:center");
1817           W_L("\"");
1818         }
1819         break;
1820       }
1821     }
1822   }
1823   W_L(">");
1824   return xhtml->out;
1825 }
1826
1827
1828 /**
1829  * It is a handler who processes the H2 tag.
1830  *
1831  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1832  *                     destination is specified.
1833  * @param node   [i]   The H2 tag node is specified.
1834  * @return The conversion result is returned.
1835  */
1836 static char *
1837 s_xhtml_1_0_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
1838 {
1839   xhtml_t *xhtml = GET_XHTML(pdoc);
1840   Doc     *doc   = xhtml->doc;
1841
1842   W_L("</h2>");
1843   return xhtml->out;
1844 }
1845
1846
1847 /**
1848  * It is a handler who processes the H3 tag.
1849  *
1850  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1851  *                     destination is specified.
1852  * @param node   [i]   The H3 tag node is specified.
1853  * @return The conversion result is returned.
1854  */
1855 static char *
1856 s_xhtml_1_0_start_h3_tag(void *pdoc, Node *node)
1857 {
1858   xhtml_t *xhtml = GET_XHTML(pdoc);
1859   Doc     *doc   = xhtml->doc;
1860   Attr    *attr;
1861
1862   W_L("<h3");
1863   for (attr = qs_get_attr(doc,node);
1864        attr;
1865        attr = qs_get_next_attr(doc,attr)) {
1866     char* name;
1867     char* value;
1868     name  = qs_get_attr_name(doc,attr);
1869     value = qs_get_attr_value(doc,attr);
1870     if (STRCASEEQ('a','A',"align", name)) {
1871       if (value) {
1872         if (STRCASEEQ('l','L',"left",value)) {
1873           W_L(" style=\"");
1874           W_L("text-align:left");
1875           W_L("\"");
1876         }
1877         else if (STRCASEEQ('r','R',"right",value)) {
1878           W_L(" style=\"");
1879           W_L("text-align:right");
1880           W_L("\"");
1881         }
1882         else if (STRCASEEQ('c','C',"center",value)) {
1883           W_L(" style=\"");
1884           W_L("text-align:center");
1885           W_L("\"");
1886         }
1887         break;
1888       }
1889     }
1890   }
1891   W_L(">");
1892   return xhtml->out;
1893 }
1894
1895
1896 /**
1897  * It is a handler who processes the H3 tag.
1898  *
1899  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1900  *                     destination is specified.
1901  * @param node   [i]   The H3 tag node is specified.
1902  * @return The conversion result is returned.
1903  */
1904 static char *
1905 s_xhtml_1_0_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
1906 {
1907   xhtml_t *xhtml = GET_XHTML(pdoc);
1908   Doc     *doc   = xhtml->doc;
1909
1910   W_L("</h3>");
1911   return xhtml->out;
1912 }
1913
1914
1915 /**
1916  * It is a handler who processes the H4 tag.
1917  *
1918  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1919  *                     destination is specified.
1920  * @param node   [i]   The H4 tag node is specified.
1921  * @return The conversion result is returned.
1922  */
1923 static char *
1924 s_xhtml_1_0_start_h4_tag(void *pdoc, Node *node)
1925 {
1926   xhtml_t *xhtml = GET_XHTML(pdoc);
1927   Doc     *doc   = xhtml->doc;
1928   Attr    *attr;
1929
1930   W_L("<h4");
1931   for (attr = qs_get_attr(doc,node);
1932        attr;
1933        attr = qs_get_next_attr(doc,attr)) {
1934     char* name;
1935     char* value;
1936     name  = qs_get_attr_name(doc,attr);
1937     value = qs_get_attr_value(doc,attr);
1938     if (STRCASEEQ('a','A',"align", name)) {
1939       if (value) {
1940         if (STRCASEEQ('l','L',"left",value)) {
1941           W_L(" style=\"");
1942           W_L("text-align:left");
1943           W_L("\"");
1944         }
1945         else if (STRCASEEQ('r','R',"right",value)) {
1946           W_L(" style=\"");
1947           W_L("text-align:right");
1948           W_L("\"");
1949         }
1950         else if (STRCASEEQ('c','C',"center",value)) {
1951           W_L(" style=\"");
1952           W_L("text-align:center");
1953           W_L("\"");
1954         }
1955         break;
1956       }
1957     }
1958   }
1959   W_L(">");
1960   return xhtml->out;
1961 }
1962
1963
1964 /**
1965  * It is a handler who processes the H4 tag.
1966  *
1967  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1968  *                     destination is specified.
1969  * @param node   [i]   The H4 tag node is specified.
1970  * @return The conversion result is returned.
1971  */
1972 static char *
1973 s_xhtml_1_0_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
1974 {
1975   xhtml_t *xhtml = GET_XHTML(pdoc);
1976   Doc     *doc   = xhtml->doc;
1977
1978   W_L("</h4>");
1979   return xhtml->out;
1980 }
1981
1982
1983 /**
1984  * It is a handler who processes the H5 tag.
1985  *
1986  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1987  *                     destination is specified.
1988  * @param node   [i]   The H5 tag node is specified.
1989  * @return The conversion result is returned.
1990  */
1991 static char *
1992 s_xhtml_1_0_start_h5_tag(void *pdoc, Node *node)
1993 {
1994   xhtml_t *xhtml = GET_XHTML(pdoc);
1995   Doc     *doc   = xhtml->doc;
1996   Attr    *attr;
1997
1998   W_L("<h5");
1999   for (attr = qs_get_attr(doc,node);
2000        attr;
2001        attr = qs_get_next_attr(doc,attr)) {
2002     char* name;
2003     char* value;
2004     name  = qs_get_attr_name(doc,attr);
2005     value = qs_get_attr_value(doc,attr);
2006     if (STRCASEEQ('a','A',"align", name)) {
2007       if (value) {
2008         if (STRCASEEQ('l','L',"left",value)) {
2009           W_L(" style=\"");
2010           W_L("text-align:left");
2011           W_L("\"");
2012         }
2013         else if (STRCASEEQ('r','R',"right",value)) {
2014           W_L(" style=\"");
2015           W_L("text-align:right");
2016           W_L("\"");
2017         }
2018         else if (STRCASEEQ('c','C',"center",value)) {
2019           W_L(" style=\"");
2020           W_L("text-align:center");
2021           W_L("\"");
2022         }
2023         break;
2024       }
2025     }
2026   }
2027   W_L(">");
2028   return xhtml->out;
2029 }
2030
2031
2032 /**
2033  * It is a handler who processes the H5 tag.
2034  *
2035  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2036  *                     destination is specified.
2037  * @param node   [i]   The H5 tag node is specified.
2038  * @return The conversion result is returned.
2039  */
2040 static char *
2041 s_xhtml_1_0_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
2042 {
2043   xhtml_t *xhtml = GET_XHTML(pdoc);
2044   Doc     *doc   = xhtml->doc;
2045
2046   W_L("</h5>");
2047   return xhtml->out;
2048 }
2049
2050
2051 /**
2052  * It is a handler who processes the H6 tag.
2053  *
2054  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2055  *                     destination is specified.
2056  * @param node   [i]   The H6 tag node is specified.
2057  * @return The conversion result is returned.
2058  */
2059 static char *
2060 s_xhtml_1_0_start_h6_tag(void *pdoc, Node *node)
2061 {
2062   xhtml_t *xhtml = GET_XHTML(pdoc);
2063   Doc     *doc   = xhtml->doc;
2064   Attr    *attr;
2065
2066   W_L("<h6");
2067   for (attr = qs_get_attr(doc,node);
2068        attr;
2069        attr = qs_get_next_attr(doc,attr)) {
2070     char* name;
2071     char* value;
2072     name  = qs_get_attr_name(doc,attr);
2073     value = qs_get_attr_value(doc,attr);
2074     if (STRCASEEQ('a','A',"align", name)) {
2075       if (value) {
2076         if (STRCASEEQ('l','L',"left",value)) {
2077           W_L(" style=\"");
2078           W_L("text-align:left");
2079           W_L("\"");
2080         }
2081         else if (STRCASEEQ('r','R',"right",value)) {
2082           W_L(" style=\"");
2083           W_L("text-align:right");
2084           W_L("\"");
2085         }
2086         else if (STRCASEEQ('c','C',"center",value)) {
2087           W_L(" style=\"");
2088           W_L("text-align:center");
2089           W_L("\"");
2090         }
2091         break;
2092       }
2093     }
2094   }
2095   W_L(">");
2096   return xhtml->out;
2097 }
2098
2099
2100 /**
2101  * It is a handler who processes the H6 tag.
2102  *
2103  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2104  *                     destination is specified.
2105  * @param node   [i]   The H6 tag node is specified.
2106  * @return The conversion result is returned.
2107  */
2108 static char *
2109 s_xhtml_1_0_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
2110 {
2111   xhtml_t *xhtml = GET_XHTML(pdoc);
2112   Doc     *doc   = xhtml->doc;
2113
2114   W_L("</h6>");
2115   return xhtml->out;
2116 }
2117
2118
2119 /**
2120  * It is a handler who processes the OL tag.
2121  *
2122  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2123  *                     destination is specified.
2124  * @param node   [i]   The OL tag node is specified.
2125  * @return The conversion result is returned.
2126  */
2127 static char *
2128 s_xhtml_1_0_start_ol_tag(void *pdoc, Node *node)
2129 {
2130   xhtml_t *xhtml = GET_XHTML(pdoc);
2131   Doc     *doc   = xhtml->doc;
2132   Attr    *attr;
2133
2134   W_L("<ol");
2135   /*--------------------------------------------------------------------------*/
2136   /* Get Attributes                                                           */
2137   /*--------------------------------------------------------------------------*/
2138   for (attr = qs_get_attr(doc,node);
2139        attr;
2140        attr = qs_get_next_attr(doc,attr)) {
2141     char *name = qs_get_attr_name(doc,attr);
2142     char *value = qs_get_attr_value(doc,attr);
2143     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2144       W_L(" type=\"");
2145       W_V(value);
2146       W_L("\"");
2147     }
2148     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
2149       W_L(" start=\"");
2150       W_V(value);
2151       W_L("\"");
2152     }
2153   }
2154   W_L(">");
2155   return xhtml->out;
2156 }
2157
2158
2159 /**
2160  * It is a handler who processes the OL tag.
2161  *
2162  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2163  *                     destination is specified.
2164  * @param node   [i]   The OL tag node is specified.
2165  * @return The conversion result is returned.
2166  */
2167 static char *
2168 s_xhtml_1_0_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
2169 {
2170   xhtml_t *xhtml = GET_XHTML(pdoc);
2171   Doc     *doc   = xhtml->doc;
2172
2173   W_L("</ol>");
2174   return xhtml->out;
2175 }
2176
2177
2178 /**
2179  * It is a handler who processes the LI tag.
2180  *
2181  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2182  *                     destination is specified.
2183  * @param node   [i]   The LI tag node is specified.
2184  * @return The conversion result is returned.
2185  */
2186 static char *
2187 s_xhtml_1_0_start_li_tag(void *pdoc, Node *node)
2188 {
2189   xhtml_t *xhtml = GET_XHTML(pdoc);
2190   Doc     *doc   = xhtml->doc;
2191   Attr    *attr;
2192
2193   W_L("<li");
2194   /*--------------------------------------------------------------------------*/
2195   /* Get Attributes                                                           */
2196   /*--------------------------------------------------------------------------*/
2197   for (attr = qs_get_attr(doc,node);
2198        attr;
2199        attr = qs_get_next_attr(doc,attr)) {
2200     char *name = qs_get_attr_name(doc,attr);
2201     char *value = qs_get_attr_value(doc,attr);
2202     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2203       W_L(" type=\"");
2204       W_V(value);
2205       W_L("\"");
2206     }
2207     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2208       W_L(" value=\"");
2209       W_V(value);
2210       W_L("\"");
2211     }
2212   }
2213   W_L(">");
2214   return xhtml->out;
2215 }
2216
2217
2218 /**
2219  ** It is a handler who processes the LI tag.
2220  *
2221  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2222  *                     destination is specified.
2223  * @param node   [i]   The LI tag node is specified.
2224  * @return The conversion result is returned.
2225  */
2226 static char *
2227 s_xhtml_1_0_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2228 {
2229   xhtml_t *xhtml = GET_XHTML(pdoc);
2230   Doc     *doc   = xhtml->doc;
2231
2232   W_L("</li>");
2233   return xhtml->out;
2234 }
2235
2236 /**
2237  * It is a handler who processes the IMG tag.
2238  *
2239  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2240  *                     destination is specified.
2241  * @param node   [i]   The IMG tag node is specified.
2242  * @return The conversion result is returned.
2243  */
2244 static char *
2245 s_xhtml_1_0_start_img_tag(void *pdoc, Node *node) 
2246 {
2247   xhtml_t       *xhtml = GET_XHTML(pdoc);
2248   Doc           *doc   = xhtml->doc;
2249   request_rec   *r     = doc->r;
2250   Attr          *attr;
2251
2252 #ifndef IMG_NOT_CONVERT_FILENAME
2253   device_table  *spec = xhtml->spec;
2254 #endif
2255
2256   W_L("<img");
2257   /*--------------------------------------------------------------------------*/
2258   /* Get Attributes                                                           */
2259   /*--------------------------------------------------------------------------*/
2260   for (attr = qs_get_attr(doc,node);
2261        attr;
2262        attr = qs_get_next_attr(doc,attr)) {
2263     char *name  = qs_get_attr_name(doc,attr);
2264     char *value = qs_get_attr_value(doc,attr);
2265
2266     if (STRCASEEQ('s','S',"src",name)) {
2267       value = chxj_encoding_parameter(r, value);
2268       value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
2269       if (value) {
2270         value = apr_psprintf(r->pool,
2271                              "%s%c%s=true",
2272                              value,
2273                              (strchr(value, '?')) ? '&' : '?',
2274                              CHXJ_COOKIE_NOUPDATE_PARAM);
2275       }
2276 #ifdef IMG_NOT_CONVERT_FILENAME
2277
2278       W_L(" src=\"");
2279       W_V(value);
2280       W_L("\"");
2281
2282 #else
2283
2284       W_L(" src=\"");
2285       {
2286         char *vv = chxj_img_conv(r,spec,value);
2287         W_V(vv);
2288       }
2289       W_L("\"");
2290
2291 #endif
2292     }
2293     else 
2294     if (STRCASEEQ('a','A',"align",name)) {
2295       if (value && (STRCASEEQ('t','T',"top",   value) ||
2296                     STRCASEEQ('m','M',"middle",value) ||
2297                     STRCASEEQ('b','B',"bottom",value) ||
2298                     STRCASEEQ('l','L',"left",  value) ||
2299                     STRCASEEQ('r','R',"right", value))) {
2300         W_L(" align=\"");
2301         W_V(value);
2302         W_L("\"");
2303       }
2304     }
2305     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2306       W_L(" alt=\"");
2307       W_V(value);
2308       W_L("\"");
2309     }
2310     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
2311       W_L(" width=\"");
2312       W_V(value);
2313       W_L("\"");
2314     }
2315     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2316       W_L(" height=\"");
2317       W_V(value);
2318       W_L("\"");
2319     }
2320     else if (STRCASEEQ('h','H',"hspace",name) && value && *value) {
2321       W_L(" hspace=\"");
2322       W_V(value);
2323       W_L("\"");
2324     }
2325     else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2326       W_L(" vspace=\"");
2327       W_V(value);
2328       W_L("\"");
2329     }
2330   }
2331   W_L(" />");
2332   return xhtml->out;
2333 }
2334
2335
2336 /**
2337  * It is a handler who processes the IMG tag.
2338  *
2339  * @param xhtml  [i/o] The pointer to the XHTML structure at the output
2340  *                     destination is specified.
2341  * @param node   [i]   The IMG tag node is specified.
2342  * @return The conversion result is returned.
2343  */
2344 static char *
2345 s_xhtml_1_0_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2346 {
2347   xhtml_t *xhtml = GET_XHTML(pdoc);
2348
2349   return xhtml->out;
2350 }
2351
2352
2353 /**
2354  * It is a handler who processes the SELECT tag.
2355  *
2356  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2357  *                     destination is specified.
2358  * @param node   [i]   The SELECT tag node is specified.
2359  * @return The conversion result is returned.
2360  */
2361 static char *
2362 s_xhtml_1_0_start_select_tag(void *pdoc, Node *child)
2363 {
2364   xhtml_t *xhtml    = GET_XHTML(pdoc);
2365   Doc     *doc      = xhtml->doc;
2366   char    *size     = NULL;
2367   char    *name     = NULL;
2368   char    *multiple = NULL;
2369   Attr    *attr;
2370
2371
2372   W_L("<select");
2373   for (attr = qs_get_attr(doc,child);
2374        attr;
2375        attr = qs_get_next_attr(doc,attr)) {
2376     char *nm  = qs_get_attr_name(doc,attr);
2377     char *val = qs_get_attr_value(doc,attr);
2378     if (STRCASEEQ('s','S',"size",nm)) {
2379       /*----------------------------------------------------------------------*/
2380       /* CHTML 1.0 version 2.0                                                */
2381       /*----------------------------------------------------------------------*/
2382       size = apr_pstrdup(doc->buf.pool, val);
2383     }
2384     else if (STRCASEEQ('n','N',"name",nm)) {
2385       /*----------------------------------------------------------------------*/
2386       /* CHTML 1.0 version 2.0                                                */
2387       /*----------------------------------------------------------------------*/
2388       name = apr_pstrdup(doc->buf.pool, val);
2389     }
2390     else if (STRCASEEQ('m','M',"multiple",nm)) {
2391       /*----------------------------------------------------------------------*/
2392       /* CHTML 1.0 version 2.0                                                */
2393       /*----------------------------------------------------------------------*/
2394       multiple = apr_pstrdup(doc->buf.pool, val);
2395     }
2396   }
2397   if (size && *size) {
2398     W_L(" size=\"");
2399     W_V(size);
2400     W_L("\"");
2401   }
2402   if (name && *name) {
2403     W_L(" name=\"");
2404     W_V(name);
2405     W_L("\"");
2406   }
2407   if (multiple) {
2408     /* "true" is *NOT* W3C. it is specification of WAP2.0 for EZWEB */
2409     W_L(" multiple=\"true\"");
2410   }
2411   W_L(">\r\n");
2412   return xhtml->out;
2413 }
2414
2415
2416 /**
2417  * It is a handler who processes the SELECT tag.
2418  *
2419  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2420  *                     destination is specified.
2421  * @param node   [i]   The SELECT tag node is specified.
2422  * @return The conversion result is returned.
2423  */
2424 static char *
2425 s_xhtml_1_0_end_select_tag(void *pdoc, Node *UNUSED(child))
2426 {
2427   xhtml_t *xhtml = GET_XHTML(pdoc);
2428   Doc     *doc   = xhtml->doc;
2429
2430   W_L("</select>\r\n");
2431   return xhtml->out;
2432 }
2433
2434
2435 /**
2436  * It is a handler who processes the OPTION tag.
2437  *
2438  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2439  *                     destination is specified.
2440  * @param node   [i]   The OPTION tag node is specified.
2441  * @return The conversion result is returned.
2442  */
2443 static char *
2444 s_xhtml_1_0_start_option_tag(void *pdoc, Node *child)
2445 {
2446   xhtml_t *xhtml = GET_XHTML(pdoc);
2447   Doc     *doc   = xhtml->doc;
2448   Attr    *attr;
2449
2450   char *selected   = NULL;
2451   char *value      = NULL;
2452
2453   W_L("<option");
2454   for (attr = qs_get_attr(doc,child);
2455        attr;
2456        attr = qs_get_next_attr(doc,attr)) {
2457     char *nm  = qs_get_attr_name(doc,attr);
2458     char *val = qs_get_attr_value(doc,attr);
2459     if (STRCASEEQ('s','S',"selected",nm)) {
2460       /* CHTML version 2.0 */
2461       selected = apr_pstrdup(doc->buf.pool, val);
2462     }
2463     else if (STRCASEEQ('v','V',"value",nm)) {
2464       /* CHTML version 2.0 */
2465       value = apr_pstrdup(doc->buf.pool, val);
2466     }
2467   }
2468   if (value && *value) {
2469     W_L(" value=\"");
2470     W_V(value);
2471     W_L("\"");
2472   }
2473   if (selected) {
2474     W_L(" selected=\"selected\"");
2475   }
2476   W_L(">");
2477   return xhtml->out;
2478 }
2479
2480
2481 /**
2482  * It is a handler who processes the OPTION tag.
2483  *
2484  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2485  *                     destination is specified.
2486  * @param node   [i]   The OPTION tag node is specified.
2487  * @return The conversion result is returned.
2488  */
2489 static char *
2490 s_xhtml_1_0_end_option_tag(void *pdoc, Node *UNUSED(child))
2491 {
2492   xhtml_t *xhtml = GET_XHTML(pdoc);
2493   Doc     *doc   = xhtml->doc;
2494
2495   W_L("</option>\r\n");
2496   return xhtml->out;
2497 }
2498
2499
2500 /**
2501  * It is a handler who processes the DIV tag.
2502  *
2503  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2504  *                     destination is specified.
2505  * @param node   [i]   The DIV tag node is specified.
2506  * @return The conversion result is returned.
2507  */
2508 static char *
2509 s_xhtml_1_0_start_div_tag(void *pdoc, Node *child)
2510 {
2511   xhtml_t *xhtml = GET_XHTML(pdoc);
2512   Doc     *doc   = xhtml->doc;
2513   Attr    *attr;
2514   char    *align   = NULL;
2515
2516   W_L("<div");
2517   for (attr = qs_get_attr(doc,child);
2518        attr;
2519        attr = qs_get_next_attr(doc,attr)) {
2520     char *nm  = qs_get_attr_name(doc,attr);
2521     char *val = qs_get_attr_value(doc,attr);
2522     if (STRCASEEQ('a','A',"align",nm)) {
2523       /*=====================================================================*/
2524       /* CHTML version 3.2                                                   */
2525       /*=====================================================================*/
2526       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2527         align = apr_pstrdup(doc->buf.pool, val);
2528       }
2529     }
2530   }
2531   if (align) {
2532     W_L(" align=\"");
2533     W_V(align);
2534     W_L("\"");
2535   }
2536   W_L(">");
2537   return xhtml->out;
2538 }
2539
2540
2541 /**
2542  * It is a handler who processes the DIV tag.
2543  *
2544  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2545  *                     destination is specified.
2546  * @param node   [i]   The DIV tag node is specified.
2547  * @return The conversion result is returned.
2548  */
2549 static char *
2550 s_xhtml_1_0_end_div_tag(void *pdoc, Node *UNUSED(child))
2551 {
2552   xhtml_t *xhtml = GET_XHTML(pdoc);
2553   Doc     *doc   = xhtml->doc;
2554   W_L("</div>\r\n");
2555   return xhtml->out;
2556 }
2557
2558
2559 /**
2560  * It is a handler who processes the B tag.
2561  *
2562  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2563  *                     destination is specified.
2564  * @param node   [i]   The B tag node is specified.
2565  * @return The conversion result is returned.
2566  */
2567 static char *
2568 s_xhtml_1_0_start_b_tag(void *pdoc, Node *UNUSED(child))
2569 {
2570   xhtml_t *xhtml = GET_XHTML(pdoc);
2571   Doc     *doc   = xhtml->doc;
2572
2573   W_L("<div style=\"font-weight:bold\">");
2574   return xhtml->out;
2575 }
2576
2577
2578 /**
2579  * It is a handler who processes the B tag.
2580  *
2581  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2582  *                     destination is specified.
2583  * @param node   [i]   The B tag node is specified.
2584  * @return The conversion result is returned.
2585  */
2586 static char *
2587 s_xhtml_1_0_end_b_tag(void *pdoc, Node *UNUSED(child))
2588 {
2589   xhtml_t *xhtml = GET_XHTML(pdoc);
2590   Doc     *doc   = xhtml->doc;
2591
2592   W_L("</div>\n");
2593   return xhtml->out;
2594 }
2595
2596
2597 /**
2598  * It is a handler who processes the CHXJ:IF tag.
2599  *
2600  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2601  *                     destination is specified.
2602  * @param node   [i]   The CHXJ:IF tag node is specified.
2603  */
2604 static char *
2605 s_xhtml_1_0_chxjif_tag(void *pdoc, Node *node)
2606 {
2607   xhtml_t      *xhtml = GET_XHTML(pdoc);
2608   Doc          *doc   = xhtml->doc;
2609   Node         *child;
2610
2611   for (child = qs_get_child_node(doc, node);
2612        child;
2613        child = qs_get_next_node(doc, child)) {
2614     W_V(child->otext);
2615     s_xhtml_1_0_chxjif_tag(xhtml, child);
2616   }
2617
2618   return NULL;
2619 }
2620
2621
2622 /**
2623  * It is a handler who processes the TEXTARE tag.
2624  *
2625  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2626  *                     destination is specified.
2627  * @param node   [i]   The TEXTAREA tag node is specified.
2628  * @return The conversion result is returned.
2629  */
2630 static char *
2631 s_xhtml_1_0_start_textarea_tag(void *pdoc, Node *node) 
2632 {
2633   xhtml_t *xhtml = GET_XHTML(pdoc);
2634   Doc     *doc   = xhtml->doc;
2635   Attr    *attr;
2636
2637   xhtml->textarea_flag++;
2638   W_L("<textarea");
2639   for (attr = qs_get_attr(doc,node);
2640        attr;
2641        attr = qs_get_next_attr(doc,attr)) {
2642     char *name  = qs_get_attr_name(doc,attr);
2643     char *value = qs_get_attr_value(doc,attr);
2644     if (STRCASEEQ('n','N',"name",name) && value && *value) {
2645       W_L(" name=\"");
2646       W_V(value);
2647       W_L("\"");
2648     }
2649     else if (STRCASEEQ('r','R',"rows",name) && value && *value) {
2650       W_L(" rows=\"");
2651       W_V(value);
2652       W_L("\"");
2653     }
2654     else if (STRCASEEQ('c','C',"cols",name) && value && *value) {
2655       W_L(" cols=\"");
2656       W_V(value);
2657       W_L("\"");
2658     }
2659     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
2660       char *fmt = qs_conv_istyle_to_format(doc->r,value);
2661       W_L(" FORMAT=\"*");
2662       W_V(fmt);
2663       W_L("\"");
2664     }
2665     else if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
2666       W_L(" accesskey=\"");
2667       W_V(value);
2668       W_L("\"");
2669     }
2670   }
2671   W_L(">\r\n");
2672   return xhtml->out;
2673 }
2674
2675
2676 /**
2677  * It is a handler who processes the TEXTAREA tag.
2678  *
2679  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2680  *                     destination is specified.
2681  * @param node   [i]   The TEXTAREA tag node is specified.
2682  * @return The conversion result is returned.
2683  */
2684 static char *
2685 s_xhtml_1_0_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
2686 {
2687   xhtml_t *xhtml = GET_XHTML(pdoc);
2688   Doc     *doc   = xhtml->doc;
2689
2690   W_L("</textarea>\r\n");
2691   xhtml->textarea_flag--;
2692
2693   return xhtml->out;
2694 }
2695
2696 static char *
2697 s_xhtml_1_0_text_tag(void *pdoc, Node *child)
2698 {
2699   xhtml_t     *xhtml   = GET_XHTML(pdoc);
2700   Doc         *doc     = xhtml->doc;
2701   request_rec *r       = doc->r;
2702   char        *textval;
2703   char        *tmp;
2704   char        *tdst;
2705   char        one_byte[2];
2706   int         ii;
2707   int         tdst_len;
2708   
2709   textval = qs_get_node_value(doc,child);
2710   if (strlen(textval) == 0) {
2711     return xhtml->out;
2712   }
2713   
2714   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2715   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2716   
2717   tdst     = qs_alloc_zero_byte_string(r);
2718   memset(one_byte, 0, sizeof(one_byte));
2719   tdst_len = 0;
2720   
2721   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2722     char *out;
2723     int rtn = s_xhtml_search_emoji(xhtml, &textval[ii], &out);
2724     if (rtn != 0) {
2725       DBG(r,"[%s][%d]", out, rtn);
2726       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2727       ii+=(rtn - 1);
2728       continue;
2729     }
2730     if (is_sjis_kanji(textval[ii])) {
2731       one_byte[0] = textval[ii+0];
2732       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2733       one_byte[0] = textval[ii+1];
2734       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2735       ii++;
2736     }
2737     else if (xhtml->pre_flag) {
2738       one_byte[0] = textval[ii+0];
2739       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2740     }
2741     else if (xhtml->textarea_flag) {
2742       one_byte[0] = textval[ii+0];
2743       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2744     }
2745     else if (textval[ii] != '\r' && textval[ii] != '\n') {
2746       one_byte[0] = textval[ii+0];
2747       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2748     }
2749   }
2750   W_V(tdst);
2751   return xhtml->out;
2752 }
2753
2754
2755 /**
2756  * It is a handler who processes the BLOCKQUOTE tag.
2757  *
2758  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2759  *                     destination is specified.
2760  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2761  * @return The conversion result is returned.
2762  */
2763 static char *
2764 s_xhtml_1_0_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
2765 {
2766   xhtml_t *xhtml = GET_XHTML(pdoc);
2767   Doc     *doc   = xhtml->doc;
2768   W_L("<blockquote>");
2769   return xhtml->out;
2770 }
2771
2772
2773 /**
2774  * It is a handler who processes the BLOCKQUOTE tag.
2775  *
2776  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2777  *                     destination is specified.
2778  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2779  * @return The conversion result is returned.
2780  */
2781 static char *
2782 s_xhtml_1_0_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
2783 {
2784   xhtml_t *xhtml = GET_XHTML(pdoc);
2785   Doc     *doc   = xhtml->doc;
2786   W_L("</blockquote>");
2787   return xhtml->out;
2788 }
2789
2790
2791 /**
2792  * It is a handler who processes the DIR tag.
2793  *
2794  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2795  *                     destination is specified.
2796  * @param node   [i]   The DIR tag node is specified.
2797  * @return The conversion result is returned.
2798  */
2799 static char *
2800 s_xhtml_1_0_start_dir_tag(void *pdoc, Node *UNUSED(child))
2801 {
2802   xhtml_t *xhtml = GET_XHTML(pdoc);
2803   Doc     *doc = xhtml->doc;
2804   W_L("<dir>");
2805   return xhtml->out;
2806 }
2807
2808
2809 /**
2810  * It is a handler who processes the DIR tag.
2811  *
2812  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2813  *                     destination is specified.
2814  * @param node   [i]   The DIR tag node is specified.
2815  * @return The conversion result is returned.
2816  */
2817 static char *
2818 s_xhtml_1_0_end_dir_tag(void *pdoc, Node *UNUSED(child))
2819 {
2820   xhtml_t *xhtml = GET_XHTML(pdoc);
2821   Doc     *doc = xhtml->doc;
2822   W_L("</dir>");
2823   return xhtml->out;
2824 }
2825
2826
2827 /**
2828  * It is a handler who processes the DL tag.
2829  *
2830  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2831  *                     destination is specified.
2832  * @param node   [i]   The DL tag node is specified.
2833  * @return The conversion result is returned.
2834  */
2835 static char *
2836 s_xhtml_1_0_start_dl_tag(void *pdoc, Node *UNUSED(child))
2837 {
2838   xhtml_t *xhtml = GET_XHTML(pdoc);
2839   Doc *doc = xhtml->doc;
2840   W_L("<dl>");
2841   return xhtml->out;
2842 }
2843
2844
2845 /**
2846  * It is a handler who processes the DL tag.
2847  *
2848  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2849  *                     destination is specified.
2850  * @param node   [i]   The DL tag node is specified.
2851  * @return The conversion result is returned.
2852  */
2853 static char *
2854 s_xhtml_1_0_end_dl_tag(void *pdoc, Node *UNUSED(child))
2855 {
2856   xhtml_t *xhtml = GET_XHTML(pdoc);
2857   Doc *doc = xhtml->doc;
2858   W_L("</dl>");
2859   return xhtml->out;
2860 }
2861
2862
2863 /**
2864  * It is a handter who processes the DT tag.
2865  *
2866  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2867  *                     destination is specified.
2868  * @param node   [i]   The DT tag node is specified.
2869  * @return The conversion result is returned.
2870  */
2871 static char *
2872 s_xhtml_1_0_start_dt_tag(void *pdoc, Node *UNUSED(child))
2873 {
2874   xhtml_t *xhtml = GET_XHTML(pdoc);
2875   Doc     *doc   = xhtml->doc;
2876   W_L("<dt>");
2877   return xhtml->out;
2878 }
2879
2880
2881 /**
2882  * It is a handter who processes the DT tag.
2883  *
2884  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2885  *                     destination is specified.
2886  * @param node   [i]   The DT tag node is specified.
2887  * @return The conversion result is returned.
2888  */
2889 static char *
2890 s_xhtml_1_0_end_dt_tag(void *pdoc, Node *UNUSED(child))
2891 {
2892   xhtml_t *xhtml = GET_XHTML(pdoc);
2893   Doc     *doc   = xhtml->doc;
2894   W_L("</dt>");
2895   return xhtml->out;
2896 }
2897
2898
2899 /**
2900  * It is a handder who processes the DD tag.
2901  *
2902  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2903  *                     destination is specified.
2904  * @param node   [i]   The DD tag node is specified.
2905  * @return The conversion result is returned.
2906  */
2907 static char *
2908 s_xhtml_1_0_start_dd_tag(void *pdoc, Node *UNUSED(child))
2909 {
2910   xhtml_t *xhtml = GET_XHTML(pdoc);
2911   Doc     *doc   = xhtml->doc;
2912   W_L("<dd>");
2913   return xhtml->out;
2914 }
2915
2916
2917 /**
2918  * It is a handder who processes the DD tag.
2919  *
2920  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2921  *                     destination is specified.
2922  * @param node   [i]   The DD tag node is specified.
2923  * @return The conversion result is returned.
2924  */
2925 static char *
2926 s_xhtml_1_0_end_dd_tag(void *pdoc, Node *UNUSED(child))
2927 {
2928   xhtml_t *xhtml = GET_XHTML(pdoc);
2929   Doc     *doc   = xhtml->doc;
2930   W_L("</dd>");
2931   return xhtml->out;
2932 }
2933
2934
2935 /**
2936  * It is a handler who processes the MENU tag.
2937  *
2938  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2939  *                     destination is specified.
2940  * @param node   [i]   The MENU tag node is specified.
2941  * @return The conversion result is returned.
2942  */
2943 static char *
2944 s_xhtml_1_0_start_menu_tag(void *pdoc, Node *UNUSED(child))
2945 {
2946   xhtml_t *xhtml;
2947   Doc *doc;
2948   xhtml = GET_XHTML(pdoc);
2949   doc     = xhtml->doc;
2950   W_L("<menu>");
2951   return xhtml->out;
2952 }
2953
2954
2955 /**
2956  * It is a hanmenuer who processes the MENU tag.
2957  *
2958  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2959  *                     destination is specified.
2960  * @param node   [i]   The MENU tag node is specified.
2961  * @return The conversion result is returned.
2962  */
2963 static char *
2964 s_xhtml_1_0_end_menu_tag(void *pdoc, Node *UNUSED(child))
2965 {
2966   xhtml_t *xhtml = GET_XHTML(pdoc);
2967   Doc *doc = xhtml->doc;
2968   W_L("</menu>");
2969   return xhtml->out;
2970 }
2971
2972
2973 /**
2974  * It is a handler who processes the PLAINTEXT tag.
2975  *
2976  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2977  *                     destination is specified.
2978  * @param node   [i]   The PLAINTEXT tag node is specified.
2979  * @return The conversion result is returned.
2980  */
2981 static char *
2982 s_xhtml_1_0_start_plaintext_tag(void *pdoc, Node *node)
2983 {
2984   xhtml_t *xhtml = GET_XHTML(pdoc);
2985   Doc     *doc     = xhtml->doc;
2986   W_L("<plaintext>");
2987   s_xhtml_1_0_start_plaintext_tag_inner(pdoc,node);
2988   return xhtml->out;
2989 }
2990
2991 static char *
2992 s_xhtml_1_0_start_plaintext_tag_inner(void *pdoc, Node *node)
2993 {
2994   xhtml_t *xhtml = GET_XHTML(pdoc);
2995   Doc     *doc     = xhtml->doc;
2996   Node    *child;
2997   for (child = qs_get_child_node(doc, node);
2998        child;
2999        child = qs_get_next_node(doc, child)) {
3000     W_V(child->otext);
3001     s_xhtml_1_0_start_plaintext_tag_inner(pdoc, child);
3002   }
3003   return xhtml->out;
3004 }
3005
3006
3007 /**
3008  * It is a handler who processes the PLAINTEXT tag.
3009  *
3010  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3011  *                     destination is specified.
3012  * @param node   [i]   The PLAINTEXT tag node is specified.
3013  * @return The conversion result is returned.
3014  */
3015 static char *
3016 s_xhtml_1_0_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3017 {
3018   xhtml_t *xhtml = GET_XHTML(pdoc);
3019   Doc     *doc     = xhtml->doc;
3020   W_L("</plaintext>");
3021   return xhtml->out;
3022 }
3023
3024
3025 /**
3026  * It is a hanblinker who processes the BLINK tag.
3027  *
3028  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3029  *                     destination is specified.
3030  * @param node   [i]   The BLINK tag node is specified.
3031  * @return The conversion result is returned.
3032  */
3033 static char *
3034 s_xhtml_1_0_start_blink_tag(void *pdoc, Node *UNUSED(child))
3035 {
3036   xhtml_t *xhtml = GET_XHTML(pdoc);
3037   Doc     *doc = xhtml->doc;
3038   W_L("<blink>");
3039   return xhtml->out;
3040 }
3041
3042
3043 /**
3044  * It is a hanblinker who processes the BLINK tag.
3045  *
3046  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3047  *                     destination is specified.
3048  * @param node   [i]   The BLINK tag node is specified.
3049  * @return The conversion result is returned.
3050  */
3051 static char *
3052 s_xhtml_1_0_end_blink_tag(void *pdoc, Node *UNUSED(child))
3053 {
3054   xhtml_t *xhtml = GET_XHTML(pdoc);
3055   Doc     *doc = xhtml->doc;
3056   W_L("</blink>");
3057   return xhtml->out;
3058 }
3059
3060
3061 /**
3062  * It is a handler who processes the MARQUEE tag.
3063  *
3064  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3065  *                     destination is specified.
3066  * @param node   [i]   The MARQUEE tag node is specified.
3067  * @return The conversion result is returned.
3068  */
3069 static char *
3070 s_xhtml_1_0_start_marquee_tag(void *pdoc, Node *node)
3071 {
3072   xhtml_t *xhtml = GET_XHTML(pdoc);
3073   Doc     *doc = xhtml->doc;
3074   Attr *attr;
3075   W_L("<marquee");
3076   /*--------------------------------------------------------------------------*/
3077   /* Get Attributes                                                           */
3078   /*--------------------------------------------------------------------------*/
3079   for (attr = qs_get_attr(doc,node);
3080        attr;
3081        attr = qs_get_next_attr(doc,attr)) {
3082     char *name   = qs_get_attr_name(doc,attr);
3083     char *value  = qs_get_attr_value(doc,attr);
3084     if (STRCASEEQ('d','D',"direction", name)) {
3085       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3086         W_L(" direction=\"");
3087         W_V(value);
3088         W_L("\"");
3089       }
3090     }
3091     else if (STRCASEEQ('b','B',"behavior",name)) {
3092       if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3093         W_L(" behavior=\""); 
3094         W_V(value);
3095         W_L("\"");
3096       }
3097     }
3098     else if (STRCASEEQ('l','L',"loop",name)) {
3099       if (value && *value) {
3100         W_L(" loop=\"");
3101         W_V(value);
3102         W_L("\"");
3103       }
3104     }
3105   }
3106   W_L(">");
3107   return xhtml->out;
3108 }
3109
3110
3111 /**
3112  * It is a handler who processes the MARQUEE tag.
3113  *
3114  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3115  *                     destination is specified.
3116  * @param node   [i]   The MARQUEE tag node is specified.
3117  * @return The conversion result is returned.
3118  */
3119 static char *
3120 s_xhtml_1_0_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3121 {
3122   xhtml_t *xhtml = GET_XHTML(pdoc);
3123   Doc     *doc = xhtml->doc;
3124   W_L("</marquee>");
3125   return xhtml->out;
3126 }
3127 /*
3128  * vim:ts=2 et
3129  */