OSDN Git Service

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