OSDN Git Service

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