OSDN Git Service

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