OSDN Git Service

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