OSDN Git Service

* Added <h1 align> attribute 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* node) 
836 {
837   Doc*          doc;
838   request_rec*  r;
839   Attr*         attr;
840   chtml10_t*    chtml10;
841
842   chtml10 = GET_CHTML10(pdoc);
843   doc     = chtml10->doc;
844   r       = doc->r;
845
846   W10_L("<h1");
847   for (attr = qs_get_attr(doc,node);
848        attr;
849        attr = qs_get_next_attr(doc,attr)) {
850     char* name;
851     char* value;
852     name  = qs_get_attr_name(doc,attr);
853     value = qs_get_attr_value(doc,attr);
854     if (STRCASEEQ('a','A',"align", name)) {
855       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
856         W10_L(" align=\"");
857         W10_V(value);
858         W10_L("\"");
859         break;
860       }
861     }
862   }
863   W10_L(">");
864
865   return chtml10->out;
866 }
867
868
869 /**
870  * It is a handler who processes the H1 tag.
871  *
872  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
873  *                     destination is specified.
874  * @param node   [i]   The H1 tag node is specified.
875  * @return The conversion result is returned.
876  */
877 static char*
878 s_chtml10_end_h1_tag(void* pdoc, Node* UNUSED(child)) 
879 {
880   Doc*          doc;
881   request_rec*  r;
882   chtml10_t*    chtml10;
883
884   chtml10 = GET_CHTML10(pdoc);
885   doc     = chtml10->doc;
886   r       = doc->r;
887
888   W10_L("</h1>");
889
890   return chtml10->out;
891 }
892
893
894 /**
895  * It is a handler who processes the H2 tag.
896  *
897  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
898  *                     destination is specified.
899  * @param node   [i]   The H2 tag node is specified.
900  * @return The conversion result is returned.
901  */
902 static char*
903 s_chtml10_start_h2_tag(void* pdoc, Node* UNUSED(node)) 
904 {
905   Doc*          doc;
906   request_rec*  r;
907   chtml10_t*    chtml10;
908
909   chtml10 = GET_CHTML10(pdoc);
910   doc     = chtml10->doc;
911   r       = doc->r;
912
913   W10_L("<h2>");
914
915   return chtml10->out;
916 }
917
918
919 /**
920  * It is a handler who processes the H2 tag.
921  *
922  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
923  *                     destination is specified.
924  * @param node   [i]   The H2 tag node is specified.
925  * @return The conversion result is returned.
926  */
927 static char*
928 s_chtml10_end_h2_tag(void* pdoc, Node* UNUSED(child)) 
929 {
930   Doc*          doc;
931   request_rec*  r;
932   chtml10_t*    chtml10;
933
934   chtml10 = GET_CHTML10(pdoc);
935   doc     = chtml10->doc;
936   r       = doc->r;
937
938   W10_L("</h2>");
939
940   return chtml10->out;
941 }
942
943
944 /**
945  * It is a handler who processes the H3 tag.
946  *
947  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
948  *                     destination is specified.
949  * @param node   [i]   The H3 tag node is specified.
950  * @return The conversion result is returned.
951  */
952 static char*
953 s_chtml10_start_h3_tag(void* pdoc, Node* UNUSED(node)) 
954 {
955   Doc*          doc;
956   request_rec*  r;
957   chtml10_t*    chtml10;
958
959   chtml10 = GET_CHTML10(pdoc);
960   doc     = chtml10->doc;
961   r       = doc->r;
962
963   W10_L("<h3>");
964
965   return chtml10->out;
966 }
967
968
969 /**
970  * It is a handler who processes the H3 tag.
971  *
972  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
973  *                     destination is specified.
974  * @param node   [i]   The H3 tag node is specified.
975  * @return The conversion result is returned.
976  */
977 static char*
978 s_chtml10_end_h3_tag(void* pdoc, Node* UNUSED(child)) 
979 {
980   chtml10_t*    chtml10;
981   Doc*          doc;
982   request_rec*  r;
983
984   chtml10 = GET_CHTML10(pdoc);
985   doc     = chtml10->doc;
986   r       = doc->r;
987
988   W10_L("</h3>");
989
990   return chtml10->out;
991 }
992
993
994 /**
995  * It is a handler who processes the H4 tag.
996  *
997  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
998  *                     destination is specified.
999  * @param node   [i]   The H4 tag node is specified.
1000  * @return The conversion result is returned.
1001  */
1002 static char*
1003 s_chtml10_start_h4_tag(void* pdoc, Node* UNUSED(node)) 
1004 {
1005   chtml10_t*    chtml10;
1006   Doc*          doc;
1007   request_rec*  r;
1008
1009   chtml10 = GET_CHTML10(pdoc);
1010   doc     = chtml10->doc;
1011   r       = doc->r;
1012
1013   W10_L("<h4>\r\n");
1014
1015   return chtml10->out;
1016 }
1017
1018
1019 /**
1020  * It is a handler who processes the H4 tag.
1021  *
1022  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1023  *                     destination is specified.
1024  * @param node   [i]   The H4 tag node is specified.
1025  * @return The conversion result is returned.
1026  */
1027 static char*
1028 s_chtml10_end_h4_tag(void* pdoc, Node* UNUSED(child)) 
1029 {
1030   Doc*          doc;
1031   request_rec*  r;
1032   chtml10_t*    chtml10;
1033
1034   chtml10  = GET_CHTML10(pdoc);
1035   doc      = chtml10->doc;
1036   r        = doc->r;
1037
1038   W10_L("</h4>\r\n");
1039
1040   return chtml10->out;
1041 }
1042
1043
1044 /**
1045  * It is a handler who processes the H5 tag.
1046  *
1047  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1048  *                     destination is specified.
1049  * @param node   [i]   The H5 tag node is specified.
1050  * @return The conversion result is returned.
1051  */
1052 static char*
1053 s_chtml10_start_h5_tag(void* pdoc, Node* UNUSED(node)) 
1054 {
1055   Doc*          doc;
1056   request_rec*  r;
1057   chtml10_t*    chtml10;
1058
1059   chtml10 = GET_CHTML10(pdoc);
1060   doc     = chtml10->doc;
1061   r       = doc->r;
1062
1063   W10_L("<h5>\r\n");
1064
1065   return chtml10->out;
1066 }
1067
1068
1069 /**
1070  * It is a handler who processes the H5 tag.
1071  *
1072  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1073  *                     destination is specified.
1074  * @param node   [i]   The H5 tag node is specified.
1075  * @return The conversion result is returned.
1076  */
1077 static char*
1078 s_chtml10_end_h5_tag(void* pdoc, Node* UNUSED(child)) 
1079 {
1080   Doc*          doc;
1081   request_rec*  r;
1082   chtml10_t*    chtml10;
1083
1084   chtml10 = GET_CHTML10(pdoc);
1085   doc     = chtml10->doc;
1086   r       = doc->r;
1087
1088   W10_L("</h5>\r\n");
1089
1090   return chtml10->out;
1091 }
1092
1093
1094 /**
1095  * It is a handler who processes the H6 tag.
1096  *
1097  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1098  *                     destination is specified.
1099  * @param node   [i]   The H6 tag node is specified.
1100  * @return The conversion result is returned.
1101  */
1102 static char*
1103 s_chtml10_start_h6_tag(void* pdoc, Node* UNUSED(node)) 
1104 {
1105   Doc*          doc;
1106   request_rec*  r;
1107   chtml10_t*    chtml10;
1108
1109   chtml10 = GET_CHTML10(pdoc);
1110   doc     = chtml10->doc;
1111   r       = doc->r;
1112
1113   W10_L("<h6>\r\n");
1114
1115   return chtml10->out;
1116 }
1117
1118
1119 /**
1120  * It is a handler who processes the H6 tag.
1121  *
1122  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1123  *                     destination is specified.
1124  * @param node   [i]   The H6 tag node is specified.
1125  * @return The conversion result is returned.
1126  */
1127 static char*
1128 s_chtml10_end_h6_tag(void* pdoc, Node* UNUSED(child)) 
1129 {
1130   Doc*          doc;
1131   request_rec*  r;
1132   chtml10_t*    chtml10;
1133
1134   chtml10 = GET_CHTML10(pdoc);
1135   doc     = chtml10->doc;
1136   r       = doc->r;
1137
1138   W10_L("</h6>\r\n");
1139
1140   return chtml10->out;
1141 }
1142
1143
1144 /**
1145  * It is a handler who processes the TITLE tag.
1146  *
1147  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1148  *                     destination is specified.
1149  * @param node   [i]   The TITLE tag node is specified.
1150  * @return The conversion result is returned.
1151  */
1152 static char*
1153 s_chtml10_start_title_tag(void* pdoc, Node* UNUSED(node)) 
1154 {
1155   Doc*         doc;
1156   request_rec* r;
1157   chtml10_t*   chtml10;
1158
1159   chtml10 = GET_CHTML10(pdoc);
1160   doc     = chtml10->doc;
1161   r       = doc->r;
1162
1163   W10_L("<title>");
1164
1165   return chtml10->out;
1166 }
1167
1168
1169 /**
1170  * It is a handler who processes the TITLE tag.
1171  *
1172  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1173  *                     destination is specified.
1174  * @param node   [i]   The TITLE tag node is specified.
1175  * @return The conversion result is returned.
1176  */
1177 static char*
1178 s_chtml10_end_title_tag(void* pdoc, Node* UNUSED(child)) 
1179 {
1180   Doc*          doc;
1181   request_rec*  r;
1182   chtml10_t*    chtml10;
1183
1184   chtml10 = GET_CHTML10(pdoc);
1185   doc     = chtml10->doc;
1186   r       = doc->r;
1187
1188   W10_L("</title>");
1189
1190   return chtml10->out;
1191 }
1192
1193
1194 /**
1195  * It is a handler who processes the BASE tag.
1196  *
1197  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1198  *                     destination is specified.
1199  * @param node   [i]   The BASE tag node is specified.
1200  * @return The conversion result is returned.
1201  */
1202 static char*
1203 s_chtml10_start_base_tag(void* pdoc, Node* node) 
1204 {
1205   Attr*         attr;
1206   chtml10_t*    chtml10;
1207   Doc*          doc;
1208   request_rec*  r;
1209
1210   chtml10 = GET_CHTML10(pdoc);
1211   doc     = chtml10->doc;
1212   r       = doc->r;
1213   
1214   W10_L("<base");
1215
1216   /*--------------------------------------------------------------------------*/
1217   /* Get Attributes                                                           */
1218   /*--------------------------------------------------------------------------*/
1219   for (attr = qs_get_attr(doc,node);
1220        attr;
1221        attr = qs_get_next_attr(doc,attr)) {
1222     char* name;
1223     char* value;
1224
1225     name  = qs_get_attr_name(doc,attr);
1226     value = qs_get_attr_value(doc,attr);
1227
1228     if (STRCASEEQ('h','H',"href", name)) {
1229       W10_L(" href=\"");
1230       W10_V(value);
1231       W10_L("\"");
1232     }
1233   }
1234
1235   W10_L(">");
1236
1237   return chtml10->out;
1238 }
1239
1240
1241 /**
1242  * It is a handler who processes the BASE tag.
1243  *
1244  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1245  *                     destination is specified.
1246  * @param node   [i]   The BASE tag node is specified.
1247  * @return The conversion result is returned.
1248  */
1249 static char*
1250 s_chtml10_end_base_tag(void* pdoc, Node* UNUSED(child)) 
1251 {
1252   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1253
1254   return chtml10->out;
1255 }
1256
1257
1258 /**
1259  * It is a handler who processes the BODY tag.
1260  *
1261  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1262  *                     destination is specified.
1263  * @param node   [i]   The BODY tag node is specified.
1264  * @return The conversion result is returned.
1265  */
1266 static char*
1267 s_chtml10_start_body_tag(void* pdoc, Node* node) 
1268 {
1269   chtml10_t*   chtml10;
1270   Doc*         doc;
1271   request_rec* r;
1272   Attr*        attr;
1273
1274   chtml10 = GET_CHTML10(pdoc);
1275   doc     = chtml10->doc;
1276   r       = doc->r;
1277
1278
1279   W10_L("<body");
1280
1281   /*--------------------------------------------------------------------------*/
1282   /* Get Attributes                                                           */
1283   /*--------------------------------------------------------------------------*/
1284   for (attr = qs_get_attr(doc,node);
1285        attr;
1286        attr = qs_get_next_attr(doc,attr)) {
1287
1288     char* name;
1289
1290     name  = qs_get_attr_name(doc,attr);
1291
1292     switch(*name) {
1293     case 'a':
1294     case 'A':
1295       if (strcasecmp(name, "alink") == 0) {
1296         /*----------------------------------------------------------------------*/
1297         /* CHTML 4.0                                                            */
1298         /*----------------------------------------------------------------------*/
1299         /* ignore */
1300       }
1301       break;
1302
1303     case 'b':
1304     case 'B':
1305       if (strcasecmp(name, "bgcolor") == 0) {
1306         /*----------------------------------------------------------------------*/
1307         /* CHTML 2.0                                                            */
1308         /*----------------------------------------------------------------------*/
1309         /* ignore */
1310       }
1311       break;
1312
1313     case 't':
1314     case 'T':
1315       if (strcasecmp(name, "text") == 0) {
1316         /*----------------------------------------------------------------------*/
1317         /* CHTML 2.0                                                            */
1318         /*----------------------------------------------------------------------*/
1319         /* ignore */
1320       }
1321       break;
1322
1323     case 'l':
1324     case 'L':
1325       if (strcasecmp(name, "link") == 0) {
1326         /*----------------------------------------------------------------------*/
1327         /* CHTML 2.0                                                            */
1328         /*----------------------------------------------------------------------*/
1329         /* ignore */
1330       }
1331       break;
1332
1333     case 'v':
1334     case 'V':
1335       if (strcasecmp(name, "vlink") == 0) {
1336         /*----------------------------------------------------------------------*/
1337         /* CHTML 4.0                                                            */
1338         /*----------------------------------------------------------------------*/
1339         /* ignore */
1340       }
1341       break;
1342
1343     default:
1344       break;
1345     }
1346   }
1347
1348   W10_L(">");
1349
1350   return chtml10->out;
1351 }
1352
1353
1354 /**
1355  * It is a handler who processes the BODY tag.
1356  *
1357  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1358  *                     destination is specified.
1359  * @param node   [i]   The BODY tag node is specified.
1360  * @return The conversion result is returned.
1361  */
1362 static char*
1363 s_chtml10_end_body_tag(void* pdoc, Node* UNUSED(child)) 
1364 {
1365   Doc*          doc;
1366   request_rec*  r;
1367   chtml10_t*    chtml10;
1368
1369   chtml10 = GET_CHTML10(pdoc);
1370   doc     = chtml10->doc;
1371   r       = doc->r;
1372
1373   W10_L("</body>");
1374
1375   return chtml10->out;
1376 }
1377
1378
1379 /**
1380  * It is a handler who processes the A tag.
1381  *
1382  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1383  *                     destination is specified.
1384  * @param node   [i]   The A tag node is specified.
1385  * @return The conversion result is returned.
1386  */
1387 static char *
1388 s_chtml10_start_a_tag(void *pdoc, Node *node) 
1389 {
1390   chtml10_t     *chtml10;
1391   Doc           *doc;
1392   request_rec   *r;
1393   Attr          *attr;
1394
1395   chtml10 = GET_CHTML10(pdoc);
1396   doc     = chtml10->doc;
1397   r       = doc->r;
1398
1399   W10_L("<a");
1400
1401   /*--------------------------------------------------------------------------*/
1402   /* Get Attributes                                                           */
1403   /*--------------------------------------------------------------------------*/
1404   for (attr = qs_get_attr(doc,node);
1405        attr; 
1406        attr = qs_get_next_attr(doc,attr)) {
1407
1408     char *name;
1409     char *value;
1410
1411     name  = qs_get_attr_name(doc,attr);
1412     value = qs_get_attr_value(doc,attr);
1413
1414     switch(*name) {
1415     case 'n':
1416     case 'N':
1417       if (strcasecmp(name, "name") == 0) {
1418         /*--------------------------------------------------------------------*/
1419         /* CHTML1.0                                                           */
1420         /*--------------------------------------------------------------------*/
1421         W10_L(" name=\"");
1422         W10_V(value);
1423         W10_L("\"");
1424       }
1425       break;
1426
1427     case 'h':
1428     case 'H':
1429       if (strcasecmp(name, "href") == 0) {
1430         /*--------------------------------------------------------------------*/
1431         /* CHTML1.0                                                           */
1432         /*--------------------------------------------------------------------*/
1433         value = chxj_encoding_parameter(r, value);
1434         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
1435         W10_L(" href=\"");
1436         W10_V(value);
1437         W10_L("\"");
1438       }
1439       break;
1440
1441     case 'a':
1442     case 'A':
1443       if (strcasecmp(name, "accesskey") == 0) {
1444         /*--------------------------------------------------------------------*/
1445         /* CHTML1.0                                                           */
1446         /*--------------------------------------------------------------------*/
1447         W10_L(" accesskey=\"");
1448         W10_V(value);
1449         W10_L("\"");
1450       }
1451       break;
1452
1453     case 'c':
1454     case 'C':
1455       if (strcasecmp(name, "cti") == 0) {
1456         /*--------------------------------------------------------------------*/
1457         /* CHTML 2.0                                                          */
1458         /*--------------------------------------------------------------------*/
1459         /* ignore */
1460       }
1461       break;
1462
1463     case 'u':
1464     case 'U':
1465       if (strcasecmp(name, "utn") == 0) {
1466         /*--------------------------------------------------------------------*/
1467         /* CHTML 3.0                                                          */
1468         /*--------------------------------------------------------------------*/
1469         /* ignore */
1470       }
1471       break;
1472
1473     case 't':
1474     case 'T':
1475       if (strcasecmp(name, "telbook") == 0) {
1476         /*--------------------------------------------------------------------*/
1477         /* CHTML 3.0                                                          */
1478         /*--------------------------------------------------------------------*/
1479         /* ignore */
1480       }
1481       break;
1482
1483     case 'k':
1484     case 'K':
1485       if (strcasecmp(name, "kana") == 0) {
1486         /*--------------------------------------------------------------------*/
1487         /* CHTML 3.0                                                          */
1488         /*--------------------------------------------------------------------*/
1489         /* ignore */
1490       }
1491       break;
1492
1493     case 'e':
1494     case 'E':
1495       if (strcasecmp(name, "email") == 0) {
1496         /*--------------------------------------------------------------------*/
1497         /* CHTML 3.0                                                          */
1498         /*--------------------------------------------------------------------*/
1499         /* ignore */
1500       }
1501       break;
1502
1503     case 'i':
1504     case 'I':
1505       if (strcasecmp(name, "ista") == 0) {
1506         /*--------------------------------------------------------------------*/
1507         /* CHTML 4.0                                                          */
1508         /*--------------------------------------------------------------------*/
1509         /* ignore */
1510       }
1511       else
1512       if (strcasecmp(name, "ilet") == 0) {
1513         /*--------------------------------------------------------------------*/
1514         /* CHTML 5.0                                                          */
1515         /*--------------------------------------------------------------------*/
1516         /* ignore */
1517       }
1518       else
1519       if (strcasecmp(name, "iswf") == 0) {
1520         /*--------------------------------------------------------------------*/
1521         /* CHTML 5.0                                                          */
1522         /*--------------------------------------------------------------------*/
1523         /* ignore */
1524       }
1525       else
1526       if (strcasecmp(name, "irst") == 0) {
1527         /*--------------------------------------------------------------------*/
1528         /* CHTML 5.0                                                          */
1529         /*--------------------------------------------------------------------*/
1530         /* ignore */
1531       }
1532       else
1533       if (strcasecmp(name, "ijam") == 0) {
1534         /*--------------------------------------------------------------------*/
1535         /* CHTML 3.0                                                          */
1536         /*--------------------------------------------------------------------*/
1537         /* ignore */
1538       }
1539       break;
1540
1541     default:
1542       break;
1543     }
1544   }
1545
1546   W10_L(">");
1547   return chtml10->out;
1548 }
1549
1550
1551 /**
1552  * It is a handler who processes the A tag.
1553  *
1554  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1555  *                     destination is specified.
1556  * @param node   [i]   The A tag node is specified.
1557  * @return The conversion result is returned.
1558  */
1559 static char *
1560 s_chtml10_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1561 {
1562   chtml10_t    *chtml10;
1563   Doc          *doc;
1564   request_rec  *r;
1565
1566   chtml10 = GET_CHTML10(pdoc);
1567   doc     = chtml10->doc;
1568   r       = doc->r;
1569
1570   W10_L("</a>");
1571   return chtml10->out;
1572 }
1573
1574
1575 /**
1576  * It is a handler who processes the BR tag.
1577  *
1578  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1579  *                     destination is specified.
1580  * @param node   [i]   The BR tag node is specified.
1581  * @return The conversion result is returned.
1582  */
1583 static char *
1584 s_chtml10_start_br_tag(void *pdoc, Node *node) 
1585 {
1586   chtml10_t    *chtml10;
1587   Doc          *doc;
1588   request_rec  *r;
1589   Attr         *attr = NULL;
1590
1591   chtml10 = GET_CHTML10(pdoc);
1592   doc     = chtml10->doc;
1593   r       = doc->r;
1594
1595   W10_L("<br");
1596
1597   /*--------------------------------------------------------------------------*/
1598   /* Get Attributes                                                           */
1599   /*--------------------------------------------------------------------------*/
1600   for (attr = qs_get_attr(doc,node);
1601        attr;
1602        attr = qs_get_next_attr(doc,attr)) {
1603     char *name;
1604     char *value;
1605
1606     name  = qs_get_attr_name(doc,attr);
1607     value = qs_get_attr_value(doc,attr);
1608
1609     if (STRCASEEQ('c','C',"clear",name)) {
1610       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1611         W10_L(" clear=\"");
1612         W10_V(value);
1613         W10_L("\"");
1614       }
1615     }
1616   }
1617   W10_L(">");
1618   return chtml10->out;
1619 }
1620
1621
1622 /**
1623  * It is a handler who processes the BR tag.
1624  *
1625  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1626  *                     destination is specified.
1627  * @param node   [i]   The BR tag node is specified.
1628  * @return The conversion result is returned.
1629  */
1630 static char *
1631 s_chtml10_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1632 {
1633   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1634
1635   return chtml10->out;
1636 }
1637
1638
1639 /**
1640  * It is a handler who processes the TR tag.
1641  *
1642  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1643  *                     destination is specified.
1644  * @param node   [i]   The TR tag node is specified.
1645  * @return The conversion result is returned.
1646  */
1647 static char *
1648 s_chtml10_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1649 {
1650   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1651
1652   return chtml10->out;
1653 }
1654
1655
1656 /**
1657  * It is a handler who processes the TR tag.
1658  *
1659  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1660  *                     destination is specified.
1661  * @param node   [i]   The TR tag node is specified.
1662  * @return The conversion result is returned.
1663  */
1664 static char *
1665 s_chtml10_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1666 {
1667   chtml10_t    *chtml10;
1668   Doc          *doc;
1669   request_rec  *r;
1670
1671   chtml10 = GET_CHTML10(pdoc);
1672   doc     = chtml10->doc;
1673   r       = doc->r;
1674
1675   W10_L("<br>\r\n");
1676
1677   return chtml10->out;
1678 }
1679
1680
1681 /**
1682  * It is a handler who processes the FONT tag.
1683  *
1684  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1685  *                     destination is specified.
1686  * @param node   [i]   The FONT tag node is specified.
1687  * @return The conversion result is returned.
1688  */
1689 static char *
1690 s_chtml10_start_font_tag(void *pdoc, Node *UNUSED(node)) 
1691 {
1692   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1693
1694   /* Ignore */
1695
1696   return chtml10->out;
1697 }
1698
1699
1700 /**
1701  * It is a handler who processes the FONT tag.
1702  *
1703  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1704  *                     destination is specified.
1705  * @param node   [i]   The FONT tag node is specified.
1706  * @return The conversion result is returned.
1707  */
1708 static char *
1709 s_chtml10_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1710 {
1711   chtml10_t *chtml10 = GET_CHTML10(pdoc);
1712
1713   /* ignore */
1714
1715   return chtml10->out;
1716 }
1717
1718
1719 /**
1720  * It is a handler who processes the FORM tag.
1721  *
1722  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1723  *                     destination is specified.
1724  * @param node   [i]   The FORM tag node is specified.
1725  * @return The conversion result is returned.
1726  */
1727 static char *
1728 s_chtml10_start_form_tag(void *pdoc, Node *node) 
1729 {
1730   chtml10_t    *chtml10;
1731   Doc          *doc;
1732   request_rec  *r;
1733   Attr         *attr;
1734
1735   chtml10 = GET_CHTML10(pdoc);
1736   doc     = chtml10->doc;
1737   r       = doc->r;
1738
1739   W10_L("<form");
1740
1741   /*--------------------------------------------------------------------------*/
1742   /* Get Attributes                                                           */
1743   /*--------------------------------------------------------------------------*/
1744   for (attr = qs_get_attr(doc,node);
1745        attr;
1746        attr = qs_get_next_attr(doc,attr)) {
1747     char *name;
1748     char *value;
1749
1750     name  = qs_get_attr_name(doc,attr);
1751     value = qs_get_attr_value(doc,attr);
1752
1753     switch(*name) {
1754     case 'a':
1755     case 'A':
1756       if (strcasecmp(name, "action") == 0) {
1757         /*--------------------------------------------------------------------*/
1758         /* CHTML 1.0                                                          */
1759         /*--------------------------------------------------------------------*/
1760         value = chxj_encoding_parameter(r, value);
1761         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
1762   
1763         W10_L(" action=\"");
1764         W10_V(value);
1765         W10_L("\"");
1766       }
1767       break;
1768
1769     case 'm':
1770     case 'M':
1771       if (strcasecmp(name, "method") == 0) {
1772         /*--------------------------------------------------------------------*/
1773         /* CHTML 1.0                                                          */
1774         /*--------------------------------------------------------------------*/
1775         W10_L(" method=\"");
1776         W10_V(value);
1777         W10_L("\"");
1778       }
1779       break;
1780
1781     case 'u':
1782     case 'U':
1783       if (strcasecmp(name, "utn") == 0) {
1784         /*--------------------------------------------------------------------*/
1785         /* CHTML 3.0                                                          */
1786         /*--------------------------------------------------------------------*/
1787         /* ignore */
1788       }
1789       break;
1790
1791     default:
1792       break;
1793     }
1794   }
1795
1796   W10_L(">");
1797
1798   return chtml10->out;
1799 }
1800
1801
1802 /**
1803  * It is a handler who processes the FORM tag.
1804  *
1805  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1806  *                     destination is specified.
1807  * @param node   [i]   The FORM tag node is specified.
1808  * @return The conversion result is returned.
1809  */
1810 static char*
1811 s_chtml10_end_form_tag(void* pdoc, Node* UNUSED(child)) 
1812 {
1813   chtml10_t*   chtml10;
1814   Doc*         doc;
1815   request_rec* r;
1816
1817   chtml10 = GET_CHTML10(pdoc);
1818   doc     = chtml10->doc;
1819   r       = doc->r;
1820
1821   W10_L("</form>");
1822
1823   return chtml10->out;
1824 }
1825
1826
1827 /**
1828  * It is a handler who processes the INPUT tag.
1829  *
1830  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1831  *                     destination is specified.
1832  * @param node   [i]   The INPUT tag node is specified.
1833  * @return The conversion result is returned.
1834  */
1835 static char*
1836 s_chtml10_start_input_tag(void* pdoc, Node* node) 
1837 {
1838   chtml10_t*    chtml10;
1839   Doc*          doc;
1840   request_rec*  r;
1841   char*         max_length;
1842   char*         type;
1843   char*         name;
1844   char*         value;
1845   char*         istyle;
1846   char*         size;
1847   char*         checked;
1848   char*         accesskey;
1849
1850   chtml10     = GET_CHTML10(pdoc);
1851   doc         = chtml10->doc;
1852   r           = doc->r;
1853
1854   max_length  = NULL;
1855   type        = NULL;
1856   name        = NULL;
1857   value       = NULL;
1858   istyle      = NULL;
1859   size        = NULL;
1860   checked     = NULL;
1861   accesskey   = NULL;
1862
1863   W10_L("<input");
1864
1865   /*--------------------------------------------------------------------------*/
1866   /* Get Attributes                                                           */
1867   /*--------------------------------------------------------------------------*/
1868
1869   type       = qs_get_type_attr(doc, node, r);
1870   name       = qs_get_name_attr(doc, node, r);
1871   value      = qs_get_value_attr(doc,node,r);
1872   istyle     = qs_get_istyle_attr(doc,node,r);
1873   max_length = qs_get_maxlength_attr(doc,node,r);
1874   checked    = qs_get_checked_attr(doc,node,r);
1875   accesskey  = qs_get_accesskey_attr(doc, node, r);
1876   size       = qs_get_size_attr(doc, node, r);
1877
1878   if (type) {
1879     W10_L(" type=\"");
1880     W10_V(type);
1881     W10_L("\"");
1882   }
1883
1884   if (size) {
1885     W10_L(" size=\"");
1886     W10_V(size);
1887     W10_L("\"");
1888   }
1889
1890   if (name) {
1891     W10_L(" name=\"");
1892     W10_V(name);
1893     W10_L("\"");
1894   }
1895
1896   if (value) {
1897     W10_L(" value=\"");
1898     W10_V(value);
1899     W10_L("\" ");
1900   }
1901
1902   if (accesskey) {
1903     W10_L(" accesskey=\"");
1904     W10_V(accesskey);
1905     W10_L("\" ");
1906   }
1907
1908   if (istyle) {
1909     /*------------------------------------------------------------------------*/
1910     /* CHTML 2.0                                                              */
1911     /*------------------------------------------------------------------------*/
1912     /* ignore */
1913   }
1914   /*--------------------------------------------------------------------------*/
1915   /* The figure is default for the password.                                  */
1916   /*--------------------------------------------------------------------------*/
1917   if (max_length) {
1918     W10_L(" maxlength=\"");
1919     W10_V(max_length);
1920     W10_L("\"");
1921   }
1922
1923   if (checked) {
1924     W10_L(" checked ");
1925   }
1926
1927   W10_L(" >");
1928   return chtml10->out;
1929 }
1930
1931
1932 /**
1933  * It is a handler who processes the INPUT tag.
1934  *
1935  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1936  *                     destination is specified.
1937  * @param node   [i]   The INPUT tag node is specified.
1938  * @return The conversion result is returned.
1939  */
1940 static char*
1941 s_chtml10_end_input_tag(void* pdoc, Node* UNUSED(child)) 
1942 {
1943   chtml10_t* chtml10 = GET_CHTML10(pdoc);
1944
1945   return chtml10->out;
1946 }
1947
1948
1949 /**
1950  * It is a handler who processes the CENTER tag.
1951  *
1952  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1953  *                     destination is specified.
1954  * @param node   [i]   The CENTER tag node is specified.
1955  * @return The conversion result is returned.
1956  */
1957 static char*
1958 s_chtml10_start_center_tag(void* pdoc, Node* UNUSED(node)) 
1959 {
1960   chtml10_t*   chtml10;
1961   Doc*         doc;
1962   request_rec* r;
1963
1964   chtml10 = GET_CHTML10(pdoc);
1965   doc     = chtml10->doc;
1966   r       = doc->r;
1967
1968   W10_L("<center>");
1969
1970   return chtml10->out;
1971 }
1972
1973
1974 /**
1975  * It is a handler who processes the CENTER tag.
1976  *
1977  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1978  *                     destination is specified.
1979  * @param node   [i]   The CENTER tag node is specified.
1980  * @return The conversion result is returned.
1981  */
1982 static char*
1983 s_chtml10_end_center_tag(void* pdoc, Node* UNUSED(child)) 
1984 {
1985   chtml10_t*    chtml10;
1986   Doc*          doc;
1987   request_rec*  r;
1988
1989   chtml10 = GET_CHTML10(pdoc);
1990   doc     = chtml10->doc;
1991   r       = doc->r;
1992
1993   W10_L("</center>");
1994
1995   return chtml10->out;
1996 }
1997
1998
1999 /**
2000  * It is a handler who processes the HR tag.
2001  *
2002  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2003  *                     destination is specified.
2004  * @param node   [i]   The HR tag node is specified.
2005  * @return The conversion result is returned.
2006  */
2007 static char*
2008 s_chtml10_start_hr_tag(void* pdoc, Node* node) 
2009 {
2010   chtml10_t*   chtml10;
2011   Doc*         doc;
2012   request_rec* r;
2013   Attr*        attr;
2014
2015   chtml10 = GET_CHTML10(pdoc);
2016   doc     = chtml10->doc;
2017   r       = doc->r;
2018
2019   W10_L("<hr ");
2020  
2021   for (attr = qs_get_attr(doc,node);
2022        attr; 
2023        attr = qs_get_next_attr(doc,attr)) {
2024
2025     char* name;
2026     char* value;
2027
2028     name  = qs_get_attr_name (doc,attr);
2029     value = qs_get_attr_value(doc,attr);
2030
2031     switch(*name) {
2032     case 'a':
2033     case 'A':
2034       if (strcasecmp(name, "align") == 0) {
2035         /*--------------------------------------------------------------------*/
2036         /* CHTML 1.0                                                          */
2037         /*--------------------------------------------------------------------*/
2038         W10_L(" align=\"");
2039         W10_V(value);
2040         W10_L("\" ");
2041       }
2042       break;
2043
2044     case 's':
2045     case 'S':
2046       if (strcasecmp(name, "size") == 0) {
2047         /*--------------------------------------------------------------------*/
2048         /* CHTML 1.0                                                          */
2049         /*--------------------------------------------------------------------*/
2050         W10_L(" size=\"");
2051         W10_V(value);
2052         W10_L("\" ");
2053       }
2054       break;
2055
2056     case 'w':
2057     case 'W':
2058       if (strcasecmp(name, "width") == 0) {
2059         /*--------------------------------------------------------------------*/
2060         /* CHTML 1.0                                                          */
2061         /*--------------------------------------------------------------------*/
2062         W10_L(" width=\"");
2063         W10_V(value);
2064         W10_L("\" ");
2065       }
2066       break;
2067
2068     case 'n':
2069     case 'N':
2070       if (strcasecmp(name, "noshade") == 0) {
2071         /*--------------------------------------------------------------------*/
2072         /* CHTML 1.0                                                          */
2073         /*--------------------------------------------------------------------*/
2074         W10_L(" noshade ");
2075       }
2076       break;
2077
2078     case 'c':
2079     case 'C':
2080       if (strcasecmp(name, "color") == 0) {
2081         /*--------------------------------------------------------------------*/
2082         /* CHTML 4.0                                                          */
2083         /*--------------------------------------------------------------------*/
2084         /* ignore */
2085       }
2086       break;
2087
2088     default:
2089       break;
2090     }
2091   }
2092
2093
2094   W10_L(" >");
2095   return chtml10->out;
2096 }
2097
2098
2099 /**
2100  * It is a handler who processes the HR tag.
2101  *
2102  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2103  *                     destination is specified.
2104  * @param node   [i]   The HR tag node is specified.
2105  * @return The conversion result is returned.
2106  */
2107 static char*
2108 s_chtml10_end_hr_tag(void* pdoc, Node* UNUSED(child)) 
2109 {
2110   chtml10_t* chtml10;
2111
2112   chtml10 = GET_CHTML10(pdoc);
2113
2114   return chtml10->out;
2115 }
2116
2117
2118 /**
2119  * It is a handler who processes the IMG tag.
2120  *
2121  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2122  *                     destination is specified.
2123  * @param node   [i]   The IMG tag node is specified.
2124  * @return The conversion result is returned.
2125  */
2126 static char*
2127 s_chtml10_start_img_tag(void* pdoc, Node* node) 
2128 {
2129   chtml10_t*   chtml10;
2130   Doc*         doc;
2131   request_rec* r;
2132   Attr*        attr;
2133 #ifndef IMG_NOT_CONVERT_FILENAME
2134   device_table *spec;
2135 #endif
2136
2137   chtml10 = GET_CHTML10(pdoc);
2138 #ifndef IMG_NOT_CONVERT_FILENAME
2139   spec    = chtml10->spec;
2140 #endif
2141   doc     = chtml10->doc;
2142   r       = doc->r;
2143
2144   W10_L("<img");
2145   /*--------------------------------------------------------------------------*/
2146   /* Get Attributes                                                           */
2147   /*--------------------------------------------------------------------------*/
2148   for (attr = qs_get_attr(doc,node);
2149        attr;
2150        attr = qs_get_next_attr(doc,attr)) {
2151
2152     char* name;
2153     char* value;
2154
2155     name  = qs_get_attr_name (doc,attr);
2156     value = qs_get_attr_value(doc,attr);
2157
2158     switch(*name) {
2159     case 's':
2160     case 'S':
2161       if (strcasecmp(name, "src") == 0) {
2162         /*--------------------------------------------------------------------*/
2163         /* CHTML 1.0                                                          */
2164         /*--------------------------------------------------------------------*/
2165 #ifdef IMG_NOT_CONVERT_FILENAME
2166         value = chxj_encoding_parameter(r, value);
2167         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
2168         if (value) {
2169           value = apr_psprintf(r->pool, 
2170                                "%s%c%s=true", 
2171                                value, 
2172                                (strchr(value, '?')) ? '&' : '?',
2173                                CHXJ_COOKIE_NOUPDATE_PARAM);
2174         }
2175         W10_L(" src=\"");
2176         W10_V(value);
2177         W10_L("\"");
2178 #else
2179         value = chxj_img_conv(r, spec, value);
2180         value = chxj_encoding_parameter(r, value);
2181         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
2182         if (value) {
2183           value = apr_psprintf(r->pool,
2184                                "%s%c%s=true",
2185                                value,
2186                                (strchr(value, '?')) ? '&' : '?',
2187                                CHXJ_COOKIE_NOUPDATE_PARAM);
2188         }
2189         W10_L(" src=\"");
2190         W10_V(value);
2191         W10_L("\"");
2192 #endif
2193       }
2194       break;
2195
2196     case 'a':
2197     case 'A':
2198       if (strcasecmp(name, "align" ) == 0) {
2199         /*--------------------------------------------------------------------*/
2200         /* CHTML 1.0                                                          */
2201         /*--------------------------------------------------------------------*/
2202         /*--------------------------------------------------------------------*/
2203         /* CHTML 4.0                                                          */
2204         /*--------------------------------------------------------------------*/
2205         W10_L(" align=\"");
2206         W10_V(value);
2207         W10_L("\"");
2208       }
2209       else
2210       if (strcasecmp(name, "alt"   ) == 0) {
2211         /*--------------------------------------------------------------------*/
2212         /* CHTML 1.0                                                          */
2213         /*--------------------------------------------------------------------*/
2214         W10_L(" alt=\"");
2215         W10_V(value);
2216         W10_L("\"");
2217       }
2218       break;
2219
2220     case 'w':
2221     case 'W':
2222       if (strcasecmp(name, "width" ) == 0) {
2223         /*--------------------------------------------------------------------*/
2224         /* CHTML 1.0                                                          */
2225         /*--------------------------------------------------------------------*/
2226         W10_L(" width=\"");
2227         W10_V(value);
2228         W10_L("\"");
2229       }
2230       break;
2231
2232     case 'h':
2233     case 'H':
2234       if (strcasecmp(name, "height") == 0) {
2235         /*--------------------------------------------------------------------*/
2236         /* CHTML 1.0                                                          */
2237         /*--------------------------------------------------------------------*/
2238         W10_L(" height=\"");
2239         W10_V(value);
2240         W10_L("\"");
2241       }
2242       else
2243       if (strcasecmp(name, "hspace") == 0) {
2244         /*--------------------------------------------------------------------*/
2245         /* CHTML 1.0                                                          */
2246         /*--------------------------------------------------------------------*/
2247         W10_L(" hspace=\"");
2248         W10_V(value);
2249         W10_L("\"");
2250       }
2251       break;
2252
2253     case 'v':
2254     case 'V':
2255       if (strcasecmp(name, "vspace") == 0) {
2256         /*--------------------------------------------------------------------*/
2257         /* CHTML 1.0                                                          */
2258         /*--------------------------------------------------------------------*/
2259         W10_L(" vspace=\"");
2260         W10_V(value);
2261         W10_L("\"");
2262       }
2263       break;
2264
2265     default:
2266       break;
2267     }
2268   }
2269
2270   W10_L(">");
2271   return chtml10->out;
2272 }
2273
2274
2275 /**
2276  * It is a handler who processes the IMG tag.
2277  *
2278  * @param chtml10  [i/o] The pointer to the CHTML structure at the output
2279  *                     destination is specified.
2280  * @param node   [i]   The IMG tag node is specified.
2281  * @return The conversion result is returned.
2282  */
2283 static char *
2284 s_chtml10_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2285 {
2286   chtml10_t *chtml10;
2287
2288   chtml10 = GET_CHTML10(pdoc);
2289
2290   return chtml10->out;
2291 }
2292
2293
2294 /**
2295  * It is a handler who processes the SELECT tag.
2296  *
2297  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2298  *                     destination is specified.
2299  * @param node   [i]   The SELECT tag node is specified.
2300  * @return The conversion result is returned.
2301  */
2302 static char *
2303 s_chtml10_start_select_tag(void *pdoc, Node *child)
2304 {
2305   chtml10_t    *chtml10;
2306   Doc          *doc;
2307   request_rec  *r;
2308   Attr         *attr;
2309
2310   char         *size;
2311   char         *name;
2312
2313   chtml10 = GET_CHTML10(pdoc);
2314   doc     = chtml10->doc;
2315   r       = doc->r;
2316
2317   size    = NULL;
2318   name    = NULL;
2319
2320   W10_L("<select");
2321   for (attr = qs_get_attr(doc,child);
2322        attr;
2323        attr = qs_get_next_attr(doc,attr)) {
2324     char *nm;
2325     char *val;
2326
2327     nm  = qs_get_attr_name (doc,attr);
2328     val = qs_get_attr_value(doc,attr);
2329
2330     switch(*nm) {
2331     case 's':
2332     case 'S':
2333       if (strcasecmp(nm, "size") == 0) {
2334         /*--------------------------------------------------------------------*/
2335         /* CHTML 1.0 version 2.0                                              */
2336         /*--------------------------------------------------------------------*/
2337         size = apr_pstrdup(doc->buf.pool, val);
2338       }
2339       break;
2340
2341     case 'n':
2342     case 'N':
2343       if (strcasecmp(nm, "name") == 0) {
2344         /*--------------------------------------------------------------------*/
2345         /* CHTML 1.0 version 2.0                                              */
2346         /*--------------------------------------------------------------------*/
2347         name = apr_pstrdup(doc->buf.pool, val);
2348       }
2349       break;
2350
2351     case 'm':
2352     case 'M':
2353       if (strcasecmp(nm, "multiple") == 0) {
2354         /*--------------------------------------------------------------------*/
2355         /* CHTML 1.0 version 2.0                                              */
2356         /*--------------------------------------------------------------------*/
2357         /* Ignore */
2358       }
2359       break;
2360
2361     default:
2362       break;
2363     }
2364   }
2365
2366   if (size) {
2367     W10_L(" size=\"");
2368     W10_V(size);
2369     W10_L("\"");
2370   }
2371
2372   if (name) {
2373     W10_L(" name=\"");
2374     W10_V(name);
2375     W10_L("\"");
2376   }
2377
2378   W10_L(">\r\n");
2379   return chtml10->out;
2380 }
2381
2382
2383 /**
2384  * It is a handler who processes the SELECT tag.
2385  *
2386  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2387  *                     destination is specified.
2388  * @param node   [i]   The SELECT tag node is specified.
2389  * @return The conversion result is returned.
2390  */
2391 static char *
2392 s_chtml10_end_select_tag(void *pdoc, Node *UNUSED(child))
2393 {
2394   chtml10_t *chtml10;
2395   Doc *doc;
2396   request_rec *r;
2397
2398   chtml10 = GET_CHTML10(pdoc);
2399   doc     = chtml10->doc;
2400   r       = doc->r;
2401
2402   W10_L("</select>\r\n");
2403   return chtml10->out;
2404 }
2405
2406
2407 /**
2408  * It is a handler who processes the OPTION tag.
2409  *
2410  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2411  *                     destination is specified.
2412  * @param node   [i]   The OPTION tag node is specified.
2413  * @return The conversion result is returned.
2414  */
2415 static char *
2416 s_chtml10_start_option_tag(void *pdoc, Node *child)
2417 {
2418   chtml10_t *chtml10;
2419   Doc *doc;
2420   request_rec *r;
2421   Attr *attr;
2422
2423   char *selected;
2424   char *value;
2425
2426   chtml10   = GET_CHTML10(pdoc);
2427   doc       = chtml10->doc;
2428   r         = doc->r;
2429
2430   selected  = NULL;
2431   value     = NULL;
2432
2433   W10_L("<option");
2434
2435   for (attr = qs_get_attr(doc,child);
2436        attr;
2437        attr = qs_get_next_attr(doc,attr)) {
2438     char *nm;
2439     char *val;
2440
2441     nm  = qs_get_attr_name (doc,attr);
2442     val = qs_get_attr_value(doc,attr);
2443
2444     switch(*nm) {
2445     case 's':
2446     case 'S':
2447       if (strcasecmp(nm, "selected") == 0) {
2448         /*--------------------------------------------------------------------*/
2449         /* CHTML 1.0 version 2.0                                              */
2450         /*--------------------------------------------------------------------*/
2451         selected = apr_pstrdup(doc->buf.pool, val);
2452       }
2453       break;
2454
2455     case 'v':
2456     case 'V':
2457       if (strcasecmp(nm, "value") == 0) {
2458         /*--------------------------------------------------------------------*/
2459         /* CHTML 1.0 version 2.0                                              */
2460         /*--------------------------------------------------------------------*/
2461         value = apr_pstrdup(doc->buf.pool, val);
2462       }
2463       break;
2464
2465     default:
2466       break;
2467     }
2468   }
2469
2470   if (value) {
2471     W10_L(" value=\"");
2472     W10_V(value);
2473     W10_L("\"");
2474   }
2475   else {
2476     W10_L(" value=\"\"");
2477   }
2478
2479   if (selected) {
2480     W10_L(" selected ");
2481   }
2482
2483   W10_L(">");
2484   return chtml10->out;
2485 }
2486
2487
2488 /**
2489  * It is a handler who processes the OPTION tag.
2490  *
2491  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2492  *                     destination is specified.
2493  * @param node   [i]   The OPTION tag node is specified.
2494  * @return The conversion result is returned.
2495  */
2496 static char *
2497 s_chtml10_end_option_tag(void *pdoc, Node *UNUSED(child))
2498 {
2499   chtml10_t *chtml10;
2500  
2501   chtml10 = GET_CHTML10(pdoc);
2502
2503   /* Don't close */
2504
2505   return chtml10->out;
2506 }
2507
2508
2509 /**
2510  * It is a handler who processes the DIV tag.
2511  *
2512  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2513  *                     destination is specified.
2514  * @param node   [i]   The DIV tag node is specified.
2515  * @return The conversion result is returned.
2516  */
2517 static char *
2518 s_chtml10_start_div_tag(void *pdoc, Node *child)
2519 {
2520   chtml10_t *chtml10;
2521   Doc *doc;
2522   request_rec *r;
2523   Attr *attr;
2524
2525   char *align;
2526
2527   chtml10 = GET_CHTML10(pdoc);
2528   doc     = chtml10->doc;
2529   r       = doc->r;
2530
2531   align   = NULL;
2532
2533   W10_L("<div");
2534
2535   for (attr = qs_get_attr(doc,child);
2536        attr;
2537        attr = qs_get_next_attr(doc,attr)) {
2538
2539     char *nm;
2540     char *val;
2541
2542     nm  = qs_get_attr_name(doc,attr);
2543     val = qs_get_attr_value(doc,attr);
2544
2545     if (STRCASEEQ('a','A',"align", nm)) {
2546       /*----------------------------------------------------------------------*/
2547       /* CHTML 1.0 (W3C version 3.2)                                          */
2548       /*----------------------------------------------------------------------*/
2549       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2550         align = apr_pstrdup(doc->buf.pool, val);
2551       }
2552     }
2553   }
2554
2555   if (align) {
2556     W10_L(" align=\"");
2557     W10_V(align);
2558     W10_L("\"");
2559   }
2560
2561   W10_L(">");
2562   return chtml10->out;
2563 }
2564
2565
2566 /**
2567  * It is a handler who processes the DIV tag.
2568  *
2569  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2570  *                     destination is specified.
2571  * @param node   [i]   The DIV tag node is specified.
2572  * @return The conversion result is returned.
2573  */
2574 static char *
2575 s_chtml10_end_div_tag(void *pdoc, Node *UNUSED(child))
2576 {
2577   chtml10_t *chtml10;
2578   Doc *doc;
2579   request_rec *r;
2580
2581   chtml10 = GET_CHTML10(pdoc);
2582   doc     = chtml10->doc;
2583   r       = doc->r;
2584
2585   W10_L("</div>");
2586   return chtml10->out;
2587 }
2588
2589
2590 /**
2591  * It is a handler who processes the CHXJ:IF tag.
2592  *
2593  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2594  *                     destination is specified.
2595  * @param node   [i]   The CHXJ:IF tag node is specified.
2596  * @return The conversion result is returned.
2597  */
2598 static char *
2599 s_chtml10_chxjif_tag(void *pdoc, Node *node)
2600 {
2601   chtml10_t *chtml10;
2602   Doc *doc;
2603   Node *child;
2604   request_rec *r;
2605
2606   chtml10 = GET_CHTML10(pdoc);
2607   doc     = chtml10->doc;
2608   r       = doc->r;
2609
2610   for (child = qs_get_child_node(doc, node);
2611        child;
2612        child = qs_get_next_node(doc, child)) {
2613     W10_V(child->otext);
2614     s_chtml10_chxjif_tag(chtml10, child);
2615   }
2616
2617   return chtml10->out;
2618 }
2619
2620
2621 /**
2622  * It is a handler who processes the PRE tag.
2623  *
2624  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2625  *                     destination is specified.
2626  * @param node   [i]   The PRE tag node is specified.
2627  * @return The conversion result is returned.
2628  */
2629 static char *
2630 s_chtml10_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
2631 {
2632   Doc *doc;
2633   request_rec *r;
2634   chtml10_t *chtml10;
2635
2636   chtml10 = GET_CHTML10(pdoc);
2637   doc     = chtml10->doc;
2638   r       = doc->r;
2639
2640   chtml10->pre_flag++;
2641   W10_L("<pre>");
2642   return chtml10->out;
2643 }
2644
2645
2646 /**
2647  * It is a handler who processes the PRE tag.
2648  *
2649  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2650  *                     destination is specified.
2651  * @param node   [i]   The PRE tag node is specified.
2652  * @return The conversion result is returned.
2653  */
2654 static char *
2655 s_chtml10_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2656 {
2657   chtml10_t *chtml10;
2658   Doc *doc;
2659   request_rec *r;
2660
2661   chtml10 = GET_CHTML10(pdoc);
2662   doc     = chtml10->doc;
2663   r       = doc->r;
2664
2665   W10_L("</pre>");
2666   chtml10->pre_flag--;
2667
2668   return chtml10->out;
2669 }
2670
2671
2672 /**
2673  * It is a handler who processes the P tag.
2674  *
2675  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2676  *                     destination is specified.
2677  * @param node   [i]   The P tag node is specified.
2678  * @return The conversion result is returned.
2679  */
2680 static char *
2681 s_chtml10_start_p_tag(void *pdoc, Node *UNUSED(node)) 
2682 {
2683   Doc *doc;
2684   request_rec *r;
2685   chtml10_t *chtml10;
2686
2687   chtml10 = GET_CHTML10(pdoc);
2688   doc     = chtml10->doc;
2689   r       = doc->r;
2690
2691   W10_L("<p>");
2692   return chtml10->out;
2693 }
2694
2695
2696 /**
2697  * It is a handler who processes the P tag.
2698  *
2699  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2700  *                     destination is specified.
2701  * @param node   [i]   The P tag node is specified.
2702  * @return The conversion result is returned.
2703  */
2704 static char *
2705 s_chtml10_end_p_tag(void *pdoc, Node *UNUSED(child)) 
2706 {
2707   Doc *doc;
2708   request_rec *r;
2709   chtml10_t *chtml10;
2710
2711   chtml10 = GET_CHTML10(pdoc);
2712   doc     = chtml10->doc;
2713   r       = doc->r;
2714
2715   W10_L("</p>");
2716   return chtml10->out;
2717 }
2718
2719
2720 /**
2721  * It is a handler who processes the TEXTARE tag.
2722  *
2723  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2724  *                     destination is specified.
2725  * @param node   [i]   The TEXTAREA tag node is specified.
2726  * @return The conversion result is returned.
2727  */
2728 static char *
2729 s_chtml10_start_textarea_tag(void *pdoc, Node *node) 
2730 {
2731   Doc *doc;
2732   request_rec *r;
2733   chtml10_t *chtml10;
2734   Attr *attr;
2735
2736   chtml10 = GET_CHTML10(pdoc);
2737   doc     = chtml10->doc;
2738   r       = doc->r;
2739
2740
2741   chtml10->textarea_flag++;
2742
2743   W10_L("<textarea ");
2744
2745   for (attr = qs_get_attr(doc,node);
2746        attr;
2747        attr = qs_get_next_attr(doc,attr)) {
2748
2749     char *name;
2750     char *value;
2751
2752     name  = qs_get_attr_name (doc,attr);
2753     value = qs_get_attr_value(doc,attr);
2754
2755     switch(*name) {
2756     case 'n':
2757     case 'N':
2758       if (strcasecmp(name, "name") == 0) {
2759         W10_L(" name=\"");
2760         W10_V(value);
2761         W10_L("\"");
2762       }
2763       break;
2764
2765     case 'r':
2766     case 'R':
2767       if (strcasecmp(name, "rows") == 0) {
2768         W10_L(" rows=\"");
2769         W10_V(value);
2770         W10_L("\"");
2771       }
2772       break;
2773
2774     case 'c':
2775     case 'C':
2776       if (strcasecmp(name, "cols") == 0) {
2777         W10_L(" cols=\"");
2778         W10_V(value);
2779         W10_L("\"");
2780       }
2781       break;
2782     
2783     default:
2784       break;
2785     }
2786   }
2787
2788   W10_L(">\r\n");
2789   return chtml10->out;
2790 }
2791
2792
2793 /**
2794  * It is a handler who processes the TEXTAREA tag.
2795  *
2796  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2797  *                     destination is specified.
2798  * @param node   [i]   The TEXTAREA tag node is specified.
2799  * @return The conversion result is returned.
2800  */
2801 static char *
2802 s_chtml10_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
2803 {
2804   Doc *doc;
2805   request_rec *r;
2806   chtml10_t *chtml10;
2807
2808   chtml10 = GET_CHTML10(pdoc);
2809   doc     = chtml10->doc;
2810   r       = doc->r;
2811
2812   W10_L("</textarea>\r\n");
2813   chtml10->textarea_flag--;
2814
2815   return chtml10->out;
2816 }
2817
2818
2819 static char *
2820 s_chtml10_text(void *pdoc, Node *child)
2821 {
2822   char *textval;
2823   char *tmp;
2824   char *tdst;
2825   char one_byte[2];
2826   int ii;
2827   int tdst_len;
2828   chtml10_t *chtml10;
2829   Doc *doc;
2830   request_rec *r;
2831
2832   chtml10 = GET_CHTML10(pdoc);
2833   doc     = chtml10->doc;
2834   r       = doc->r;
2835   
2836   textval = qs_get_node_value(doc,child);
2837   textval = qs_trim_string(r, textval);
2838
2839   if (strlen(textval) == 0)
2840     return chtml10->out;
2841   
2842   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2843   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2844   
2845   tdst     = qs_alloc_zero_byte_string(r);
2846   memset(one_byte, 0, sizeof(one_byte));
2847   tdst_len = 0;
2848   
2849   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2850     char* out;
2851     int   rtn;
2852
2853     rtn = s_chtml10_search_emoji(chtml10, &textval[ii], &out);
2854     if (rtn) {
2855       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2856       ii+=(rtn - 1);
2857       continue;
2858     }
2859   
2860     if (is_sjis_kanji(textval[ii])) {
2861       one_byte[0] = textval[ii+0];
2862       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2863       one_byte[0] = textval[ii+1];
2864       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2865       ii++;
2866     }
2867     else 
2868     if (chtml10->pre_flag) {
2869       one_byte[0] = textval[ii+0];
2870       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2871     }
2872     else 
2873     if (chtml10->textarea_flag) {
2874       one_byte[0] = textval[ii+0];
2875       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2876     }
2877     else 
2878     if (textval[ii] != '\r' && textval[ii] != '\n') {
2879       one_byte[0] = textval[ii+0];
2880       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2881     }
2882   }
2883
2884   W10_V(tdst);
2885   return chtml10->out;
2886 }
2887
2888
2889 /**
2890  * It is a handler who processes the BLOCKQUOTE tag.
2891  *
2892  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2893  *                     destination is specified.
2894  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2895  * @return The conversion result is returned.
2896  */
2897 static char *
2898 s_chtml10_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
2899 {
2900   chtml10_t *chtml10;
2901   Doc *doc;
2902   chtml10 = GET_CHTML10(pdoc);
2903   doc     = chtml10->doc;
2904   W10_L("<blockquote>");
2905   return chtml10->out;
2906 }
2907
2908
2909 /**
2910  * It is a handler who processes the BLOCKQUOTE tag.
2911  *
2912  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2913  *                     destination is specified.
2914  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2915  * @return The conversion result is returned.
2916  */
2917 static char *
2918 s_chtml10_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
2919 {
2920   chtml10_t *chtml10;
2921   Doc *doc;
2922
2923   chtml10 = GET_CHTML10(pdoc);
2924   doc     = chtml10->doc;
2925   W10_L("</blockquote>");
2926   return chtml10->out;
2927 }
2928
2929
2930 /**
2931  * It is a handler who processes the DIR tag.
2932  *
2933  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2934  *                     destination is specified.
2935  * @param node   [i]   The DIR tag node is specified.
2936  * @return The conversion result is returned.
2937  */
2938 static char *
2939 s_chtml10_start_dir_tag(void *pdoc, Node *UNUSED(child))
2940 {
2941   chtml10_t *chtml10;
2942   Doc *doc;
2943   chtml10 = GET_CHTML10(pdoc);
2944   doc     = chtml10->doc;
2945   W10_L("<dir>");
2946   return chtml10->out;
2947 }
2948
2949
2950 /**
2951  * It is a handler who processes the DIR 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 DIR tag node is specified.
2956  * @return The conversion result is returned.
2957  */
2958 static char *
2959 s_chtml10_end_dir_tag(void *pdoc, Node *UNUSED(child))
2960 {
2961   chtml10_t *chtml10;
2962   Doc *doc;
2963
2964   chtml10 = GET_CHTML10(pdoc);
2965   doc     = chtml10->doc;
2966   W10_L("</dir>");
2967   return chtml10->out;
2968 }
2969
2970
2971 /**
2972  * It is a handler who processes the DL tag.
2973  *
2974  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2975  *                     destination is specified.
2976  * @param node   [i]   The DL tag node is specified.
2977  * @return The conversion result is returned.
2978  */
2979 static char *
2980 s_chtml10_start_dl_tag(void *pdoc, Node *UNUSED(child))
2981 {
2982   chtml10_t *chtml10;
2983   Doc *doc;
2984   chtml10 = GET_CHTML10(pdoc);
2985   doc     = chtml10->doc;
2986   W10_L("<dl>");
2987   return chtml10->out;
2988 }
2989
2990
2991 /**
2992  * It is a handler who processes the DL tag.
2993  *
2994  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2995  *                     destination is specified.
2996  * @param node   [i]   The DL tag node is specified.
2997  * @return The conversion result is returned.
2998  */
2999 static char *
3000 s_chtml10_end_dl_tag(void *pdoc, Node *UNUSED(child))
3001 {
3002   chtml10_t *chtml10;
3003   Doc *doc;
3004   chtml10 = GET_CHTML10(pdoc);
3005   doc     = chtml10->doc;
3006   W10_L("</dl>");
3007   return chtml10->out;
3008 }
3009
3010
3011 /**
3012  * It is a handter who processes the DT tag.
3013  *
3014  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3015  *                     destination is specified.
3016  * @param node   [i]   The DT tag node is specified.
3017  * @return The conversion result is returned.
3018  */
3019 static char *
3020 s_chtml10_start_dt_tag(void *pdoc, Node *UNUSED(child))
3021 {
3022   chtml10_t *chtml10;
3023   Doc *doc;
3024   chtml10 = GET_CHTML10(pdoc);
3025   doc     = chtml10->doc;
3026   W10_L("<dt>");
3027   return chtml10->out;
3028 }
3029
3030
3031 /**
3032  * It is a handter who processes the DT tag.
3033  *
3034  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3035  *                     destination is specified.
3036  * @param node   [i]   The DT tag node is specified.
3037  * @return The conversion result is returned.
3038  */
3039 static char *
3040 s_chtml10_end_dt_tag(void *pdoc, Node *UNUSED(child))
3041 {
3042   chtml10_t *chtml10;
3043   chtml10 = GET_CHTML10(pdoc);
3044   return chtml10->out;
3045 }
3046
3047
3048 /**
3049  * It is a handder who processes the DD tag.
3050  *
3051  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3052  *                     destination is specified.
3053  * @param node   [i]   The DD tag node is specified.
3054  * @return The conversion result is returned.
3055  */
3056 static char *
3057 s_chtml10_start_dd_tag(void *pdoc, Node *UNUSED(child))
3058 {
3059   chtml10_t *chtml10;
3060   Doc *doc;
3061   chtml10 = GET_CHTML10(pdoc);
3062   doc     = chtml10->doc;
3063   W10_L("<dd>");
3064   return chtml10->out;
3065 }
3066
3067
3068 /**
3069  * It is a handder who processes the DD tag.
3070  *
3071  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3072  *                     destination is specified.
3073  * @param node   [i]   The DD tag node is specified.
3074  * @return The conversion result is returned.
3075  */
3076 static char *
3077 s_chtml10_end_dd_tag(void *pdoc, Node *UNUSED(child))
3078 {
3079   chtml10_t *chtml10;
3080   chtml10 = GET_CHTML10(pdoc);
3081   return chtml10->out;
3082 }
3083 /*
3084  * vim:ts=2 et
3085  */