OSDN Git Service

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