OSDN Git Service

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