OSDN Git Service

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