OSDN Git Service

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