OSDN Git Service

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