OSDN Git Service

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