OSDN Git Service

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