OSDN Git Service

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