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       if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "telto:")) {
1034         value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
1035       }
1036       W_L(" href=\"");
1037       W_V(value);
1038       W_L("\"");
1039     }
1040     else if (STRCASEEQ('a','A',"accesskey", name)) {
1041       W_L(" accesskey=\"");
1042       W_V(value);
1043       W_L("\"");
1044     }
1045     else if (STRCASEEQ('c','C',"cti",name)) {
1046       /* ignore */
1047     }
1048     else if (STRCASEEQ('i','I',"ijam", name)) {
1049       /* ignore */
1050     }
1051     else if (STRCASEEQ('u','U',"utn", name)) {
1052       /* ignore */
1053     }
1054     else if (STRCASEEQ('t','T',"telbook",name)) {
1055       /* ignore */
1056     }
1057     else if (STRCASEEQ('k','K',"kana",name)) {
1058       /* ignore */
1059     }
1060     else if (STRCASEEQ('e','E',"email",name)) {
1061       /* ignore */
1062     }
1063     else if (STRCASEEQ('i','I',"ista",name)) {
1064       /* ignore */
1065     }
1066     else if (STRCASEEQ('i','I',"ilet",name)) {
1067       /* ignore */
1068     }
1069     else if (STRCASEEQ('i','I',"iswf",name)) {
1070       /* ignore */
1071     }
1072     else if (STRCASEEQ('i','I',"irst",name)) {
1073       /* ignore */
1074     }
1075   }
1076   W_L(">");
1077   return xhtml->out;
1078 }
1079
1080
1081 /**
1082  * It is a handler who processes the A tag.
1083  *
1084  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1085  *                     destination is specified.
1086  * @param node   [i]   The A tag node is specified.
1087  * @return The conversion result is returned.
1088  */
1089 static char *
1090 s_xhtml_1_0_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1091 {
1092   xhtml_t *xhtml = GET_XHTML(pdoc);
1093   Doc     *doc   = xhtml->doc;
1094
1095   W_L("</a>");
1096
1097   return xhtml->out;
1098 }
1099
1100
1101 /**
1102  * It is a handler who processes the BR tag.
1103  *
1104  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1105  *                     destination is specified.
1106  * @param node   [i]   The BR tag node is specified.
1107  * @return The conversion result is returned.
1108  */
1109 static char *
1110 s_xhtml_1_0_start_br_tag(void *pdoc, Node *node) 
1111 {
1112   xhtml_t *xhtml = GET_XHTML(pdoc);
1113   Doc     *doc   = xhtml->doc;
1114   Attr    *attr;
1115
1116   W_L("<br");
1117   /*--------------------------------------------------------------------------*/
1118   /* Get Attributes                                                           */
1119   /*--------------------------------------------------------------------------*/
1120   for (attr = qs_get_attr(doc,node);
1121        attr;
1122        attr = qs_get_next_attr(doc,attr)) {
1123     char *name  = qs_get_attr_name(doc,attr);
1124     char *value = qs_get_attr_value(doc,attr);
1125     if (STRCASEEQ('c','C',"clear",name)) {
1126       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1127         W_L(" clear=\"");
1128         W_V(value);
1129         W_L("\"");
1130       }
1131     }
1132   }
1133   W_L(" />");
1134
1135   return xhtml->out;
1136 }
1137
1138
1139 /**
1140  * It is a handler who processes the BR tag.
1141  *
1142  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1143  *                     destination is specified.
1144  * @param node   [i]   The BR tag node is specified.
1145  * @return The conversion result is returned.
1146  */
1147 static char *
1148 s_xhtml_1_0_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1149 {
1150   xhtml_t *xhtml = GET_XHTML(pdoc);
1151
1152   return xhtml->out;
1153 }
1154
1155
1156 /**
1157  * It is a handler who processes the TR tag.
1158  *
1159  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1160  *                     destination is specified.
1161  * @param node   [i]   The TR tag node is specified.
1162  * @return The conversion result is returned.
1163  */
1164 static char *
1165 s_xhtml_1_0_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1166 {
1167   xhtml_t *xhtml = GET_XHTML(pdoc);
1168   Doc     *doc   = xhtml->doc;
1169
1170   W_L("<br />");
1171
1172   return xhtml->out;
1173 }
1174
1175
1176 /**
1177  * It is a handler who processes the TR tag.
1178  *
1179  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1180  *                     destination is specified.
1181  * @param node   [i]   The TR tag node is specified.
1182  * @return The conversion result is returned.
1183  */
1184 static char *
1185 s_xhtml_1_0_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1186 {
1187   xhtml_t *xhtml = GET_XHTML(pdoc);
1188
1189   return xhtml->out;
1190 }
1191
1192
1193 /**
1194  * It is a handler who processes the FONT tag.
1195  *
1196  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1197  *                     destination is specified.
1198  * @param node   [i]   The FONT tag node is specified.
1199  * @return The conversion result is returned.
1200  */
1201 static char *
1202 s_xhtml_1_0_start_font_tag(void *pdoc, Node *node) 
1203 {
1204   xhtml_t *xhtml = GET_XHTML(pdoc);
1205   Doc     *doc   = xhtml->doc;
1206   Attr    *attr;
1207   char    *size = NULL;
1208   char    *color = NULL;
1209
1210   /*=========================================================================*/
1211   /* Get Attributes                                                          */
1212   /*=========================================================================*/
1213   for (attr = qs_get_attr(doc,node);
1214        attr;
1215        attr = qs_get_next_attr(doc,attr)) {
1216     char *name = qs_get_attr_name(doc,attr);
1217     char *value = qs_get_attr_value(doc,attr);
1218     if (STRCASEEQ('c','C',"color",name) && value && *value) {
1219       color = apr_pstrdup(doc->buf.pool, value);
1220     }
1221     else if (STRCASEEQ('s','S',"size",name) && value && *value) {
1222       size = apr_pstrdup(doc->buf.pool, value);
1223     }
1224   }
1225   if (color) {
1226     W_L("<font color=\"");
1227     W_V(color);
1228     W_L("\">");
1229     xhtml->font_color_flag++;
1230   }
1231   if (size) {
1232     xhtml->font_size_flag++;
1233     switch(*size) {
1234     case '1': W_L("<span style=\"font-size: xx-small\">"); break;
1235     case '2': W_L("<span style=\"font-size: x-small\">");  break;
1236     case '3': W_L("<span style=\"font-size: small\">");    break;
1237     case '4': W_L("<span style=\"font-size: medium\">");   break;
1238     case '5': W_L("<span style=\"font-size: large\">");    break;
1239     case '6': W_L("<span style=\"font-size: x-large\">");  break;
1240     case '7': W_L("<span style=\"font-size: xx-large\">"); break;
1241     case '-':
1242       if (*(size + 1) == '1') {
1243         W_L("<span style=\"font-size: small\">");
1244         break;
1245       }
1246       if (*(size + 1) == '2') {
1247         W_L("<span style=\"font-size: x-small\">");
1248         break;
1249       }
1250       if (*(size + 1) == '3') {
1251         W_L("<span style=\"font-size: xx-small\">");
1252         break;
1253       }
1254       xhtml->font_size_flag--;
1255       break;
1256
1257     case '+':
1258       if (*(size + 1) == '1') {
1259         W_L("<span style=\"font-size: large\">");
1260         break;
1261       }
1262       if (*(size + 1) == '2') {
1263         W_L("<span style=\"font-size: x-large\">");
1264         break;
1265       }
1266       if (*(size + 1) == '3') {
1267         W_L("<span style=\"font-size: xx-large\">");
1268         break;
1269       }
1270       xhtml->font_size_flag--;
1271       break;
1272
1273     default:
1274       WRN(doc->r, "invlalid font size. [%s] != (1|2|3|4|5|6|7|+1|+2|+3|-1|-2|-3)", size);
1275       xhtml->font_size_flag--;
1276     }
1277   }
1278   return xhtml->out;
1279 }
1280
1281
1282 /**
1283  * It is a handler who processes the FONT tag.
1284  *
1285  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1286  *                     destination is specified.
1287  * @param node   [i]   The FONT tag node is specified.
1288  * @return The conversion result is returned.
1289  */
1290 static char *
1291 s_xhtml_1_0_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1292 {
1293   xhtml_t *xhtml = GET_XHTML(pdoc);
1294   Doc     *doc   = xhtml->doc;
1295
1296   if (xhtml->font_size_flag) {
1297     W_L("</span>");
1298     xhtml->font_size_flag--;
1299   }
1300   if (xhtml->font_color_flag) {
1301     W_L("</font>");
1302     xhtml->font_color_flag--;
1303   }
1304   return xhtml->out;
1305 }
1306
1307
1308 /**
1309  * It is a handler who processes the FORM tag.
1310  *
1311  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1312  *                     destination is specified.
1313  * @param node   [i]   The FORM tag node is specified.
1314  * @return The conversion result is returned.
1315  */
1316 static char *
1317 s_xhtml_1_0_start_form_tag(void *pdoc, Node *node) 
1318 {
1319   xhtml_t     *xhtml = GET_XHTML(pdoc);
1320   Doc         *doc   = xhtml->doc;
1321   request_rec *r     = doc->r;
1322   Attr        *attr;
1323   char        *new_hidden_tag = NULL;
1324   char        *attr_action = NULL;
1325   char        *attr_method = NULL;
1326   char        *attr_name = NULL;
1327
1328   /*--------------------------------------------------------------------------*/
1329   /* Get Attributes                                                           */
1330   /*--------------------------------------------------------------------------*/
1331   for (attr = qs_get_attr(doc,node);
1332        attr;
1333        attr = qs_get_next_attr(doc,attr)) {
1334     char *name = qs_get_attr_name(doc,attr);
1335     char *value = qs_get_attr_value(doc,attr);
1336     if (STRCASEEQ('a','A',"action",name)) {
1337       attr_action = chxj_encoding_parameter(r, value);
1338       attr_action = chxj_add_cookie_parameter(r, attr_action, xhtml->cookie);
1339     }
1340     else if (STRCASEEQ('m','M',"method",name)) {
1341       attr_method = apr_pstrdup(doc->pool, value);
1342     }
1343     else if (STRCASEEQ('u','U',"utn",name)) {
1344       /* ignore */
1345     }
1346     else if (STRCASEEQ('n','N',"name",name)) {
1347       attr_name = apr_pstrdup(doc->pool, value);
1348     }
1349   }
1350
1351   int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1352
1353   W_L("<form");
1354   if (attr_action) {
1355     char *q;
1356     q = strchr(attr_action, '?');
1357     if (q) {
1358       new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag);
1359       if (new_hidden_tag) {
1360         *q = 0;
1361       }
1362     }
1363     W_L(" action=\"");
1364     W_V(attr_action);
1365     W_L("\"");
1366   }
1367   if (attr_method) {
1368     W_L(" method=\"");
1369     W_V(attr_method);
1370     W_L("\"");
1371   }
1372   if (attr_name) {
1373     W_L(" name=\"");
1374     W_V(attr_name);
1375     W_L("\"");
1376   }
1377   W_L(">");
1378   if (new_hidden_tag) {
1379     W_V(new_hidden_tag);
1380   }
1381   return xhtml->out;
1382 }
1383
1384
1385 /**
1386  * It is a handler who processes the FORM tag.
1387  *
1388  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1389  *                     destination is specified.
1390  * @param node   [i]   The FORM tag node is specified.
1391  * @return The conversion result is returned.
1392  */
1393 static char *
1394 s_xhtml_1_0_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1395 {
1396   xhtml_t *xhtml = GET_XHTML(pdoc);
1397   Doc     *doc   = xhtml->doc;
1398
1399   W_L("</form>");
1400
1401   return xhtml->out;
1402 }
1403
1404
1405 /**
1406  * It is a handler who processes the INPUT tag.
1407  *
1408  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1409  *                     destination is specified.
1410  * @param node   [i]   The INPUT tag node is specified.
1411  * @return The conversion result is returned.
1412  */
1413 static char *
1414 s_xhtml_1_0_start_input_tag(void *pdoc, Node *node) 
1415 {
1416   xhtml_t     *xhtml       = GET_XHTML(pdoc);
1417   Doc         *doc         = xhtml->doc;
1418   request_rec *r           = doc->r;
1419   char        *max_length  = NULL;
1420   char        *type        = NULL;
1421   char        *name        = NULL;
1422   char        *value       = NULL;
1423   char        *istyle      = NULL;
1424   char        *size        = NULL;
1425   char        *checked     = NULL;
1426   char        *accesskey   = NULL;
1427
1428   W_L("<input");
1429   /*--------------------------------------------------------------------------*/
1430   /* Get Attributes                                                           */
1431   /*--------------------------------------------------------------------------*/
1432   type       = qs_get_type_attr(doc, node, doc->buf.pool);
1433   name       = qs_get_name_attr(doc, node, doc->buf.pool);
1434   value      = qs_get_value_attr(doc,node, doc->buf.pool);
1435   istyle     = qs_get_istyle_attr(doc,node,doc->buf.pool);
1436   max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
1437   checked    = qs_get_checked_attr(doc,node, doc->buf.pool);
1438   accesskey  = qs_get_accesskey_attr(doc, node, doc->buf.pool);
1439   size       = qs_get_size_attr(doc, node, doc->buf.pool);
1440
1441   if (type) {
1442     type = qs_trim_string(doc->buf.pool, type);
1443     if (type && (STRCASEEQ('t','T',"text",    type) ||
1444                  STRCASEEQ('p','P',"password",type) ||
1445                  STRCASEEQ('c','C',"checkbox",type) ||
1446                  STRCASEEQ('r','R',"radio",   type) ||
1447                  STRCASEEQ('h','H',"hidden",  type) ||
1448                  STRCASEEQ('s','S',"submit",  type) ||
1449                  STRCASEEQ('r','R',"reset",   type))) {
1450       W_L(" type=\"");
1451       W_V(type);
1452       W_L("\"");
1453     }
1454   }
1455   if (size && *size) {
1456     W_L(" size=\"");
1457     W_V(size);
1458     W_L("\"");
1459   }
1460   if (name && *name) {
1461     W_L(" name=\"");
1462     W_V(name);
1463     W_L("\"");
1464   }
1465   if (value && *value) {
1466     W_L(" value=\"");
1467     W_V(chxj_add_slash_to_doublequote(doc->pool, value));
1468     W_L("\"");
1469   }
1470   if (accesskey && *accesskey) {
1471     W_L(" accesskey=\"");
1472     W_V(accesskey);
1473     W_L("\"");
1474   }
1475   if (istyle && *istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1476     char *fmt = qs_conv_istyle_to_format(r,istyle);
1477     if (max_length && *max_length) {
1478       int ii;
1479       for (ii=0; (unsigned int)ii<strlen(max_length); ii++) {
1480         if (max_length[ii] < '0' || max_length[ii] > '9') {
1481           max_length = apr_psprintf(r->pool, "0");
1482           break;
1483         }
1484       }
1485
1486       if (strcmp(max_length, "0")) {
1487         char *vv = apr_psprintf(r->pool, " FORMAT=\"%d%s\"", atoi(max_length), fmt);
1488         W_V(vv);
1489       }
1490     }
1491     else {
1492       W_L(" FORMAT=\"");
1493       W_L("*");
1494       W_V(fmt);
1495       W_L("\"");
1496     }
1497   }
1498   else {
1499     if (max_length && *max_length) {
1500       if (chxj_chk_numeric(max_length) != 0) {
1501         max_length = apr_psprintf(r->pool, "0");
1502       }
1503       if (strcmp(max_length, "0")) {
1504         char *vv = apr_psprintf(r->pool, " FORMAT=\"%dm\"", atoi(max_length));
1505         W_V(vv);
1506       }
1507     }
1508   }
1509   /*--------------------------------------------------------------------------*/
1510   /* The figure is default for the password.                                  */
1511   /*--------------------------------------------------------------------------*/
1512   if (type && (istyle == NULL || *istyle == 0) && STRCASEEQ('p','P',"password", type) && ! xhtml->entryp->pc_flag) {
1513     if (max_length) {
1514       W_L(" FORMAT=\"");
1515       W_V(max_length);
1516       W_L("N\"");
1517     }
1518     else {
1519       W_L(" FORMAT=\"*N\"");
1520     }
1521   }
1522   if (checked) {
1523     W_L(" checked=\"checked\"");
1524   }
1525   W_L(" />");
1526
1527   return xhtml->out;
1528 }
1529
1530
1531 /**
1532  * It is a handler who processes the INPUT tag.
1533  *
1534  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1535  *                     destination is specified.
1536  * @param node   [i]   The INPUT tag node is specified.
1537  * @return The conversion result is returned.
1538  */
1539 static char *
1540 s_xhtml_1_0_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1541 {
1542   xhtml_t *xhtml = GET_XHTML(pdoc);
1543
1544   return xhtml->out;
1545 }
1546
1547
1548 /**
1549  * It is a handler who processes the CENTER tag.
1550  *
1551  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1552  *                     destination is specified.
1553  * @param node   [i]   The CENTER tag node is specified.
1554  * @return The conversion result is returned.
1555  */
1556 static char *
1557 s_xhtml_1_0_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1558 {
1559   xhtml_t *xhtml = GET_XHTML(pdoc);
1560   Doc     *doc   = xhtml->doc;
1561
1562   W_L("<center>");
1563   return xhtml->out;
1564 }
1565
1566
1567 /**
1568  * It is a handler who processes the CENTER tag.
1569  *
1570  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1571  *                     destination is specified.
1572  * @param node   [i]   The CENTER tag node is specified.
1573  * @return The conversion result is returned.
1574  */
1575 static char *
1576 s_xhtml_1_0_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1577 {
1578   xhtml_t *xhtml = GET_XHTML(pdoc);
1579   Doc     *doc   = xhtml->doc;
1580
1581   W_L("</center>");
1582   return xhtml->out;
1583 }
1584
1585
1586 /**
1587  * It is a handler who processes the HR tag.
1588  *
1589  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1590  *                     destination is specified.
1591  * @param node   [i]   The HR tag node is specified.
1592  * @return The conversion result is returned.
1593  */
1594 static char *
1595 s_xhtml_1_0_start_hr_tag(void *pdoc, Node *node)
1596 {
1597   xhtml_t *xhtml = GET_XHTML(pdoc);
1598   Doc     *doc   = xhtml->doc;
1599   Attr    *attr;
1600
1601   W_L("<hr");
1602  
1603   for (attr = qs_get_attr(doc,node);
1604        attr; 
1605        attr = qs_get_next_attr(doc,attr)) {
1606     char *name = qs_get_attr_name(doc,attr);
1607     char *value = qs_get_attr_value(doc,attr);
1608     if (STRCASEEQ('a','A',"align", name)) {
1609       /*----------------------------------------------------------------------*/
1610       /* CHTML 1.0                                                            */
1611       /*----------------------------------------------------------------------*/
1612       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1613         W_L(" align=\"");
1614         W_V(value);
1615         W_L("\"");
1616       }
1617     }
1618     else if (STRCASEEQ('s','S',"size", name)) {
1619       /*----------------------------------------------------------------------*/
1620       /* CHTML 1.0                                                            */
1621       /*----------------------------------------------------------------------*/
1622       if (value && *value) {
1623         W_L(" size=\"");
1624         W_V(value);
1625         W_L("\"");
1626       }
1627     }
1628     else if (STRCASEEQ('w','W',"width", name)) {
1629       /*----------------------------------------------------------------------*/
1630       /* CHTML 1.0                                                            */
1631       /*----------------------------------------------------------------------*/
1632       if (value && *value) {
1633         W_L(" width=\"");
1634         W_V(value);
1635         W_L("\"");
1636       }
1637     }
1638     else if (STRCASEEQ('n','N',"noshade", name)) {
1639       /*----------------------------------------------------------------------*/
1640       /* CHTML 1.0                                                            */
1641       /*----------------------------------------------------------------------*/
1642       /* ignore */
1643     }
1644     else if (STRCASEEQ('c','C',"color", name) && value && *value) {
1645       /*----------------------------------------------------------------------*/
1646       /* CHTML 4.0                                                            */
1647       /*----------------------------------------------------------------------*/
1648       W_L(" color=\"");
1649       W_V(value);
1650       W_L("\"");
1651     }
1652   }
1653   W_L(" />");
1654   return xhtml->out;
1655 }
1656
1657
1658 /**
1659  * It is a handler who processes the HR tag.
1660  *
1661  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1662  *                     destination is specified.
1663  * @param node   [i]   The HR tag node is specified.
1664  * @return The conversion result is returned.
1665  */
1666 static char *
1667 s_xhtml_1_0_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1668 {
1669   xhtml_t *xhtml = GET_XHTML(pdoc);
1670
1671   return xhtml->out;
1672 }
1673
1674
1675 /**
1676  * It is a handler who processes the PRE tag.
1677  *
1678  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1679  *                     destination is specified.
1680  * @param node   [i]   The PRE tag node is specified.
1681  * @return The conversion result is returned.
1682  */
1683 static char *
1684 s_xhtml_1_0_start_pre_tag(void* pdoc, Node* UNUSED(node)) 
1685 {
1686   xhtml_t *xhtml = GET_XHTML(pdoc);
1687   Doc     *doc   = xhtml->doc;
1688
1689   xhtml->pre_flag++;
1690   W_L("<pre>");
1691   return xhtml->out;
1692 }
1693
1694
1695 /**
1696  * It is a handler who processes the PRE tag.
1697  *
1698  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1699  *                     destination is specified.
1700  * @param node   [i]   The PRE tag node is specified.
1701  * @return The conversion result is returned.
1702  */
1703 static char *
1704 s_xhtml_1_0_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
1705 {
1706   xhtml_t *xhtml = GET_XHTML(pdoc);
1707   Doc     *doc   = xhtml->doc;
1708
1709   W_L("</pre>");
1710   xhtml->pre_flag--;
1711
1712   return xhtml->out;
1713 }
1714
1715
1716 /**
1717  * It is a handler who processes the P tag.
1718  *
1719  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1720  *                     destination is specified.
1721  * @param node   [i]   The P tag node is specified.
1722  * @return The conversion result is returned.
1723  */
1724 static char *
1725 s_xhtml_1_0_start_p_tag(void *pdoc, Node *node) 
1726 {
1727   xhtml_t *xhtml = GET_XHTML(pdoc);
1728   Doc     *doc   = xhtml->doc;
1729   Attr    *attr;
1730   char    *align = NULL;
1731
1732   W_L("<p");
1733   for (attr = qs_get_attr(doc,node);
1734        attr;
1735        attr = qs_get_next_attr(doc,attr)) {
1736     char *nm  = qs_get_attr_name(doc,attr);
1737     char *val = qs_get_attr_value(doc,attr);
1738     if (STRCASEEQ('a','A',"align", nm)) {
1739       /*----------------------------------------------------------------------*/
1740       /* CHTML 1.0 (W3C version 3.2)                                          */
1741       /*----------------------------------------------------------------------*/
1742       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
1743         align = apr_pstrdup(doc->buf.pool, val);
1744         break;
1745       }
1746     }
1747   }
1748   if (align) {
1749     W_L(" align=\"");
1750     W_V(align);
1751     W_L("\"");
1752   }
1753   W_L(">");
1754   return xhtml->out;
1755 }
1756
1757
1758 /**
1759  * It is a handler who processes the P tag.
1760  *
1761  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1762  *                     destination is specified.
1763  * @param node   [i]   The P tag node is specified.
1764  * @return The conversion result is returned.
1765  */
1766 static char *
1767 s_xhtml_1_0_end_p_tag(void *pdoc, Node *UNUSED(child)) 
1768 {
1769   xhtml_t *xhtml = GET_XHTML(pdoc);
1770   Doc     *doc   = xhtml->doc;
1771
1772   W_L("</p>");
1773   return xhtml->out;
1774 }
1775
1776
1777 /**
1778  * It is a handler who processes the UL tag.
1779  *
1780  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1781  *                     destination is specified.
1782  * @param node   [i]   The UL tag node is specified.
1783  * @return The conversion result is returned.
1784  */
1785 static char *
1786 s_xhtml_1_0_start_ul_tag(void *pdoc, Node *node)
1787 {
1788   xhtml_t *xhtml = GET_XHTML(pdoc);
1789   Doc     *doc   = xhtml->doc;
1790   Attr    *attr;
1791   W_L("<ul");
1792   /*--------------------------------------------------------------------------*/
1793   /* Get Attributes                                                           */
1794   /*--------------------------------------------------------------------------*/
1795   for (attr = qs_get_attr(doc,node);
1796        attr;
1797        attr = qs_get_next_attr(doc,attr)) {
1798     char *name   = qs_get_attr_name(doc,attr);
1799     char *value  = qs_get_attr_value(doc,attr);
1800     if (STRCASEEQ('t','T',"type",name)) {
1801       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
1802         W_L(" type=\"");
1803         W_V(value);
1804         W_L("\"");
1805       }
1806     }
1807   }
1808   W_L(">");
1809   return xhtml->out;
1810 }
1811
1812
1813 /**
1814  * It is a handler who processes the UL tag.
1815  *
1816  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1817  *                     destination is specified.
1818  * @param node   [i]   The UL tag node is specified.
1819  * @return The conversion result is returned.
1820  */
1821 static char *
1822 s_xhtml_1_0_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1823 {
1824   xhtml_t *xhtml = GET_XHTML(pdoc);
1825   Doc     *doc   = xhtml->doc;
1826
1827   W_L("</ul>");
1828   return xhtml->out;
1829 }
1830
1831
1832 /**
1833  * It is a handler who processes the H1 tag.
1834  *
1835  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1836  *                     destination is specified.
1837  * @param node   [i]   The H1 tag node is specified.
1838  * @return The conversion result is returned.
1839  */
1840 static char *
1841 s_xhtml_1_0_start_h1_tag(void *pdoc, Node *node) 
1842 {
1843   xhtml_t *xhtml = GET_XHTML(pdoc);
1844   Doc     *doc   = xhtml->doc;
1845   Attr    *attr;
1846
1847   W_L("<h1");
1848   for (attr = qs_get_attr(doc,node);
1849        attr;
1850        attr = qs_get_next_attr(doc,attr)) {
1851     char* name;
1852     char* value;
1853     name  = qs_get_attr_name(doc,attr);
1854     value = qs_get_attr_value(doc,attr);
1855     if (STRCASEEQ('a','A',"align", name)) {
1856       if (value) {
1857         if (STRCASEEQ('l','L',"left",value)) {
1858           W_L(" style=\"");
1859           W_L("text-align:left");
1860           W_L("\"");
1861         }
1862         else if (STRCASEEQ('r','R',"right",value)) {
1863           W_L(" style=\"");
1864           W_L("text-align:right");
1865           W_L("\"");
1866         }
1867         else if (STRCASEEQ('c','C',"center",value)) {
1868           W_L(" style=\"");
1869           W_L("text-align:center");
1870           W_L("\"");
1871         }
1872         break;
1873       }
1874     }
1875   }
1876   W_L(">");
1877   return xhtml->out;
1878 }
1879
1880
1881 /**
1882  * It is a handler who processes the H1 tag.
1883  *
1884  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1885  *                     destination is specified.
1886  * @param node   [i]   The H1 tag node is specified.
1887  * @return The conversion result is returned.
1888  */
1889 static char *
1890 s_xhtml_1_0_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
1891 {
1892   xhtml_t *xhtml = GET_XHTML(pdoc);
1893   Doc     *doc   = xhtml->doc;
1894
1895   W_L("</h1>");
1896   return xhtml->out;
1897 }
1898
1899
1900 /**
1901  * It is a handler who processes the H2 tag.
1902  *
1903  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1904  *                     destination is specified.
1905  * @param node   [i]   The H2 tag node is specified.
1906  * @return The conversion result is returned.
1907  */
1908 static char *
1909 s_xhtml_1_0_start_h2_tag(void *pdoc, Node *node)
1910 {
1911   xhtml_t *xhtml = GET_XHTML(pdoc);
1912   Doc     *doc = xhtml->doc;
1913   Attr    *attr;
1914
1915   W_L("<h2");
1916   for (attr = qs_get_attr(doc,node);
1917        attr;
1918        attr = qs_get_next_attr(doc,attr)) {
1919     char* name;
1920     char* value;
1921     name  = qs_get_attr_name(doc,attr);
1922     value = qs_get_attr_value(doc,attr);
1923     if (STRCASEEQ('a','A',"align", name)) {
1924       if (value) {
1925         if (STRCASEEQ('l','L',"left",value)) {
1926           W_L(" style=\"");
1927           W_L("text-align:left");
1928           W_L("\"");
1929         }
1930         else if (STRCASEEQ('r','R',"right",value)) {
1931           W_L(" style=\"");
1932           W_L("text-align:right");
1933           W_L("\"");
1934         }
1935         else if (STRCASEEQ('c','C',"center",value)) {
1936           W_L(" style=\"");
1937           W_L("text-align:center");
1938           W_L("\"");
1939         }
1940         break;
1941       }
1942     }
1943   }
1944   W_L(">");
1945   return xhtml->out;
1946 }
1947
1948
1949 /**
1950  * It is a handler who processes the H2 tag.
1951  *
1952  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1953  *                     destination is specified.
1954  * @param node   [i]   The H2 tag node is specified.
1955  * @return The conversion result is returned.
1956  */
1957 static char *
1958 s_xhtml_1_0_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
1959 {
1960   xhtml_t *xhtml = GET_XHTML(pdoc);
1961   Doc     *doc   = xhtml->doc;
1962
1963   W_L("</h2>");
1964   return xhtml->out;
1965 }
1966
1967
1968 /**
1969  * It is a handler who processes the H3 tag.
1970  *
1971  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1972  *                     destination is specified.
1973  * @param node   [i]   The H3 tag node is specified.
1974  * @return The conversion result is returned.
1975  */
1976 static char *
1977 s_xhtml_1_0_start_h3_tag(void *pdoc, Node *node)
1978 {
1979   xhtml_t *xhtml = GET_XHTML(pdoc);
1980   Doc     *doc   = xhtml->doc;
1981   Attr    *attr;
1982
1983   W_L("<h3");
1984   for (attr = qs_get_attr(doc,node);
1985        attr;
1986        attr = qs_get_next_attr(doc,attr)) {
1987     char* name;
1988     char* value;
1989     name  = qs_get_attr_name(doc,attr);
1990     value = qs_get_attr_value(doc,attr);
1991     if (STRCASEEQ('a','A',"align", name)) {
1992       if (value) {
1993         if (STRCASEEQ('l','L',"left",value)) {
1994           W_L(" style=\"");
1995           W_L("text-align:left");
1996           W_L("\"");
1997         }
1998         else if (STRCASEEQ('r','R',"right",value)) {
1999           W_L(" style=\"");
2000           W_L("text-align:right");
2001           W_L("\"");
2002         }
2003         else if (STRCASEEQ('c','C',"center",value)) {
2004           W_L(" style=\"");
2005           W_L("text-align:center");
2006           W_L("\"");
2007         }
2008         break;
2009       }
2010     }
2011   }
2012   W_L(">");
2013   return xhtml->out;
2014 }
2015
2016
2017 /**
2018  * It is a handler who processes the H3 tag.
2019  *
2020  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2021  *                     destination is specified.
2022  * @param node   [i]   The H3 tag node is specified.
2023  * @return The conversion result is returned.
2024  */
2025 static char *
2026 s_xhtml_1_0_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2027 {
2028   xhtml_t *xhtml = GET_XHTML(pdoc);
2029   Doc     *doc   = xhtml->doc;
2030
2031   W_L("</h3>");
2032   return xhtml->out;
2033 }
2034
2035
2036 /**
2037  * It is a handler who processes the H4 tag.
2038  *
2039  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2040  *                     destination is specified.
2041  * @param node   [i]   The H4 tag node is specified.
2042  * @return The conversion result is returned.
2043  */
2044 static char *
2045 s_xhtml_1_0_start_h4_tag(void *pdoc, Node *node)
2046 {
2047   xhtml_t *xhtml = GET_XHTML(pdoc);
2048   Doc     *doc   = xhtml->doc;
2049   Attr    *attr;
2050
2051   W_L("<h4");
2052   for (attr = qs_get_attr(doc,node);
2053        attr;
2054        attr = qs_get_next_attr(doc,attr)) {
2055     char* name;
2056     char* value;
2057     name  = qs_get_attr_name(doc,attr);
2058     value = qs_get_attr_value(doc,attr);
2059     if (STRCASEEQ('a','A',"align", name)) {
2060       if (value) {
2061         if (STRCASEEQ('l','L',"left",value)) {
2062           W_L(" style=\"");
2063           W_L("text-align:left");
2064           W_L("\"");
2065         }
2066         else if (STRCASEEQ('r','R',"right",value)) {
2067           W_L(" style=\"");
2068           W_L("text-align:right");
2069           W_L("\"");
2070         }
2071         else if (STRCASEEQ('c','C',"center",value)) {
2072           W_L(" style=\"");
2073           W_L("text-align:center");
2074           W_L("\"");
2075         }
2076         break;
2077       }
2078     }
2079   }
2080   W_L(">");
2081   return xhtml->out;
2082 }
2083
2084
2085 /**
2086  * It is a handler who processes the H4 tag.
2087  *
2088  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2089  *                     destination is specified.
2090  * @param node   [i]   The H4 tag node is specified.
2091  * @return The conversion result is returned.
2092  */
2093 static char *
2094 s_xhtml_1_0_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2095 {
2096   xhtml_t *xhtml = GET_XHTML(pdoc);
2097   Doc     *doc   = xhtml->doc;
2098
2099   W_L("</h4>");
2100   return xhtml->out;
2101 }
2102
2103
2104 /**
2105  * It is a handler who processes the H5 tag.
2106  *
2107  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2108  *                     destination is specified.
2109  * @param node   [i]   The H5 tag node is specified.
2110  * @return The conversion result is returned.
2111  */
2112 static char *
2113 s_xhtml_1_0_start_h5_tag(void *pdoc, Node *node)
2114 {
2115   xhtml_t *xhtml = GET_XHTML(pdoc);
2116   Doc     *doc   = xhtml->doc;
2117   Attr    *attr;
2118
2119   W_L("<h5");
2120   for (attr = qs_get_attr(doc,node);
2121        attr;
2122        attr = qs_get_next_attr(doc,attr)) {
2123     char* name;
2124     char* value;
2125     name  = qs_get_attr_name(doc,attr);
2126     value = qs_get_attr_value(doc,attr);
2127     if (STRCASEEQ('a','A',"align", name)) {
2128       if (value) {
2129         if (STRCASEEQ('l','L',"left",value)) {
2130           W_L(" style=\"");
2131           W_L("text-align:left");
2132           W_L("\"");
2133         }
2134         else if (STRCASEEQ('r','R',"right",value)) {
2135           W_L(" style=\"");
2136           W_L("text-align:right");
2137           W_L("\"");
2138         }
2139         else if (STRCASEEQ('c','C',"center",value)) {
2140           W_L(" style=\"");
2141           W_L("text-align:center");
2142           W_L("\"");
2143         }
2144         break;
2145       }
2146     }
2147   }
2148   W_L(">");
2149   return xhtml->out;
2150 }
2151
2152
2153 /**
2154  * It is a handler who processes the H5 tag.
2155  *
2156  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2157  *                     destination is specified.
2158  * @param node   [i]   The H5 tag node is specified.
2159  * @return The conversion result is returned.
2160  */
2161 static char *
2162 s_xhtml_1_0_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
2163 {
2164   xhtml_t *xhtml = GET_XHTML(pdoc);
2165   Doc     *doc   = xhtml->doc;
2166
2167   W_L("</h5>");
2168   return xhtml->out;
2169 }
2170
2171
2172 /**
2173  * It is a handler who processes the H6 tag.
2174  *
2175  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2176  *                     destination is specified.
2177  * @param node   [i]   The H6 tag node is specified.
2178  * @return The conversion result is returned.
2179  */
2180 static char *
2181 s_xhtml_1_0_start_h6_tag(void *pdoc, Node *node)
2182 {
2183   xhtml_t *xhtml = GET_XHTML(pdoc);
2184   Doc     *doc   = xhtml->doc;
2185   Attr    *attr;
2186
2187   W_L("<h6");
2188   for (attr = qs_get_attr(doc,node);
2189        attr;
2190        attr = qs_get_next_attr(doc,attr)) {
2191     char* name;
2192     char* value;
2193     name  = qs_get_attr_name(doc,attr);
2194     value = qs_get_attr_value(doc,attr);
2195     if (STRCASEEQ('a','A',"align", name)) {
2196       if (value) {
2197         if (STRCASEEQ('l','L',"left",value)) {
2198           W_L(" style=\"");
2199           W_L("text-align:left");
2200           W_L("\"");
2201         }
2202         else if (STRCASEEQ('r','R',"right",value)) {
2203           W_L(" style=\"");
2204           W_L("text-align:right");
2205           W_L("\"");
2206         }
2207         else if (STRCASEEQ('c','C',"center",value)) {
2208           W_L(" style=\"");
2209           W_L("text-align:center");
2210           W_L("\"");
2211         }
2212         break;
2213       }
2214     }
2215   }
2216   W_L(">");
2217   return xhtml->out;
2218 }
2219
2220
2221 /**
2222  * It is a handler who processes the H6 tag.
2223  *
2224  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2225  *                     destination is specified.
2226  * @param node   [i]   The H6 tag node is specified.
2227  * @return The conversion result is returned.
2228  */
2229 static char *
2230 s_xhtml_1_0_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
2231 {
2232   xhtml_t *xhtml = GET_XHTML(pdoc);
2233   Doc     *doc   = xhtml->doc;
2234
2235   W_L("</h6>");
2236   return xhtml->out;
2237 }
2238
2239
2240 /**
2241  * It is a handler who processes the OL tag.
2242  *
2243  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2244  *                     destination is specified.
2245  * @param node   [i]   The OL tag node is specified.
2246  * @return The conversion result is returned.
2247  */
2248 static char *
2249 s_xhtml_1_0_start_ol_tag(void *pdoc, Node *node)
2250 {
2251   xhtml_t *xhtml = GET_XHTML(pdoc);
2252   Doc     *doc   = xhtml->doc;
2253   Attr    *attr;
2254
2255   W_L("<ol");
2256   /*--------------------------------------------------------------------------*/
2257   /* Get Attributes                                                           */
2258   /*--------------------------------------------------------------------------*/
2259   for (attr = qs_get_attr(doc,node);
2260        attr;
2261        attr = qs_get_next_attr(doc,attr)) {
2262     char *name = qs_get_attr_name(doc,attr);
2263     char *value = qs_get_attr_value(doc,attr);
2264     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2265       W_L(" type=\"");
2266       W_V(value);
2267       W_L("\"");
2268     }
2269     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
2270       W_L(" start=\"");
2271       W_V(value);
2272       W_L("\"");
2273     }
2274   }
2275   W_L(">");
2276   return xhtml->out;
2277 }
2278
2279
2280 /**
2281  * It is a handler who processes the OL tag.
2282  *
2283  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2284  *                     destination is specified.
2285  * @param node   [i]   The OL tag node is specified.
2286  * @return The conversion result is returned.
2287  */
2288 static char *
2289 s_xhtml_1_0_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
2290 {
2291   xhtml_t *xhtml = GET_XHTML(pdoc);
2292   Doc     *doc   = xhtml->doc;
2293
2294   W_L("</ol>");
2295   return xhtml->out;
2296 }
2297
2298
2299 /**
2300  * It is a handler who processes the LI tag.
2301  *
2302  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2303  *                     destination is specified.
2304  * @param node   [i]   The LI tag node is specified.
2305  * @return The conversion result is returned.
2306  */
2307 static char *
2308 s_xhtml_1_0_start_li_tag(void *pdoc, Node *node)
2309 {
2310   xhtml_t *xhtml = GET_XHTML(pdoc);
2311   Doc     *doc   = xhtml->doc;
2312   Attr    *attr;
2313
2314   W_L("<li");
2315   /*--------------------------------------------------------------------------*/
2316   /* Get Attributes                                                           */
2317   /*--------------------------------------------------------------------------*/
2318   for (attr = qs_get_attr(doc,node);
2319        attr;
2320        attr = qs_get_next_attr(doc,attr)) {
2321     char *name  = qs_get_attr_name(doc,attr);
2322     char *value = qs_get_attr_value(doc,attr);
2323     if (STRCASEEQ('t','T',"type",name)) {
2324       if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2325         W_L(" type=\"");
2326         W_V(value);
2327         W_L("\"");
2328       }
2329     }
2330     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2331       W_L(" value=\"");
2332       W_V(value);
2333       W_L("\"");
2334     }
2335   }
2336   W_L(">");
2337   return xhtml->out;
2338 }
2339
2340
2341 /**
2342  ** It is a handler who processes the LI 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 LI tag node is specified.
2347  * @return The conversion result is returned.
2348  */
2349 static char *
2350 s_xhtml_1_0_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2351 {
2352   xhtml_t *xhtml = GET_XHTML(pdoc);
2353   Doc     *doc   = xhtml->doc;
2354
2355   W_L("</li>");
2356   return xhtml->out;
2357 }
2358
2359 /**
2360  * It is a handler who processes the IMG tag.
2361  *
2362  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2363  *                     destination is specified.
2364  * @param node   [i]   The IMG tag node is specified.
2365  * @return The conversion result is returned.
2366  */
2367 static char *
2368 s_xhtml_1_0_start_img_tag(void *pdoc, Node *node) 
2369 {
2370   xhtml_t       *xhtml = GET_XHTML(pdoc);
2371   Doc           *doc   = xhtml->doc;
2372   request_rec   *r     = doc->r;
2373   Attr          *attr;
2374
2375 #ifndef IMG_NOT_CONVERT_FILENAME
2376   device_table  *spec = xhtml->spec;
2377 #endif
2378
2379   W_L("<img");
2380   /*--------------------------------------------------------------------------*/
2381   /* Get Attributes                                                           */
2382   /*--------------------------------------------------------------------------*/
2383   for (attr = qs_get_attr(doc,node);
2384        attr;
2385        attr = qs_get_next_attr(doc,attr)) {
2386     char *name  = qs_get_attr_name(doc,attr);
2387     char *value = qs_get_attr_value(doc,attr);
2388
2389     if (STRCASEEQ('s','S',"src",name)) {
2390       value = chxj_encoding_parameter(r, value);
2391       value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
2392       if (value) {
2393         value = apr_psprintf(r->pool,
2394                              "%s%c%s=true",
2395                              value,
2396                              (strchr(value, '?')) ? '&' : '?',
2397                              CHXJ_COOKIE_NOUPDATE_PARAM);
2398       }
2399 #ifdef IMG_NOT_CONVERT_FILENAME
2400
2401       W_L(" src=\"");
2402       W_V(value);
2403       W_L("\"");
2404
2405 #else
2406
2407       W_L(" src=\"");
2408       {
2409         char *vv = chxj_img_conv(r,spec,value);
2410         W_V(vv);
2411       }
2412       W_L("\"");
2413
2414 #endif
2415     }
2416     else 
2417     if (STRCASEEQ('a','A',"align",name)) {
2418       if (value) {
2419         if (STRCASEEQ('t','T',"top",   value) ||
2420             STRCASEEQ('m','M',"middle",value) ||
2421             STRCASEEQ('b','B',"bottom",value) ||
2422             STRCASEEQ('l','L',"left",  value) ||
2423             STRCASEEQ('r','R',"right", value)) {
2424           W_L(" align=\"");
2425           W_V(value);
2426           W_L("\"");
2427         }
2428         else if (STRCASEEQ('c','C',"center",  value)) {
2429           W_L(" align=\"");
2430           W_L("middle");
2431           W_L("\"");
2432         }
2433       }
2434     }
2435     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2436       W_L(" alt=\"");
2437       W_V(value);
2438       W_L("\"");
2439     }
2440     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
2441       W_L(" width=\"");
2442       W_V(value);
2443       W_L("\"");
2444     }
2445     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2446       W_L(" height=\"");
2447       W_V(value);
2448       W_L("\"");
2449     }
2450     else if (STRCASEEQ('h','H',"hspace",name) && value && *value) {
2451       W_L(" hspace=\"");
2452       W_V(value);
2453       W_L("\"");
2454     }
2455     else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2456       W_L(" vspace=\"");
2457       W_V(value);
2458       W_L("\"");
2459     }
2460   }
2461   W_L(" />");
2462   return xhtml->out;
2463 }
2464
2465
2466 /**
2467  * It is a handler who processes the IMG tag.
2468  *
2469  * @param xhtml  [i/o] The pointer to the XHTML structure at the output
2470  *                     destination is specified.
2471  * @param node   [i]   The IMG tag node is specified.
2472  * @return The conversion result is returned.
2473  */
2474 static char *
2475 s_xhtml_1_0_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2476 {
2477   xhtml_t *xhtml = GET_XHTML(pdoc);
2478
2479   return xhtml->out;
2480 }
2481
2482
2483 /**
2484  * It is a handler who processes the SELECT tag.
2485  *
2486  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2487  *                     destination is specified.
2488  * @param node   [i]   The SELECT tag node is specified.
2489  * @return The conversion result is returned.
2490  */
2491 static char *
2492 s_xhtml_1_0_start_select_tag(void *pdoc, Node *child)
2493 {
2494   xhtml_t *xhtml    = GET_XHTML(pdoc);
2495   Doc     *doc      = xhtml->doc;
2496   char    *size     = NULL;
2497   char    *name     = NULL;
2498   char    *multiple = NULL;
2499   Attr    *attr;
2500
2501
2502   W_L("<select");
2503   for (attr = qs_get_attr(doc,child);
2504        attr;
2505        attr = qs_get_next_attr(doc,attr)) {
2506     char *nm  = qs_get_attr_name(doc,attr);
2507     char *val = qs_get_attr_value(doc,attr);
2508     if (STRCASEEQ('s','S',"size",nm)) {
2509       /*----------------------------------------------------------------------*/
2510       /* CHTML 1.0 version 2.0                                                */
2511       /*----------------------------------------------------------------------*/
2512       size = apr_pstrdup(doc->buf.pool, val);
2513     }
2514     else if (STRCASEEQ('n','N',"name",nm)) {
2515       /*----------------------------------------------------------------------*/
2516       /* CHTML 1.0 version 2.0                                                */
2517       /*----------------------------------------------------------------------*/
2518       name = apr_pstrdup(doc->buf.pool, val);
2519     }
2520     else if (STRCASEEQ('m','M',"multiple",nm)) {
2521       /*----------------------------------------------------------------------*/
2522       /* CHTML 1.0 version 2.0                                                */
2523       /*----------------------------------------------------------------------*/
2524       multiple = apr_pstrdup(doc->buf.pool, val);
2525     }
2526   }
2527   if (size && *size) {
2528     W_L(" size=\"");
2529     W_V(size);
2530     W_L("\"");
2531   }
2532   if (name && *name) {
2533     W_L(" name=\"");
2534     W_V(name);
2535     W_L("\"");
2536   }
2537   if (multiple) {
2538     /* "true" is *NOT* W3C. it is specification of WAP2.0 for EZWEB */
2539     W_L(" multiple=\"true\"");
2540   }
2541   W_L(">");
2542   return xhtml->out;
2543 }
2544
2545
2546 /**
2547  * It is a handler who processes the SELECT tag.
2548  *
2549  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2550  *                     destination is specified.
2551  * @param node   [i]   The SELECT tag node is specified.
2552  * @return The conversion result is returned.
2553  */
2554 static char *
2555 s_xhtml_1_0_end_select_tag(void *pdoc, Node *UNUSED(child))
2556 {
2557   xhtml_t *xhtml = GET_XHTML(pdoc);
2558   Doc     *doc   = xhtml->doc;
2559
2560   W_L("</select>");
2561   return xhtml->out;
2562 }
2563
2564
2565 /**
2566  * It is a handler who processes the OPTION tag.
2567  *
2568  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2569  *                     destination is specified.
2570  * @param node   [i]   The OPTION tag node is specified.
2571  * @return The conversion result is returned.
2572  */
2573 static char *
2574 s_xhtml_1_0_start_option_tag(void *pdoc, Node *child)
2575 {
2576   xhtml_t *xhtml = GET_XHTML(pdoc);
2577   Doc     *doc   = xhtml->doc;
2578   Attr    *attr;
2579
2580   char *selected   = NULL;
2581   char *value      = NULL;
2582
2583   W_L("<option");
2584   for (attr = qs_get_attr(doc,child);
2585        attr;
2586        attr = qs_get_next_attr(doc,attr)) {
2587     char *nm  = qs_get_attr_name(doc,attr);
2588     char *val = qs_get_attr_value(doc,attr);
2589     if (STRCASEEQ('s','S',"selected",nm)) {
2590       /* CHTML version 2.0 */
2591       selected = apr_pstrdup(doc->buf.pool, val);
2592     }
2593     else if (STRCASEEQ('v','V',"value",nm)) {
2594       /* CHTML version 2.0 */
2595       value = apr_pstrdup(doc->buf.pool, val);
2596     }
2597   }
2598   if (value && *value) {
2599     W_L(" value=\"");
2600     W_V(value);
2601     W_L("\"");
2602   }
2603   if (selected) {
2604     W_L(" selected=\"selected\"");
2605   }
2606   W_L(">");
2607   return xhtml->out;
2608 }
2609
2610
2611 /**
2612  * It is a handler who processes the OPTION tag.
2613  *
2614  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2615  *                     destination is specified.
2616  * @param node   [i]   The OPTION tag node is specified.
2617  * @return The conversion result is returned.
2618  */
2619 static char *
2620 s_xhtml_1_0_end_option_tag(void *pdoc, Node *UNUSED(child))
2621 {
2622   xhtml_t *xhtml = GET_XHTML(pdoc);
2623   Doc     *doc   = xhtml->doc;
2624
2625   W_L("</option>");
2626   return xhtml->out;
2627 }
2628
2629
2630 /**
2631  * It is a handler who processes the DIV tag.
2632  *
2633  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2634  *                     destination is specified.
2635  * @param node   [i]   The DIV tag node is specified.
2636  * @return The conversion result is returned.
2637  */
2638 static char *
2639 s_xhtml_1_0_start_div_tag(void *pdoc, Node *child)
2640 {
2641   xhtml_t *xhtml = GET_XHTML(pdoc);
2642   Doc     *doc   = xhtml->doc;
2643   Attr    *attr;
2644   char    *align   = NULL;
2645
2646   W_L("<div");
2647   for (attr = qs_get_attr(doc,child);
2648        attr;
2649        attr = qs_get_next_attr(doc,attr)) {
2650     char *nm  = qs_get_attr_name(doc,attr);
2651     char *val = qs_get_attr_value(doc,attr);
2652     if (STRCASEEQ('a','A',"align",nm)) {
2653       /*=====================================================================*/
2654       /* CHTML version 3.2                                                   */
2655       /*=====================================================================*/
2656       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2657         align = apr_pstrdup(doc->buf.pool, val);
2658       }
2659     }
2660   }
2661   if (align) {
2662     W_L(" align=\"");
2663     W_V(align);
2664     W_L("\"");
2665   }
2666   W_L(">");
2667   return xhtml->out;
2668 }
2669
2670
2671 /**
2672  * It is a handler who processes the DIV 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 DIV tag node is specified.
2677  * @return The conversion result is returned.
2678  */
2679 static char *
2680 s_xhtml_1_0_end_div_tag(void *pdoc, Node *UNUSED(child))
2681 {
2682   xhtml_t *xhtml = GET_XHTML(pdoc);
2683   Doc     *doc   = xhtml->doc;
2684   W_L("</div>");
2685   return xhtml->out;
2686 }
2687
2688
2689 /**
2690  * It is a handler who processes the B tag.
2691  *
2692  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2693  *                     destination is specified.
2694  * @param node   [i]   The B tag node is specified.
2695  * @return The conversion result is returned.
2696  */
2697 static char *
2698 s_xhtml_1_0_start_b_tag(void *pdoc, Node *UNUSED(child))
2699 {
2700   xhtml_t *xhtml = GET_XHTML(pdoc);
2701   Doc     *doc   = xhtml->doc;
2702
2703   W_L("<div style=\"font-weight:bold\">");
2704   return xhtml->out;
2705 }
2706
2707
2708 /**
2709  * It is a handler who processes the B tag.
2710  *
2711  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2712  *                     destination is specified.
2713  * @param node   [i]   The B tag node is specified.
2714  * @return The conversion result is returned.
2715  */
2716 static char *
2717 s_xhtml_1_0_end_b_tag(void *pdoc, Node *UNUSED(child))
2718 {
2719   xhtml_t *xhtml = GET_XHTML(pdoc);
2720   Doc     *doc   = xhtml->doc;
2721
2722   W_L("</div>");
2723   return xhtml->out;
2724 }
2725
2726
2727 /**
2728  * It is a handler who processes the CHXJ:IF tag.
2729  *
2730  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2731  *                     destination is specified.
2732  * @param node   [i]   The CHXJ:IF tag node is specified.
2733  */
2734 static char *
2735 s_xhtml_1_0_chxjif_tag(void *pdoc, Node *node)
2736 {
2737   xhtml_t      *xhtml = GET_XHTML(pdoc);
2738   Doc          *doc   = xhtml->doc;
2739   Node         *child;
2740
2741   for (child = qs_get_child_node(doc, node);
2742        child;
2743        child = qs_get_next_node(doc, child)) {
2744     W_V(child->otext);
2745     s_xhtml_1_0_chxjif_tag(xhtml, child);
2746   }
2747
2748   return NULL;
2749 }
2750
2751
2752 /**
2753  * It is a handler who processes the TEXTARE tag.
2754  *
2755  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2756  *                     destination is specified.
2757  * @param node   [i]   The TEXTAREA tag node is specified.
2758  * @return The conversion result is returned.
2759  */
2760 static char *
2761 s_xhtml_1_0_start_textarea_tag(void *pdoc, Node *node) 
2762 {
2763   xhtml_t *xhtml = GET_XHTML(pdoc);
2764   Doc     *doc   = xhtml->doc;
2765   Attr    *attr;
2766
2767   xhtml->textarea_flag++;
2768   W_L("<textarea");
2769   for (attr = qs_get_attr(doc,node);
2770        attr;
2771        attr = qs_get_next_attr(doc,attr)) {
2772     char *name  = qs_get_attr_name(doc,attr);
2773     char *value = qs_get_attr_value(doc,attr);
2774     if (STRCASEEQ('n','N',"name",name) && value && *value) {
2775       W_L(" name=\"");
2776       W_V(value);
2777       W_L("\"");
2778     }
2779     else if (STRCASEEQ('r','R',"rows",name) && value && *value) {
2780       W_L(" rows=\"");
2781       W_V(value);
2782       W_L("\"");
2783     }
2784     else if (STRCASEEQ('c','C',"cols",name) && value && *value) {
2785       W_L(" cols=\"");
2786       W_V(value);
2787       W_L("\"");
2788     }
2789     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
2790       char *fmt = qs_conv_istyle_to_format(doc->r,value);
2791       W_L(" FORMAT=\"*");
2792       W_V(fmt);
2793       W_L("\"");
2794     }
2795     else if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
2796       W_L(" accesskey=\"");
2797       W_V(value);
2798       W_L("\"");
2799     }
2800   }
2801   W_L(">");
2802   return xhtml->out;
2803 }
2804
2805
2806 /**
2807  * It is a handler who processes the TEXTAREA tag.
2808  *
2809  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2810  *                     destination is specified.
2811  * @param node   [i]   The TEXTAREA tag node is specified.
2812  * @return The conversion result is returned.
2813  */
2814 static char *
2815 s_xhtml_1_0_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
2816 {
2817   xhtml_t *xhtml = GET_XHTML(pdoc);
2818   Doc     *doc   = xhtml->doc;
2819
2820   W_L("</textarea>");
2821   xhtml->textarea_flag--;
2822
2823   return xhtml->out;
2824 }
2825
2826 static char *
2827 s_xhtml_1_0_text_tag(void *pdoc, Node *child)
2828 {
2829   xhtml_t     *xhtml   = GET_XHTML(pdoc);
2830   Doc         *doc     = xhtml->doc;
2831   request_rec *r       = doc->r;
2832   char        *textval;
2833   char        *tmp;
2834   char        *tdst;
2835   char        one_byte[2];
2836   int         ii;
2837   int         tdst_len;
2838   
2839   textval = qs_get_node_value(doc,child);
2840   if (strlen(textval) == 0) {
2841     return xhtml->out;
2842   }
2843   
2844   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2845   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2846   
2847   tdst     = qs_alloc_zero_byte_string(doc->buf.pool);
2848   memset(one_byte, 0, sizeof(one_byte));
2849   tdst_len = 0;
2850   
2851   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2852     char *out;
2853     int rtn = s_xhtml_search_emoji(xhtml, &textval[ii], &out);
2854     if (rtn != 0) {
2855       DBG(r,"[%s][%d]", out, rtn);
2856       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2857       ii+=(rtn - 1);
2858       continue;
2859     }
2860     if (is_sjis_kanji(textval[ii])) {
2861       one_byte[0] = textval[ii+0];
2862       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2863       one_byte[0] = textval[ii+1];
2864       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2865       ii++;
2866     }
2867     else if (xhtml->pre_flag) {
2868       one_byte[0] = textval[ii+0];
2869       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2870     }
2871     else if (xhtml->textarea_flag) {
2872       one_byte[0] = textval[ii+0];
2873       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2874     }
2875     else if (textval[ii] != '\r' && textval[ii] != '\n') {
2876       one_byte[0] = textval[ii+0];
2877       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2878     }
2879   }
2880   W_V(tdst);
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_start_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 BLOCKQUOTE 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 BLOCKQUOTE tag node is specified.
2909  * @return The conversion result is returned.
2910  */
2911 static char *
2912 s_xhtml_1_0_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
2913 {
2914   xhtml_t *xhtml = GET_XHTML(pdoc);
2915   Doc     *doc   = xhtml->doc;
2916   W_L("</blockquote>");
2917   return xhtml->out;
2918 }
2919
2920
2921 /**
2922  * It is a handler who processes the DIR tag.
2923  *
2924  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2925  *                     destination is specified.
2926  * @param node   [i]   The DIR tag node is specified.
2927  * @return The conversion result is returned.
2928  */
2929 static char *
2930 s_xhtml_1_0_start_dir_tag(void *pdoc, Node *node)
2931 {
2932   xhtml_t *xhtml = GET_XHTML(pdoc);
2933   Doc     *doc = xhtml->doc;
2934   Attr      *attr;
2935   W_L("<dir");
2936   for (attr = qs_get_attr(doc,node);
2937        attr;
2938        attr = qs_get_next_attr(doc,attr)) {
2939     char *name   = qs_get_attr_name(doc,attr);
2940     char *value  = qs_get_attr_value(doc,attr);
2941     if (STRCASEEQ('t','T',"type",name)) {
2942       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2943         W_L(" type=\"");
2944         W_V(value);
2945         W_L("\"");
2946       }
2947     }
2948   }
2949   W_L(">");
2950   return xhtml->out;
2951 }
2952
2953
2954 /**
2955  * It is a handler who processes the DIR 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 DIR tag node is specified.
2960  * @return The conversion result is returned.
2961  */
2962 static char *
2963 s_xhtml_1_0_end_dir_tag(void *pdoc, Node *UNUSED(child))
2964 {
2965   xhtml_t *xhtml = GET_XHTML(pdoc);
2966   Doc     *doc = xhtml->doc;
2967   W_L("</dir>");
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_start_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 handler who processes the DL 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 DL tag node is specified.
2996  * @return The conversion result is returned.
2997  */
2998 static char *
2999 s_xhtml_1_0_end_dl_tag(void *pdoc, Node *UNUSED(child))
3000 {
3001   xhtml_t *xhtml = GET_XHTML(pdoc);
3002   Doc *doc = xhtml->doc;
3003   W_L("</dl>");
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_start_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 handter who processes the DT 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 DT tag node is specified.
3032  * @return The conversion result is returned.
3033  */
3034 static char *
3035 s_xhtml_1_0_end_dt_tag(void *pdoc, Node *UNUSED(child))
3036 {
3037   xhtml_t *xhtml = GET_XHTML(pdoc);
3038   Doc     *doc   = xhtml->doc;
3039   W_L("</dt>");
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_start_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 handder who processes the DD 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 DD tag node is specified.
3068  * @return The conversion result is returned.
3069  */
3070 static char *
3071 s_xhtml_1_0_end_dd_tag(void *pdoc, Node *UNUSED(child))
3072 {
3073   xhtml_t *xhtml = GET_XHTML(pdoc);
3074   Doc     *doc   = xhtml->doc;
3075   W_L("</dd>");
3076   return xhtml->out;
3077 }
3078
3079
3080 /**
3081  * It is a handler who processes the MENU tag.
3082  *
3083  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3084  *                     destination is specified.
3085  * @param node   [i]   The MENU tag node is specified.
3086  * @return The conversion result is returned.
3087  */
3088 static char *
3089 s_xhtml_1_0_start_menu_tag(void *pdoc, Node *node)
3090 {
3091   xhtml_t *xhtml = GET_XHTML(pdoc);
3092   Doc     *doc   = xhtml->doc;
3093   Attr    *attr;
3094   W_L("<menu");
3095   /*--------------------------------------------------------------------------*/
3096   /* Get Attributes                                                           */
3097   /*--------------------------------------------------------------------------*/
3098   for (attr = qs_get_attr(doc,node);
3099        attr;
3100        attr = qs_get_next_attr(doc,attr)) {
3101     char *name   = qs_get_attr_name(doc,attr);
3102     char *value  = qs_get_attr_value(doc,attr);
3103     if (STRCASEEQ('t','T',"type",name)) {
3104       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
3105         W_L(" type=\"");
3106         W_V(value);
3107         W_L("\"");
3108       }
3109     }
3110   }
3111   W_L(">");
3112   return xhtml->out;
3113 }
3114
3115
3116 /**
3117  * It is a hanmenuer who processes the MENU 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 MENU tag node is specified.
3122  * @return The conversion result is returned.
3123  */
3124 static char *
3125 s_xhtml_1_0_end_menu_tag(void *pdoc, Node *UNUSED(child))
3126 {
3127   xhtml_t *xhtml = GET_XHTML(pdoc);
3128   Doc *doc = xhtml->doc;
3129   W_L("</menu>");
3130   return xhtml->out;
3131 }
3132
3133
3134 /**
3135  * It is a handler who processes the PLAINTEXT tag.
3136  *
3137  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3138  *                     destination is specified.
3139  * @param node   [i]   The PLAINTEXT tag node is specified.
3140  * @return The conversion result is returned.
3141  */
3142 static char *
3143 s_xhtml_1_0_start_plaintext_tag(void *pdoc, Node *node)
3144 {
3145   xhtml_t *xhtml = GET_XHTML(pdoc);
3146   Doc     *doc     = xhtml->doc;
3147   W_L("<plaintext>");
3148   s_xhtml_1_0_start_plaintext_tag_inner(pdoc,node);
3149   return xhtml->out;
3150 }
3151
3152 static char *
3153 s_xhtml_1_0_start_plaintext_tag_inner(void *pdoc, Node *node)
3154 {
3155   xhtml_t *xhtml = GET_XHTML(pdoc);
3156   Doc     *doc     = xhtml->doc;
3157   Node    *child;
3158   for (child = qs_get_child_node(doc, node);
3159        child;
3160        child = qs_get_next_node(doc, child)) {
3161     W_V(child->otext);
3162     s_xhtml_1_0_start_plaintext_tag_inner(pdoc, child);
3163   }
3164   return xhtml->out;
3165 }
3166
3167
3168 /**
3169  * It is a handler who processes the PLAINTEXT 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 PLAINTEXT tag node is specified.
3174  * @return The conversion result is returned.
3175  */
3176 static char *
3177 s_xhtml_1_0_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3178 {
3179   xhtml_t *xhtml = GET_XHTML(pdoc);
3180   Doc     *doc     = xhtml->doc;
3181   W_L("</plaintext>");
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_start_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 hanblinker who processes the BLINK 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 BLINK tag node is specified.
3210  * @return The conversion result is returned.
3211  */
3212 static char *
3213 s_xhtml_1_0_end_blink_tag(void *pdoc, Node *UNUSED(child))
3214 {
3215   xhtml_t *xhtml = GET_XHTML(pdoc);
3216   Doc     *doc = xhtml->doc;
3217   W_L("</blink>");
3218   return xhtml->out;
3219 }
3220
3221
3222 /**
3223  * It is a handler who processes the MARQUEE tag.
3224  *
3225  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3226  *                     destination is specified.
3227  * @param node   [i]   The MARQUEE tag node is specified.
3228  * @return The conversion result is returned.
3229  */
3230 static char *
3231 s_xhtml_1_0_start_marquee_tag(void *pdoc, Node *node)
3232 {
3233   xhtml_t *xhtml = GET_XHTML(pdoc);
3234   Doc     *doc = xhtml->doc;
3235   Attr *attr;
3236   W_L("<marquee");
3237   /*--------------------------------------------------------------------------*/
3238   /* Get Attributes                                                           */
3239   /*--------------------------------------------------------------------------*/
3240   for (attr = qs_get_attr(doc,node);
3241        attr;
3242        attr = qs_get_next_attr(doc,attr)) {
3243     char *name   = qs_get_attr_name(doc,attr);
3244     char *value  = qs_get_attr_value(doc,attr);
3245     if (STRCASEEQ('d','D',"direction", name)) {
3246       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3247         W_L(" direction=\"");
3248         W_V(value);
3249         W_L("\"");
3250       }
3251     }
3252     else if (STRCASEEQ('b','B',"behavior",name)) {
3253       if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3254         W_L(" behavior=\""); 
3255         W_V(value);
3256         W_L("\"");
3257       }
3258     }
3259     else if (STRCASEEQ('l','L',"loop",name)) {
3260       if (value && *value) {
3261         W_L(" loop=\"");
3262         W_V(value);
3263         W_L("\"");
3264       }
3265     }
3266     else if (STRCASEEQ('b','B',"bgcolor",name)) {
3267       if (value && *value) {
3268         W_L(" bgcolor=\"");
3269         W_V(value);
3270         W_L("\"");
3271       }
3272     }
3273   }
3274   W_L(">");
3275   return xhtml->out;
3276 }
3277
3278
3279 /**
3280  * It is a handler who processes the MARQUEE tag.
3281  *
3282  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3283  *                     destination is specified.
3284  * @param node   [i]   The MARQUEE tag node is specified.
3285  * @return The conversion result is returned.
3286  */
3287 static char *
3288 s_xhtml_1_0_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3289 {
3290   xhtml_t *xhtml = GET_XHTML(pdoc);
3291   Doc     *doc = xhtml->doc;
3292   W_L("</marquee>");
3293   return xhtml->out;
3294 }
3295
3296
3297 /**
3298  * It is handler who processes the New Line Code.
3299  */
3300 static char *
3301 s_xhtml_1_0_newline_mark(void *pdoc, Node *UNUSED(node))
3302 {
3303   xhtml_t *xhtml = GET_XHTML(pdoc);
3304   Doc *doc = xhtml->doc;
3305   W_NLCODE();
3306   return xhtml->out;
3307 }
3308 /*
3309  * vim:ts=2 et
3310  */