OSDN Git Service

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