2 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
3 * Copyright (C) 2005 Atsushi Konno All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "chxj_hdml.h"
18 #include "chxj_tag_util.h"
19 #include "chxj_str_util.h"
21 #include "chxj_img_conv.h"
22 #include "chxj_dump.h"
23 #include "chxj_qr_code.h"
25 #define CHECK_BOX_PREFIX "_chxj_c_"
26 #define RADIO_BUTTON_PREFIX "_chxj_r_"
27 #define SUBMIT_BUTTON_PREFIX "_chxj_s_"
29 static void s_init_hdml (hdml_t* hdml, Doc* doc, request_rec* r, device_table* spec);
30 static char* s_hdml_node_exchange (hdml_t* doc, Node* node, int indent);
31 static char* s_hdml_start_html_tag (hdml_t* doc, Node* node);
32 static char* s_hdml_end_html_tag (hdml_t* doc, Node* node);
33 static char* s_hdml_start_li_tag (hdml_t* doc, Node* node);
34 static char* s_hdml_end_li_tag (hdml_t* doc, Node* node);
35 static char* s_hdml_start_meta_tag (hdml_t* doc, Node* node);
36 static char* s_hdml_end_meta_tag (hdml_t* doc, Node* node);
37 static char* s_hdml_start_head_tag (hdml_t* doc, Node* node);
38 static char* s_hdml_end_head_tag (hdml_t* doc, Node* node);
39 static char* s_hdml_start_title_tag (hdml_t* doc, Node* node);
40 static char* s_hdml_end_title_tag (hdml_t* doc, Node* node);
41 static char* s_hdml_start_base_tag (hdml_t* doc, Node* node);
42 static char* s_hdml_end_base_tag (hdml_t* doc, Node* node);
43 static char* s_hdml_start_body_tag (hdml_t* doc, Node* node);
44 static char* s_hdml_end_body_tag (hdml_t* doc, Node* node);
45 static char* s_hdml_start_a_tag (hdml_t* doc, Node* node);
46 static char* s_hdml_end_a_tag (hdml_t* doc, Node* node);
47 static char* s_hdml_start_br_tag (hdml_t* doc, Node* node);
48 static char* s_hdml_end_br_tag (hdml_t* doc, Node* node);
49 static char* s_hdml_start_tr_tag (hdml_t* doc, Node* node);
50 static char* s_hdml_end_tr_tag (hdml_t* doc, Node* node);
51 static char* s_hdml_start_font_tag (hdml_t* doc, Node* node);
52 static char* s_hdml_end_font_tag (hdml_t* doc, Node* node);
53 static char* s_hdml_start_form_tag (hdml_t* doc, Node* node);
54 static char* s_hdml_end_form_tag (hdml_t* doc, Node* node);
55 static char* s_hdml_start_input_tag (hdml_t* doc, Node* node);
56 static char* s_hdml_end_input_tag (hdml_t* doc, Node* node);
57 static char* s_hdml_start_select_tag(hdml_t* doc, Node* node);
58 static char* s_hdml_end_select_tag (hdml_t* doc, Node* node);
59 static char* s_hdml_start_option_tag(hdml_t* doc, Node* node);
60 static char* s_hdml_end_option_tag (hdml_t* doc, Node* node);
61 static char* s_hdml_start_center_tag(hdml_t* doc, Node* node);
62 static char* s_hdml_end_center_tag (hdml_t* doc, Node* node);
63 static char* s_hdml_start_hr_tag (hdml_t* doc, Node* node);
64 static char* s_hdml_end_hr_tag (hdml_t* doc, Node* node);
65 static char* s_hdml_start_img_tag (hdml_t* doc, Node* node);
66 static char* s_hdml_end_img_tag (hdml_t* doc, Node* node);
67 static char* s_hdml_start_div_tag (hdml_t* doc, Node* node);
68 static char* s_hdml_end_div_tag (hdml_t* doc, Node* node);
69 static char* s_get_form_no (request_rec* r, hdml_t* hdml);
70 static void s_hdml_count_radio_tag (hdml_t* hdml, Node* node) ;
71 static void s_hdml_do_input_text_tag (hdml_t* hdml, Node* tag);
72 static void s_hdml_do_input_password_tag(hdml_t* hdml, Node* tag);
73 static void s_hdml_do_input_submit_tag (hdml_t* hdml, Node* tag);
74 static void s_hdml_do_input_hidden_tag (hdml_t* hdml, Node* tag);
75 static void s_hdml_do_input_radio_tag (hdml_t* hdml, Node* tag);
76 static void s_hdml_do_input_checkbox_tag(hdml_t* hdml, Node* tag);
77 static void s_hdml_tag_output_upper_half(hdml_t* hdml, Node* node);
78 static hdml_t* s_output_to_hdml_out (hdml_t* hdml, char* s);
79 static hdml_t* s_output_to_hdml_card (hdml_t* hdml, char* s);
80 static void s_output_to_postdata (hdml_t* hdml, char* s);
81 static void s_output_to_init_vars (hdml_t* hdml, char* s);
82 static int s_hdml_search_emoji (hdml_t* hdml, char* txt, char** rslt);
83 static void s_hdml_chxjif_tag (hdml_t* hdml, Node* node);
88 * converts from CHTML to hdml.
90 * @param r [i] Requet_rec is appointed.
91 * @param spec [i] The result of the device specification processing which
92 * was done in advance is appointed.
93 * @param src [i] The character string before the converting is appointed.
94 * @return The character string after the converting is returned.
97 chxj_exchange_hdml(request_rec* r,
102 chxjconvrule_entry* entryp
110 /*--------------------------------------------------------------------------*/
112 /*--------------------------------------------------------------------------*/
114 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
116 DBG(r,"i found qrcode xml");
119 DBG(r,"not found qrcode xml");
121 /*--------------------------------------------------------------------------*/
122 /* initialize hdml structure */
123 /*--------------------------------------------------------------------------*/
124 s_init_hdml(&hdml,&doc,r, spec);
126 hdml.entryp = entryp;
128 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
129 /*--------------------------------------------------------------------------*/
131 /*--------------------------------------------------------------------------*/
133 chxj_dump_out("[src] CHTML->HDML", src, srclen);
137 /*--------------------------------------------------------------------------*/
138 /* It is examined whether there is a location header. It ends without doing */
139 /* anything when is. */
140 /*--------------------------------------------------------------------------*/
141 buf = (char*)apr_table_get(r->headers_out, (const char*)"Location");
143 /*------------------------------------------------------------------------*/
144 /* The Location header generates tag in an initial HDML machine for the */
145 /* uncorrespon dence. */
146 /*------------------------------------------------------------------------*/
147 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
148 "Location is not null[Location:%s]", buf);
149 s_output_to_hdml_out(&hdml,
150 "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\n"
151 "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\n"
152 "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
154 s_output_to_hdml_out(&hdml, buf);
155 s_output_to_hdml_out(&hdml,
160 dst = apr_pstrdup(r->pool, hdml.out);
163 /*------------------------------------------------------------------------*/
164 /* Here, the parsing of the received character string is done */
165 /*------------------------------------------------------------------------*/
166 char *ss = apr_pstrdup(r->pool, src);
168 DBG1(r, "input srclen=[%d]\n", srclen);
170 qs_init_malloc(&doc);
171 qs_init_root_node(&doc);
173 qs_parse_string(&doc, ss, srclen);
175 /*------------------------------------------------------------------------*/
176 /* The number of radiobuttons is counted. */
177 /*------------------------------------------------------------------------*/
178 s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
180 dst = s_hdml_node_exchange(&hdml, qs_get_root(&doc), 0);
181 DBG1(r,"tmp=[%s]", dst);
182 qs_all_free(&doc,QX_LOGMARK);
185 /*--------------------------------------------------------------------------*/
187 /*--------------------------------------------------------------------------*/
189 chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
192 /*--------------------------------------------------------------------------*/
193 /* When there is no processing result, former character string is copied */
194 /* and it returns it. */
195 /*--------------------------------------------------------------------------*/
198 return apr_pstrdup(r->pool,src);
201 *dstlen = hdml.out_len;
203 /*--------------------------------------------------------------------------*/
204 /* Null is set at the end of the character string to make sure. */
205 /*--------------------------------------------------------------------------*/
206 dst[hdml.out_len] = 0;
212 * The HDML structure is initialized.
214 * @param hdml [i/o] The pointer to the HDML structure that wants to be
215 * initialized is specified.
216 * @param doc [i] The Doc structure that should be set to the initialized
217 * HDML structure is specified.
218 * @param r [i] To use POOL, the pointer to request_rec is specified.
219 * @param spec [i] The pointer to the device_table
222 s_init_hdml(hdml_t* hdml, Doc* doc, request_rec* r, device_table* spec)
227 /*--------------------------------------------------------------------------*/
228 /* init hdml structure value */
229 /*--------------------------------------------------------------------------*/
230 memset(hdml, 0, sizeof(hdml_t));
232 hdml->card = qs_alloc_zero_byte_string(r);
234 hdml->conf = ap_get_module_config(r->per_dir_config, &chxj_module);
235 hdml->doc->parse_mode = PARSE_MODE_CHTML;
237 for (ii=0; ii<MAX_FORM_COUNT; ii++) {
238 hdml->var_cnt[ii] = 0;
239 hdml->postdata[ii] = qs_alloc_zero_byte_string(r);
242 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
243 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
244 hdml->radio_value_list[ii][jj] = NULL;
246 hdml->radio_name_list[ii] = NULL;
247 hdml->radio_out_cnt[ii] = 0;
248 hdml->radio_checked_value[ii] = NULL;
251 for (ii=0; ii<MAX_SUBMIT_BUTTON_COUNT; ii++)
252 hdml->submit_button[ii] = NULL;
254 hdml->init_vars = qs_alloc_zero_byte_string(r);
258 hdml->form_cnt = apr_time_now();
259 hdml->out = qs_alloc_zero_byte_string(r);
263 * It is main processing converted from CHTML to HDML.
265 * @param hdml [i/o] The pointer to the HDML structure at the output
266 * destination is specified.
267 * @param node [i] The route node is specified.
268 * @param indent [i] Depth from the route node is specified. At present,
269 * other use doesn't exist.
270 * @return The conversion result is returned.
273 s_hdml_node_exchange(hdml_t* hdml, Node* node, int indent)
276 Doc* doc = hdml->doc;
277 request_rec* r = doc->r;
279 for (child = qs_get_child_node(doc,node);
281 child = qs_get_next_node(doc,child)) {
282 char* name = qs_get_node_name(doc,child);
284 /*----------------------------------------------------------------------*/
285 /* When </ HDML > tag has already been output, it doesn't process it. */
286 /*----------------------------------------------------------------------*/
287 if (hdml->hdml_end_flag == 1)
291 /*------------------------------------------------------------------------*/
292 /* <TEXTARE> (for TEST) */
293 /*------------------------------------------------------------------------*/
294 if ((*name == 't' || *name == 'T') && strcasecmp(name, "textarea") == 0) {
295 /* @todo XXX ignore */
298 /*------------------------------------------------------------------------*/
299 /* <NOBR> (for TEST) */
300 /*------------------------------------------------------------------------*/
301 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "nobr") == 0) {
302 s_hdml_node_exchange (hdml, child, indent+1);
305 /*------------------------------------------------------------------------*/
306 /* <PRE> (for TEST) */
307 /*------------------------------------------------------------------------*/
308 if ((*name == 'p' || *name == 'P') && strcasecmp(name, "pre") == 0) {
309 s_hdml_node_exchange (hdml, child, indent+1);
312 /*------------------------------------------------------------------------*/
314 /*------------------------------------------------------------------------*/
315 if ((*name == 'p' || *name == 'P') && strcasecmp(name, "p") == 0) {
316 s_hdml_node_exchange (hdml, child, indent+1);
319 /*------------------------------------------------------------------------*/
320 /* <UL> (for TEST) */
321 /*------------------------------------------------------------------------*/
322 if ((*name == 'u' || *name == 'U') && strcasecmp(name, "ul") == 0) {
323 s_hdml_node_exchange (hdml, child, indent+1);
325 /*------------------------------------------------------------------------*/
326 /* <LI> (for TEST) */
327 /*------------------------------------------------------------------------*/
329 if ((*name == 'l' || *name == 'L') && strcasecmp(name, "li") == 0) {
330 s_hdml_start_li_tag(hdml, child);
331 s_hdml_node_exchange (hdml, child, indent+1);
332 s_hdml_end_li_tag(hdml, child);
335 if (*name == 'h' || *name == 'H') {
336 /*----------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------*/
339 if (strcasecmp(name, "html") == 0) {
340 hdml->out = s_hdml_start_html_tag(hdml, child);
341 hdml->hdml_br_flag = 0;
342 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
343 hdml->out = s_hdml_end_html_tag(hdml, child);
345 /*----------------------------------------------------------------------*/
347 /*----------------------------------------------------------------------*/
349 if (strcasecmp(name, "head") == 0) {
350 hdml->out = s_hdml_start_head_tag(hdml, child);
351 hdml->hdml_br_flag = 0;
352 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
353 hdml->out = s_hdml_end_head_tag(hdml, child);
355 /*----------------------------------------------------------------------*/
357 /*----------------------------------------------------------------------*/
359 if (strcasecmp(name, "hr") == 0) {
360 hdml->out = s_hdml_start_hr_tag(hdml, child);
361 hdml->out = s_hdml_end_hr_tag(hdml, child);
364 /*------------------------------------------------------------------------*/
366 /*------------------------------------------------------------------------*/
368 if ((*name == 'm' || *name == 'M') && strcasecmp(name, "meta") == 0) {
369 hdml->out = s_hdml_start_meta_tag(hdml, child);
370 hdml->hdml_br_flag = 0;
371 hdml->out = s_hdml_end_meta_tag(hdml, child);
374 if (*name == 'b' || *name == 'B') {
375 /*----------------------------------------------------------------------*/
377 /*----------------------------------------------------------------------*/
378 if (strcasecmp(name, "base") == 0) {
379 hdml->out = s_hdml_start_base_tag(hdml, child);
380 hdml->hdml_br_flag = 0;
381 hdml->out = s_hdml_end_base_tag(hdml, child);
383 /*----------------------------------------------------------------------*/
385 /*----------------------------------------------------------------------*/
387 if (strcasecmp(name, "body") == 0) {
388 hdml->out = s_hdml_start_body_tag(hdml, child);
389 hdml->hdml_br_flag = 0;
390 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
391 hdml->out = s_hdml_end_body_tag(hdml, child);
393 /*----------------------------------------------------------------------*/
395 /*----------------------------------------------------------------------*/
397 if (strcasecmp(name, "br") == 0) {
398 hdml->out = s_hdml_start_br_tag(hdml, child);
399 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
400 hdml->out = s_hdml_end_br_tag(hdml, child);
403 /*------------------------------------------------------------------------*/
405 /*------------------------------------------------------------------------*/
407 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "a") == 0) {
408 hdml->out = s_hdml_start_a_tag(hdml, child);
409 hdml->hdml_br_flag = 0;
410 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
411 hdml->out = s_hdml_end_a_tag(hdml, child);
414 if (*name == 'f' || *name == 'F') {
415 /*----------------------------------------------------------------------*/
417 /*----------------------------------------------------------------------*/
418 if (strcasecmp(name, "font") == 0) {
419 hdml->out = s_hdml_start_font_tag(hdml, child);
420 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
421 hdml->out = s_hdml_end_font_tag(hdml, child);
423 /*----------------------------------------------------------------------*/
425 /*----------------------------------------------------------------------*/
427 if (strcasecmp(name, "form") == 0) {
428 hdml->out = s_hdml_start_form_tag(hdml, child);
429 hdml->hdml_br_flag = 0;
430 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
431 hdml->out = s_hdml_end_form_tag(hdml, child);
435 if (*name == 'i' || *name == 'I') {
436 /*----------------------------------------------------------------------*/
438 /*----------------------------------------------------------------------*/
439 if (strcasecmp(name, "input") == 0) {
440 hdml->out = s_hdml_start_input_tag(hdml, child);
441 hdml->hdml_br_flag = 0;
442 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
443 hdml->out = s_hdml_end_input_tag(hdml, child);
445 /*----------------------------------------------------------------------*/
447 /*----------------------------------------------------------------------*/
449 if (strcasecmp(name, "img") == 0) {
450 hdml->out = s_hdml_start_img_tag(hdml, child);
451 hdml->hdml_br_flag = 0;
452 hdml->out = s_hdml_end_img_tag (hdml, child);
456 if (*name == 's' || *name == 'S') {
457 /*----------------------------------------------------------------------*/
459 /*----------------------------------------------------------------------*/
460 if (strcasecmp(name, "select") == 0) {
461 hdml->out = s_hdml_start_select_tag(hdml, child);
462 hdml->hdml_br_flag = 0;
463 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
464 hdml->out = s_hdml_end_select_tag(hdml, child);
466 /*----------------------------------------------------------------------*/
467 /* <STYLE> (for TEST) */
468 /*----------------------------------------------------------------------*/
470 if (strcasecmp(name, "style") == 0) {
471 s_hdml_node_exchange (hdml, child, indent+1);
473 /*----------------------------------------------------------------------*/
474 /* <SPAN> (for TEST) */
475 /*----------------------------------------------------------------------*/
477 if (strcasecmp(name, "span") == 0) {
478 s_hdml_node_exchange (hdml, child, indent+1);
481 /*------------------------------------------------------------------------*/
483 /*------------------------------------------------------------------------*/
485 if ((*name == 'o' || *name == 'O') && strcasecmp(name, "option") == 0) {
486 hdml->out = s_hdml_start_option_tag(hdml, child);
487 hdml->hdml_br_flag = 0;
488 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
489 hdml->out = s_hdml_end_option_tag(hdml, child);
491 /*------------------------------------------------------------------------*/
493 /*------------------------------------------------------------------------*/
495 if ((*name == 'd' || *name == 'D') && strcasecmp(name, "div") == 0) {
496 hdml->out = s_hdml_start_div_tag(hdml, child);
497 hdml->hdml_br_flag = 0;
498 hdml->out = s_hdml_node_exchange(hdml, child, indent+1);
499 hdml->out = s_hdml_end_div_tag(hdml, child);
502 if (*name == 'c' || *name == 'C') {
503 /*----------------------------------------------------------------------*/
505 /*----------------------------------------------------------------------*/
506 if (strcasecmp(name, "center") == 0) {
507 hdml->out = s_hdml_start_center_tag(hdml, child);
508 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
509 hdml->out = s_hdml_end_center_tag(hdml, child);
511 /*----------------------------------------------------------------------*/
513 /*----------------------------------------------------------------------*/
515 if (strcasecmp(name, "chxj:if") == 0) {
516 DBG(r,"chxj:if tag found");
517 if (chxj_chxjif_is_mine(hdml->spec, doc, child)) {
518 DBG(r,"chxj:if tag is mine");
519 char* parse_attr = NULL;
521 parse_attr = qs_get_parse_attr(doc, child, r);
522 if (parse_attr && strcasecmp(parse_attr, "true") == 0)
523 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
525 s_hdml_chxjif_tag(hdml, child);
530 if (*name == 't' || *name == 'T') {
531 /*----------------------------------------------------------------------*/
533 /*----------------------------------------------------------------------*/
534 if (strcasecmp(name, "title") == 0) {
535 hdml->out = s_hdml_start_title_tag(hdml, child);
536 hdml->hdml_br_flag = 0;
537 hdml->out = s_hdml_node_exchange(hdml, child,indent+1);
538 hdml->out = s_hdml_end_title_tag(hdml, child);
540 /*----------------------------------------------------------------------*/
541 /* <TABLE> (for TEST) */
542 /*----------------------------------------------------------------------*/
544 if (strcasecmp(name, "table") == 0) {
545 s_hdml_node_exchange (hdml, child, indent+1);
547 /*----------------------------------------------------------------------*/
548 /* <TBODY> (for TEST) */
549 /*----------------------------------------------------------------------*/
551 if (strcasecmp(name, "tbody") == 0) {
552 s_hdml_node_exchange (hdml, child, indent+1);
554 /*----------------------------------------------------------------------*/
555 /* <TH> (for TEST) */
556 /*----------------------------------------------------------------------*/
558 if (strcasecmp(name, "th") == 0) {
559 s_hdml_node_exchange (hdml, child, indent+1);
561 /*----------------------------------------------------------------------*/
562 /* <TR> (for TEST) */
563 /*----------------------------------------------------------------------*/
565 if (strcasecmp(name, "tr") == 0) {
566 s_hdml_start_tr_tag (hdml, child);
567 s_hdml_node_exchange (hdml, child,indent+1);
568 s_hdml_end_tr_tag (hdml, child);
570 /*----------------------------------------------------------------------*/
571 /* <TD> (for TEST) */
572 /*----------------------------------------------------------------------*/
574 if (strcasecmp(name, "td") == 0) {
575 s_hdml_node_exchange (hdml, child, indent+1);
577 /*----------------------------------------------------------------------*/
579 /*----------------------------------------------------------------------*/
581 if (strcasecmp(name, "text") == 0) {
589 textval = qs_get_node_value(doc,child);
590 textval = qs_trim_string(r, textval);
591 if (strlen(textval) == 0)
594 if (hdml->option_flag == 1)
597 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
598 memset(tmp, 0, qs_get_node_size(doc,child)+1);
599 tdst = apr_palloc(r->pool, 1);
604 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
606 int rtn = s_hdml_search_emoji(hdml, &textval[ii], &out);
608 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
612 if (is_sjis_kanji(textval[ii])) {
613 one_byte[0] = textval[ii+0];
614 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
615 one_byte[0] = textval[ii+1];
616 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
620 if (textval[ii] != '\r' && textval[ii] != '\n') {
621 one_byte[0] = textval[ii+0];
622 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
625 memcpy(tmp, textval, strlen(textval)-1);
627 s_hdml_tag_output_upper_half(hdml, node);
628 s_output_to_hdml_out(hdml, tdst);
629 hdml->hdml_br_flag = 0;
633 hdml->out[hdml->out_len] = 0;
639 s_hdml_search_emoji(hdml_t* hdml, char* txt, char** rslt)
652 DBG(r,"spec is NULL");
654 for (ee = hdml->conf->emoji;
657 unsigned char hex1byte;
658 unsigned char hex2byte;
661 DBG(r, "emoji->imode is NULL");
665 hex1byte = ee->imode->hex1byte & 0xff;
666 hex2byte = ee->imode->hex2byte & 0xff;
668 if (ee->imode->string
669 && strlen(ee->imode->string) > 0
670 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
671 if (spec == NULL || spec->emoji_type == NULL) {
672 *rslt = apr_psprintf(r->pool,
675 return strlen(ee->imode->string);
678 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
679 *rslt = apr_psprintf(r->pool,
682 return strlen(ee->imode->string);
685 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
686 *rslt = apr_psprintf(r->pool,
689 return strlen(ee->imode->string);
692 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
693 *rslt = apr_psprintf(r->pool,
696 return strlen(ee->imode->string);
699 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
700 *rslt = apr_psprintf(r->pool,
703 return strlen(ee->imode->string);
706 *rslt = apr_psprintf(r->pool,
709 return strlen(ee->imode->string);
714 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
715 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
716 if (spec == NULL || spec->emoji_type == NULL) {
717 *rslt = apr_psprintf(r->pool,
723 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
724 *rslt = apr_psprintf(r->pool,
730 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
731 *rslt = apr_psprintf(r->pool,
737 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
738 *rslt = apr_psprintf(r->pool,
744 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
745 *rslt = apr_psprintf(r->pool,
751 *rslt = apr_psprintf(r->pool,
762 * It is a handler who processes the HTML tag.
764 * @param hdml [i/o] The pointer to the HDML structure at the output
765 * destination is specified.
766 * @param node [i] The HTML tag node is specified.
767 * @return The conversion result is returned.
770 s_hdml_start_html_tag(hdml_t* hdml, Node* node)
772 s_output_to_hdml_out(hdml,
773 "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\n"
774 "<NODISPLAY NAME=D0>\n"
775 "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\n"
785 * It is a handler who processes the HTML tag.
787 * @param hdml [i/o] The pointer to the HDML structure at the output
788 * destination is specified.
789 * @param node [i] The HTML tag node is specified.
790 * @return The conversion result is returned.
793 s_hdml_end_html_tag(hdml_t* hdml, Node* child)
795 s_output_to_hdml_card(hdml,
796 "<NODISPLAY NAME=D1>\n"
797 "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
800 if (strlen(hdml->init_vars))
801 s_output_to_hdml_card(hdml, hdml->init_vars );
803 s_output_to_hdml_card(hdml, "_chxj_dmy=" );
805 s_output_to_hdml_card(hdml,
810 s_output_to_hdml_out(hdml, hdml->card );
811 s_output_to_hdml_out(hdml, "</HDML>\n");
813 hdml->hdml_end_flag = 1;
819 * It is a handler who processes the META tag.
821 * @param hdml [i/o] The pointer to the HDML structure at the output
822 * destination is specified.
823 * @param node [i] The META tag node is specified.
824 * @return The conversion result is returned.
827 s_hdml_start_meta_tag(hdml_t* hdml, Node* node)
834 * It is a handler who processes the META tag.
836 * @param hdml [i/o] The pointer to the HDML structure at the output
837 * destination is specified.
838 * @param node [i] The META tag node is specified.
839 * @return The conversion result is returned.
842 s_hdml_end_meta_tag(hdml_t* hdml, Node* child)
848 * It is a handler who processes the HEAD tag.
850 * @param hdml [i/o] The pointer to the HDML structure at the output
851 * destination is specified.
852 * @param node [i] The HEAD tag node is specified.
853 * @return The conversion result is returned.
856 s_hdml_start_head_tag(hdml_t* hdml, Node* node)
863 * It is a handler who processes the HEAD tag.
865 * @param hdml [i/o] The pointer to the HDML structure at the output
866 * destination is specified.
867 * @param node [i] The HEAD tag node is specified.
868 * @return The conversion result is returned.
871 s_hdml_end_head_tag(hdml_t* hdml, Node* child)
878 * It is a handler who processes the TITLE tag.
880 * @param hdml [i/o] The pointer to the HDML structure at the output
881 * destination is specified.
882 * @param node [i] The TITLE tag node is specified.
883 * @return The conversion result is returned.
886 s_hdml_start_title_tag(hdml_t* hdml, Node* node)
888 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
889 hdml->found_title = 1;
895 * It is a handler who processes the TITLE tag.
897 * @param hdml [i/o] The pointer to the HDML structure at the output
898 * destination is specified.
899 * @param node [i] The TITLE tag node is specified.
900 * @return The conversion result is returned.
903 s_hdml_end_title_tag(hdml_t* hdml, Node* child)
905 s_output_to_hdml_out(hdml, "\">\n");
911 * It is a handler who processes the BASE tag.
913 * @param hdml [i/o] The pointer to the HDML structure at the output
914 * destination is specified.
915 * @param node [i] The BASE tag node is specified.
916 * @return The conversion result is returned.
919 s_hdml_start_base_tag(hdml_t* hdml, Node* node)
926 * It is a handler who processes the BASE tag.
928 * @param hdml [i/o] The pointer to the HDML structure at the output
929 * destination is specified.
930 * @param node [i] The BASE tag node is specified.
931 * @return The conversion result is returned.
934 s_hdml_end_base_tag(hdml_t* hdml, Node* child)
940 * It is a handler who processes the BODY tag.
942 * @param hdml [i/o] The pointer to the HDML structure at the output
943 * destination is specified.
944 * @param node [i] The BODY tag node is specified.
945 * @return The conversion result is returned.
948 s_hdml_start_body_tag(hdml_t* hdml, Node* node)
950 Doc* doc = hdml->doc;
953 if (hdml->found_title == 0)
954 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\n");
956 s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
958 /*--------------------------------*/
960 /*--------------------------------*/
961 for (attr = qs_get_attr(doc,node);
963 attr = qs_get_next_attr(doc,attr)) {
964 char* name = qs_get_attr_name(doc,attr);
966 if ((*name == 'b' || *name == 'B') && strcasecmp(name, "bgcolor") == 0) {
970 if ((*name == 't' || *name == 'T') && strcasecmp(name, "text") == 0) {
974 if ((*name == 'l' || *name == 'L') && strcasecmp(name, "link") == 0) {
978 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alink") == 0) {
982 if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vlink") == 0) {
987 s_output_to_hdml_out(hdml, ">\n");
993 * It is a handler who processes the BODY tag.
995 * @param hdml [i/o] The pointer to the HDML structure at the output
996 * destination is specified.
997 * @param node [i] The BODY tag node is specified.
998 * @return The conversion result is returned.
1001 s_hdml_end_body_tag(hdml_t* hdml, Node* child)
1003 s_output_to_hdml_out(hdml, "\n</DISPLAY>\n");
1009 * It is a handler who processes the A tag.
1011 * @param hdml [i/o] The pointer to the HDML structure at the output
1012 * destination is specified.
1013 * @param node [i] The A tag node is specified.
1014 * @return The conversion result is returned.
1017 s_hdml_start_a_tag(hdml_t* hdml, Node* node)
1019 Doc* doc = hdml->doc;
1022 s_hdml_tag_output_upper_half(hdml,node);
1024 s_output_to_hdml_out(hdml, "<A");
1027 /*------------------------------------*/
1028 /* Get Attributes */
1029 /*------------------------------------*/
1030 for (attr = qs_get_attr(doc,node);
1032 attr = qs_get_next_attr(doc,attr)) {
1033 char* name = qs_get_attr_name(doc,attr);
1034 char* value = qs_get_attr_value(doc,attr);
1035 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
1039 if ((*name == 'h' || *name == 'H') && strcasecmp(name, "href") == 0) {
1040 if ((*value == 'm' || *value == 'M') && strncasecmp(value, "mailto:", 7) == 0) {
1041 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1042 s_output_to_hdml_out(hdml, value );
1043 s_output_to_hdml_out(hdml, "\" " );
1046 if ((*value == 't' || *value == 'T') && strncasecmp(value, "tel:", 4) == 0) {
1048 s_output_to_hdml_out(hdml, " TASK=CALL NUMBER=\"");
1049 s_output_to_hdml_out(hdml, &value[4] );
1050 s_output_to_hdml_out(hdml, "\" " );
1053 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1054 s_output_to_hdml_out(hdml, value );
1055 s_output_to_hdml_out(hdml, "\"" );
1059 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0) {
1060 if (strcasecmp(value, "0") != 0) {
1061 s_output_to_hdml_out(hdml, " ACCESSKEY=" );
1062 s_output_to_hdml_out(hdml, value );
1063 s_output_to_hdml_out(hdml, "" );
1067 if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cti") == 0) {
1071 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ijam") == 0) {
1075 if ((*name == 'u' || *name == 'U') && strcasecmp(name, "utn") == 0) {
1079 if ((*name == 't' || *name == 'T') && strcasecmp(name, "telbook") == 0) {
1083 if ((*name == 'k' || *name == 'K') && strcasecmp(name, "kana") == 0) {
1087 if ((*name == 'e' || *name == 'E') && strcasecmp(name, "email") == 0) {
1091 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ista") == 0) {
1095 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ilet") == 0) {
1099 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "iswf") == 0) {
1103 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "irst") == 0) {
1107 s_output_to_hdml_out(hdml, ">" );
1109 hdml->hdml_a_flag = 1;
1115 * It is a handler who processes the A tag.
1117 * @param hdml [i/o] The pointer to the HDML structure at the output
1118 * destination is specified.
1119 * @param node [i] The A tag node is specified.
1120 * @return The conversion result is returned.
1123 s_hdml_end_a_tag(hdml_t* hdml, Node* child)
1125 s_output_to_hdml_out(hdml, "</A>\n");
1127 hdml->hdml_a_flag = 0;
1133 * It is a handler who processes the BR tag.
1135 * @param hdml [i/o] The pointer to the HDML structure at the output
1136 * destination is specified.
1137 * @param node [i] The BR tag node is specified.
1138 * @return The conversion result is returned.
1141 s_hdml_start_br_tag(hdml_t* hdml, Node* node)
1143 if (hdml->in_center > 0)
1144 hdml->in_center = 0;
1146 if (hdml->div_in_center > 0)
1147 hdml->div_in_center = 0;
1149 s_output_to_hdml_out(hdml, "<BR>\n");
1151 hdml->hdml_br_flag = 1;
1157 * It is a handler who processes the BR tag.
1159 * @param hdml [i/o] The pointer to the HDML structure at the output
1160 * destination is specified.
1161 * @param node [i] The BR tag node is specified.
1162 * @return The conversion result is returned.
1165 s_hdml_end_br_tag(hdml_t* hdml, Node* child)
1171 * It is a handler who processes the TR tag.
1173 * @param hdml [i/o] The pointer to the HDML structure at the output
1174 * destination is specified.
1175 * @param node [i] The TR tag node is specified.
1176 * @return The conversion result is returned.
1179 s_hdml_start_tr_tag(hdml_t* hdml, Node* node)
1181 if (hdml->in_center > 0)
1182 hdml->in_center = 0;
1184 if (hdml->div_in_center > 0)
1185 hdml->div_in_center = 0;
1187 s_output_to_hdml_out(hdml, "<BR>\n");
1189 hdml->hdml_br_flag = 1;
1195 * It is a handler who processes the TR tag.
1197 * @param hdml [i/o] The pointer to the HDML structure at the output
1198 * destination is specified.
1199 * @param node [i] The TR tag node is specified.
1200 * @return The conversion result is returned.
1203 s_hdml_end_tr_tag(hdml_t* hdml, Node* child)
1209 * It is a handler who processes the FONT tag.
1211 * @param hdml [i/o] The pointer to the HDML structure at the output
1212 * destination is specified.
1213 * @param node [i] The FONT tag node is specified.
1214 * @return The conversion result is returned.
1217 s_hdml_start_font_tag(hdml_t* hdml, Node* node)
1223 * It is a handler who processes the FONT tag.
1225 * @param hdml [i/o] The pointer to the HDML structure at the output
1226 * destination is specified.
1227 * @param node [i] The FONT tag node is specified.
1228 * @return The conversion result is returned.
1231 s_hdml_end_font_tag(hdml_t* hdml, Node* child)
1237 * It is a handler who processes the FORM tag.
1239 * @param hdml [i/o] The pointer to the HDML structure at the output
1240 * destination is specified.
1241 * @param node [i] The FORM tag node is specified.
1242 * @return The conversion result is returned.
1245 s_hdml_start_form_tag(hdml_t* hdml, Node* node)
1247 request_rec* r = hdml->doc->r;
1249 Doc* doc = hdml->doc;
1252 hdml->form_tmp = apr_psprintf(r->pool,
1253 "<NODISPLAY NAME=F%d>\n",
1254 hdml->pure_form_cnt);
1255 hdml->form_tmp = apr_pstrcat(r->pool,
1257 "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",NULL);
1258 /* Get Attributes */
1259 for (attr = qs_get_attr(doc,node);
1261 attr = qs_get_next_attr(doc,attr)) {
1262 char* name = qs_get_attr_name(doc,attr);
1263 char* value = qs_get_attr_value(doc,attr);
1265 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "action") == 0) {
1266 act = apr_psprintf(r->pool, "%s", value);
1271 hdml->form_tmp = apr_pstrcat(r->pool,
1276 hdml->form_tmp = apr_pstrcat(r->pool,
1279 hdml->form_tmp = apr_pstrcat(r->pool,
1281 "POSTDATA=\"", NULL);
1287 * handler of the form end tag.
1289 * @param hdml [i/o] The pointer to the HDML structure at the output
1290 * destination is specified.
1291 * @param child [i] unused.
1292 * @return The HDML output result after it edits it is returned.
1295 s_hdml_end_form_tag(hdml_t* hdml, Node* child)
1297 request_rec* r = hdml->doc->r;
1299 s_output_to_postdata(hdml, "_chxj_dmy=");
1301 hdml->form_tmp = apr_pstrcat(r->pool,
1303 hdml->postdata[hdml->pure_form_cnt],
1306 hdml->form_tmp = apr_pstrcat(r->pool,
1308 "\" CLEAR=TRUE >\n",
1310 hdml->form_tmp = apr_pstrcat(r->pool,
1315 s_output_to_hdml_card(hdml, hdml->form_tmp);
1317 hdml->form_tmp = NULL;
1318 hdml->pure_form_cnt++;
1324 * It is a handler that takes charge of the processing of the input tag.
1326 * @param hdml [i/o] The pointer to the HDML structure at the output
1327 * destination is specified.
1328 * @param node [i] The tag node to be processed is specified.
1331 s_hdml_start_input_tag(hdml_t* hdml, Node* node)
1333 Doc* doc = hdml->doc;
1336 /*--------------------------------------------------------------------------*/
1337 /* The attribute of the input tag is acquired. */
1338 /*--------------------------------------------------------------------------*/
1339 for (attr = qs_get_attr(doc,node);
1341 attr = qs_get_next_attr(doc,attr)) {
1342 char* name = qs_get_attr_name(doc,attr);
1343 char* value = qs_get_attr_value(doc,attr);
1345 if ((*name == 't'|| *name == 'T') && strcasecmp(name, "type") == 0) {
1346 if ((*value == 't' || *value == 'T') && strcasecmp(value, "text") == 0) {
1347 /*--------------------------------------------------------------------*/
1348 /* "input type ='text'" tag is processed. */
1349 /*--------------------------------------------------------------------*/
1350 s_hdml_do_input_text_tag(hdml, node);
1353 if ((*value == 'p' || *value == 'P') && strcasecmp(value, "password") == 0) {
1354 /*--------------------------------------------------------------------*/
1355 /* "input type='password'" tag is processed. */
1356 /*--------------------------------------------------------------------*/
1357 s_hdml_do_input_password_tag(hdml, node);
1360 if ((*value == 's' || *value == 'S') && strcasecmp(value, "submit") == 0) {
1361 /*--------------------------------------------------------------------*/
1362 /* "input type='submit'" tag is processed. */
1363 /*--------------------------------------------------------------------*/
1364 s_hdml_do_input_submit_tag(hdml, node);
1367 if ((*value == 'h' || *value == 'H') && strcasecmp(value, "hidden") == 0) {
1368 /*--------------------------------------------------------------------*/
1369 /* "input type='hidden'" tag is processed. */
1370 /*--------------------------------------------------------------------*/
1371 s_hdml_do_input_hidden_tag(hdml, node);
1374 if ((*value == 'r' || *value == 'R') && strcasecmp(value, "radio") == 0) {
1375 /*--------------------------------------------------------------------*/
1376 /* "input type='radio'" tag is processed. */
1377 /*--------------------------------------------------------------------*/
1378 s_hdml_do_input_radio_tag(hdml, node);
1381 if ((*value == 'c' || *value == 'C') && strcasecmp(value, "checkbox") == 0) {
1382 /*--------------------------------------------------------------------*/
1383 /* "input type='checkbox'" tag is processed. */
1384 /*--------------------------------------------------------------------*/
1385 s_hdml_do_input_checkbox_tag(hdml, node);
1389 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
1393 if ((*name == 'v' || *name == 'V') && strcasecmp(name, "value") == 0) {
1397 if ((*name == 's' || *name == 'S') && strcasecmp(name, "size") == 0) {
1401 if ((*name == 'm' || *name == 'M') && strcasecmp(name, "maxlength") == 0) {
1405 if ((*name == 'c' || *name == 'C') && strcasecmp(name, "checked") == 0) {
1409 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0) {
1413 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "istyle") == 0) {
1421 * The substitution processing of tag "input type = text" is done.
1423 * @param hdml [i/o] The pointer to the HDML structure at the output
1424 * destination is specified.
1425 * @param tag [i] The tag node of input type=text is specified.
1428 s_hdml_do_input_text_tag(hdml_t* hdml, Node* tag)
1430 Doc* doc = hdml->doc;
1431 request_rec* r = doc->r;
1438 s_hdml_tag_output_upper_half(hdml, tag);
1441 s_output_to_hdml_out(hdml,
1442 apr_psprintf(r->pool,
1443 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1444 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1446 s_get_form_no(r, hdml),
1447 hdml->var_cnt[hdml->pure_form_cnt],
1448 s_get_form_no(r, hdml),
1449 hdml->var_cnt[hdml->pure_form_cnt]
1452 s_output_to_hdml_out(hdml,
1453 apr_psprintf(r->pool, "[$%s%02d]</A>\n" ,
1454 s_get_form_no(r, hdml),
1455 hdml->var_cnt[hdml->pure_form_cnt]));
1457 /*--------------------------------------------------------------------------*/
1458 /* ENTRY CARD is output here. */
1459 /*--------------------------------------------------------------------------*/
1460 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1461 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1462 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1468 nm = qs_get_name_attr(doc, tag, r);
1470 nm = qs_alloc_zero_byte_string(r);
1473 s_output_to_postdata(hdml,
1474 apr_psprintf(r->pool,
1477 s_get_form_no(r, hdml),
1478 hdml->var_cnt[hdml->pure_form_cnt]));
1480 mlen = qs_get_maxlength_attr (doc, tag, r);
1481 is = qs_get_istyle_attr (doc, tag, r);
1482 val = qs_get_value_attr (doc, tag, r);
1484 fmt = qs_conv_istyle_to_format(r, is);
1485 DBG(r,"qs_conv_istyle_to_format end");
1489 for (ii=0; ii<strlen(mlen); ii++) {
1490 if (mlen[ii] < '0' || mlen[ii] > '9') {
1491 mlen = apr_psprintf(r->pool, "0");
1495 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1498 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1501 s_output_to_hdml_card(hdml,
1502 " MARKABLE=FALSE>\n"
1503 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\n"
1507 s_output_to_init_vars(hdml,
1508 apr_psprintf(r->pool, "%s%02d=%s",
1509 s_get_form_no(r, hdml),
1510 hdml->var_cnt[hdml->pure_form_cnt],
1511 ap_escape_uri(r->pool,val)));
1513 s_output_to_init_vars(hdml,
1514 apr_psprintf(r->pool, "%s%02d=",
1515 s_get_form_no(r, hdml),
1516 hdml->var_cnt[hdml->pure_form_cnt]));
1518 hdml->var_cnt[hdml->pure_form_cnt]++;
1522 * The substitution processing of tag "input type = password" is done.
1524 * @param hdml [i/o] The pointer to the HDML structure at the output
1525 * destination is specified.
1526 * @param tag [i] The tag node of input type=password is specified.
1529 s_hdml_do_input_password_tag(hdml_t* hdml, Node* tag)
1531 Doc* doc = hdml->doc;
1532 request_rec* r = doc->r;
1539 s_hdml_tag_output_upper_half(hdml, tag);
1542 s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1543 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1544 s_output_to_hdml_out(hdml,
1545 apr_psprintf(r->pool, "VARS=\"V=$%s%02d\" ",
1546 s_get_form_no(r, hdml),
1547 hdml->var_cnt[hdml->pure_form_cnt]));
1549 s_output_to_hdml_out(hdml,
1550 apr_psprintf(r->pool, "RECEIVE=%s%02d>" ,
1551 s_get_form_no(r, hdml),
1552 hdml->var_cnt[hdml->pure_form_cnt]));
1553 s_output_to_hdml_out(hdml,
1554 apr_psprintf(r->pool, "[$%s%02d]</A>\n" ,
1555 s_get_form_no(r, hdml),
1556 hdml->var_cnt[hdml->pure_form_cnt]));
1558 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1559 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1560 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1567 nm = qs_get_name_attr(doc, tag, r);
1569 nm = qs_alloc_zero_byte_string(r);
1571 s_output_to_postdata(hdml,
1572 apr_psprintf(r->pool,
1575 s_get_form_no(r, hdml),
1576 hdml->var_cnt[hdml->pure_form_cnt]));
1578 mlen = qs_get_maxlength_attr (doc, tag, r);
1579 val = qs_get_value_attr (doc, tag, r);
1580 /*--------------------------------------------------------------------------*/
1581 /* Default is a figure input. */
1582 /*--------------------------------------------------------------------------*/
1583 fmt = apr_psprintf(r->pool, "N");
1585 if (chxj_chk_numeric(mlen) != 0)
1586 mlen = apr_psprintf(r->pool, "0");
1587 s_output_to_hdml_card(hdml,
1588 apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1591 s_output_to_hdml_card(hdml,
1592 apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1594 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1596 s_output_to_hdml_card(hdml,
1597 " MARKABLE=FALSE>\n"
1598 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\n"
1602 s_output_to_init_vars(hdml,
1603 apr_psprintf(r->pool, "%s%02d=%s",
1604 s_get_form_no(r, hdml),
1605 hdml->var_cnt[hdml->pure_form_cnt],
1606 ap_escape_uri(r->pool,val)));
1608 s_output_to_init_vars(hdml,
1609 apr_psprintf(r->pool, "%s%02d=",
1610 s_get_form_no(r, hdml),
1611 hdml->var_cnt[hdml->pure_form_cnt]));
1613 hdml->var_cnt[hdml->pure_form_cnt]++;
1617 * The substitution processing of tag "input type = submit" is done.
1619 * @param hdml [i/o] The pointer to the HDML structure at the output
1620 * destination is specified.
1621 * @param tag [i] The tag node of input type=submit is specified.
1624 s_hdml_do_input_submit_tag(hdml_t* hdml, Node* tag)
1626 Doc* doc = hdml->doc;
1627 request_rec* r = doc->r;
1631 s_hdml_tag_output_upper_half(hdml, tag);
1633 s_output_to_hdml_out(hdml,
1634 apr_psprintf(r->pool,
1635 "<A TASK=GO LABEL=OK DEST=#F%d ",
1636 hdml->pure_form_cnt));
1638 /*--------------------------------------------------------------------------*/
1639 /* get name and value attribute */
1640 /*--------------------------------------------------------------------------*/
1641 nm = qs_get_name_attr (doc, tag, r);
1642 val = qs_get_value_attr (doc, tag, r);
1645 s_output_to_hdml_out(hdml,
1646 apr_psprintf(r->pool, "VARS=\"%s=%s\" ",
1648 ap_escape_uri(r->pool,val)));
1649 if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1650 s_output_to_postdata(hdml,
1651 apr_psprintf(r->pool,"%s%s=$%s",
1652 SUBMIT_BUTTON_PREFIX, nm, nm));
1655 s_output_to_hdml_out(hdml, ">" );
1656 s_output_to_hdml_out(hdml, val);
1657 s_output_to_hdml_out(hdml, "</A>\n" );
1661 * The substitution processing of tag "input type = hidden" is done.
1663 * @param hdml [i/o] The pointer to the HDML structure at the output
1664 * destination is specified.
1665 * @param tag [i] The tag node of input type=hidden is specified.
1668 s_hdml_do_input_hidden_tag(hdml_t* hdml, Node* tag)
1670 Doc* doc = hdml->doc;
1671 request_rec* r = doc->r;
1675 /*--------------------------------------------------------------------------*/
1676 /* get name and value attribute */
1677 /*--------------------------------------------------------------------------*/
1678 nm = qs_get_name_attr (doc, tag, r);
1679 val = qs_get_value_attr (doc, tag, r);
1682 s_output_to_postdata(hdml,
1683 apr_psprintf(r->pool,
1686 ap_escape_uri(r->pool, val)));
1691 * The substitution processing of tag "input type = radio" is done.
1693 * @param hdml [i/o] The pointer to the HDML structure at the output
1694 * destination is specified.
1695 * @param tag [i] The tag node of input type=radio is specified.
1698 s_hdml_do_input_radio_tag(hdml_t* hdml, Node* tag)
1700 Doc* doc = hdml->doc;
1701 request_rec* r = doc->r;
1709 s_hdml_tag_output_upper_half(hdml, tag);
1711 /*--------------------------------------------------------------------------*/
1712 /* get name and value attribute */
1713 /*--------------------------------------------------------------------------*/
1714 nm = qs_get_name_attr (doc, tag, r);
1715 val = qs_get_value_attr (doc, tag, r);
1717 /*--------------------------------------------------------------------------*/
1718 /* The same name is searched out from the list made beforehand. */
1719 /*--------------------------------------------------------------------------*/
1720 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1721 if (! hdml->radio_name_list[ii]) {
1723 DBG(r, "Oops... radio list is null");
1724 /*----------------------------------------------------------------------*/
1725 /* Processing is ended because it doesn't happen off the fly. */
1726 /*----------------------------------------------------------------------*/
1730 if (strcasecmp(hdml->radio_name_list[ii], nm) == 0)
1733 if (ii == MAX_RADIO_COUNT) {
1735 DBG(r,"Oops... The same name was not in the list. ");
1736 /*------------------------------------------------------------------------*/
1737 /* Processing is ended because it doesn't happen off the fly. */
1738 /*------------------------------------------------------------------------*/
1742 s_output_to_hdml_out(hdml,
1743 apr_psprintf(r->pool,
1745 "LABEL=\"\x93\xfc\x97\xcd\" "
1746 "DEST=#R%d VARS=\"VAL=%s\" "
1752 if (hdml->radio_out_cnt[ii] == 0) {
1753 s_output_to_hdml_card(hdml,
1754 apr_psprintf(r->pool,
1755 "<NODISPLAY NAME=R%d>\n",
1757 s_output_to_hdml_card(hdml,
1758 apr_psprintf(r->pool,
1760 "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1763 kk = hdml->radio_out_cnt[ii];
1764 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
1765 if (! hdml->radio_value_list[ii][jj])
1770 for (jj=0; jj<r_cnt; jj++) {
1771 if (! hdml->radio_value_list[ii][jj])
1775 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1776 if (hdml->radio_out_cnt[ii] == 0)
1777 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1780 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1781 if (hdml->radio_out_cnt[ii] == 0) {
1783 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1785 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1792 s_output_to_hdml_out(hdml,
1793 apr_psprintf(r->pool, "\" >$%s_%02d</A>",
1795 hdml->radio_out_cnt[ii]));
1796 if (! hdml->radio_out_cnt[ii]) {
1797 s_output_to_hdml_card(hdml, "\">\n" );
1798 s_output_to_hdml_card(hdml, "</NODISPLAY>\n");
1800 s_output_to_postdata(hdml, apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1802 for (jj=0; jj<r_cnt; jj++) {
1803 if (hdml->radio_value_list[ii][jj] && hdml->radio_checked_value[ii]) {
1804 if (strcasecmp(hdml->radio_value_list[ii][jj],
1805 hdml->radio_checked_value[ii]) == 0) {
1806 s_output_to_init_vars(hdml,
1807 apr_psprintf(r->pool,
1813 s_output_to_init_vars(hdml,
1814 apr_psprintf(r->pool,
1821 s_output_to_init_vars(hdml,
1822 apr_psprintf(r->pool,
1829 if (hdml->radio_checked_value[ii]) {
1830 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
1831 "radio button is checked. checked value is [%s]",
1832 hdml->radio_checked_value[ii]);
1833 s_output_to_init_vars(hdml,
1834 apr_psprintf(r->pool,
1837 hdml->radio_checked_value[ii]));
1840 DBG(r,"radio button is not checked. checked value is []");
1841 s_output_to_init_vars(hdml,
1842 apr_psprintf(r->pool,
1847 hdml->radio_out_cnt[ii]++;
1851 * The substitution processing of tag "input type = checkbox" is done.
1853 * @param hdml [i/o] The pointer to the HDML structure at the output
1854 * destination is specified.
1855 * @param tag [i] The tag node of input type=checkbox is specified.
1858 s_hdml_do_input_checkbox_tag(hdml_t* hdml, Node* tag)
1860 Doc* doc = hdml->doc;
1861 request_rec* r = doc->r;
1866 /*--------------------------------------------------------------------------*/
1867 /* It is posted to the one without the checked attribute. */
1868 /* However, they were able to be removed with INPUT FILTER. */
1869 /*--------------------------------------------------------------------------*/
1870 if (! hdml->has_checkbox) {
1871 hdml->has_checkbox++;
1872 s_output_to_hdml_card(hdml,
1873 "<NODISPLAY NAME=\"_chk\">\n"
1874 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1875 "RETVALS=\"_uchk;$V;X\" >\n"
1877 "<NODISPLAY NAME=\"_uchk\">\n"
1878 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1879 "RETVALS=\"_chk;;_\" >\n"
1884 /*--------------------------------------------------------------------------*/
1885 /* It is examined whether it is CHECKED. */
1886 /*--------------------------------------------------------------------------*/
1887 chk = qs_is_checked_checkbox_attr(doc, tag, r);
1889 /*--------------------------------------------------------------------------*/
1890 /* The value of the name attribute and the value attribute is acquired */
1892 /*--------------------------------------------------------------------------*/
1893 val = qs_get_value_attr(doc, tag, r);
1894 nm = qs_get_name_attr(doc, tag, r);
1897 val = qs_alloc_zero_byte_string(r);
1900 nm = qs_alloc_zero_byte_string(r);
1902 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
1903 "<A TASK=GOSUB LABEL=\"a\xaf\xb8\" "
1904 "DEST=\"#$%s%02d\" "
1906 "RECEIVE=\"%s%02d;%s%02d;%s%02d\">"
1908 s_get_form_no(r, hdml),
1909 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1911 s_get_form_no(r, hdml),
1912 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1913 s_get_form_no(r, hdml),
1914 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1915 s_get_form_no(r, hdml),
1916 hdml->var_cnt[hdml->pure_form_cnt] + 2,
1917 s_get_form_no(r, hdml),
1918 hdml->var_cnt[hdml->pure_form_cnt] + 2));
1920 s_output_to_init_vars(hdml,
1921 apr_psprintf(r->pool,
1922 "%s%02d=_uchk&%s%02d=%s&%s%02d=X",
1923 s_get_form_no(r, hdml),
1924 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1925 s_get_form_no(r, hdml),
1926 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1927 ap_escape_uri(r->pool,val),
1928 s_get_form_no(r, hdml),
1929 hdml->var_cnt[hdml->pure_form_cnt] + 2
1933 s_output_to_init_vars(hdml,
1934 apr_psprintf(r->pool,
1935 "%s%02d=_chk&%s%02d=&%s%02d=_",
1936 s_get_form_no(r, hdml),
1937 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1938 s_get_form_no(r, hdml),
1939 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1940 s_get_form_no(r, hdml),
1941 hdml->var_cnt[hdml->pure_form_cnt] + 2
1945 s_output_to_postdata(hdml,
1946 apr_psprintf(r->pool, "%s%s=$%s%02d",
1949 s_get_form_no(r, hdml),
1950 hdml->var_cnt[hdml->pure_form_cnt] + 1));
1952 hdml->var_cnt[hdml->pure_form_cnt] += 3;
1956 * The ISTYLE attribute is converted into the HDML form.
1958 * @param r [i] To use POOL, the pointer to request_rec is specified.
1959 * @param is [i] The value of the ISTYLE attribute is specified.
1960 * @return The ISTYLE attribute converted into the HDML form is returned.
1963 qs_conv_istyle_to_format(request_rec* r, char* is)
1972 fmt = apr_psprintf(r->pool, "M");
1975 fmt = apr_psprintf(r->pool, "M");
1978 fmt = apr_psprintf(r->pool, "m");
1981 fmt = apr_psprintf(r->pool, "N");
1991 * It is a handler who processes the INPUT tag.
1993 * @param hdml [i/o] The pointer to the HDML structure at the output
1994 * destination is specified.
1995 * @param node [i] The INPUT tag node is specified.
1996 * @return The conversion result is returned.
1999 s_hdml_end_input_tag(hdml_t* hdml, Node* child)
2005 * It is a handler who processes the CENTER tag.
2007 * @param hdml [i/o] The pointer to the HDML structure at the output
2008 * destination is specified.
2009 * @param node [i] The CENTER tag node is specified.
2010 * @return The conversion result is returned.
2013 s_hdml_start_center_tag(hdml_t* hdml, Node* node)
2018 if (hdml->hdml_br_flag == 0)
2019 hdml = s_output_to_hdml_out(hdml, "<BR>\n");
2021 hdml = s_output_to_hdml_out(hdml, "<CENTER>");
2027 * It is a handler who processes the CENTER tag.
2029 * @param hdml [i/o] The pointer to the HDML structure at the output
2030 * destination is specified.
2031 * @param node [i] The CENTER tag node is specified.
2032 * @return The conversion result is returned.
2035 s_hdml_end_center_tag(hdml_t* hdml, Node* child)
2038 hdml->in_center = 0;
2040 hdml = s_output_to_hdml_out(hdml, "<BR>\n");
2041 hdml->hdml_br_flag = 1;
2047 * It is a handler who processes the HR tag.
2049 * @param hdml [i/o] The pointer to the HDML structure at the output
2050 * destination is specified.
2051 * @param node [i] The HR tag node is specified.
2052 * @return The conversion result is returned.
2055 s_hdml_start_hr_tag(hdml_t* hdml, Node* node)
2057 if (hdml->hdml_br_flag == 0) {
2058 s_output_to_hdml_out(hdml, "<BR>\n");
2059 if (hdml->in_center)
2062 if (hdml->div_in_center)
2063 hdml->div_in_center--;
2066 s_output_to_hdml_out(hdml, "<CENTER>\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c<BR>\n");
2068 hdml->hdml_br_flag = 1;
2074 * It is a handler who processes the HR tag.
2076 * @param hdml [i/o] The pointer to the HDML structure at the output
2077 * destination is specified.
2078 * @param node [i] The HR tag node is specified.
2079 * @return The conversion result is returned.
2082 s_hdml_end_hr_tag(hdml_t* hdml, Node* child)
2088 * It is a handler who processes the LI tag.
2090 * @param hdml [i/o] The pointer to the HDML structure at the output
2091 * destination is specified.
2092 * @param node [i] The LI tag node is specified.
2093 * @return The conversion result is returned.
2096 s_hdml_start_li_tag(hdml_t* hdml, Node* node)
2098 if (hdml->hdml_br_flag == 0) {
2099 s_output_to_hdml_out(hdml, "<BR>\n");
2100 if (hdml->in_center)
2103 if (hdml->div_in_center)
2104 hdml->div_in_center--;
2107 hdml->hdml_br_flag = 1;
2113 * It is a handler who processes the LI tag.
2115 * @param hdml [i/o] The pointer to the HDML structure at the output
2116 * destination is specified.
2117 * @param node [i] The LI tag node is specified.
2118 * @return The conversion result is returned.
2121 s_hdml_end_li_tag(hdml_t* hdml, Node* child)
2123 if (hdml->hdml_br_flag == 0) {
2124 s_output_to_hdml_out(hdml, "<BR>\n");
2125 if (hdml->in_center)
2128 if (hdml->div_in_center)
2129 hdml->div_in_center--;
2132 hdml->hdml_br_flag = 1;
2137 * It is a handler who processes the IMG tag.
2139 * @param hdml [i/o] The pointer to the HDML structure at the output
2140 * destination is specified.
2141 * @param node [i] The IMG tag node is specified.
2142 * @return The conversion result is returned.
2145 s_hdml_start_img_tag(hdml_t* hdml, Node* node)
2147 Doc* doc = hdml->doc;
2148 #ifndef IMG_NOT_CONVERT_FILENAME
2149 device_table_t* spec = hdml->spec;
2153 s_hdml_tag_output_upper_half(hdml, node);
2155 s_output_to_hdml_out(hdml, "<img");
2157 /* Get Attributes */
2158 for (attr = qs_get_attr(doc,node);
2160 attr = qs_get_next_attr(doc,attr)) {
2162 char* name = qs_get_attr_name(doc,attr);
2163 char* value = qs_get_attr_value(doc,attr);
2165 if ((*name == 's' || *name == 'S') && strcasecmp(name, "src") == 0) {
2166 s_output_to_hdml_out(hdml, " src=\"");
2167 #ifdef IMG_NOT_CONVERT_FILENAME
2168 s_output_to_hdml_out(hdml, value );
2170 s_output_to_hdml_out(hdml, chxj_img_conv(doc->r, spec,value));
2172 s_output_to_hdml_out(hdml, "\"" );
2175 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align" ) == 0) {
2176 s_output_to_hdml_out(hdml, " align=\"" );
2177 s_output_to_hdml_out(hdml, value );
2178 s_output_to_hdml_out(hdml, "\"" );
2181 if ((*name == 'w' || *name == 'W') && strcasecmp(name, "width" ) == 0) {
2182 s_output_to_hdml_out(hdml, " width=\"");
2183 s_output_to_hdml_out(hdml, value );
2184 s_output_to_hdml_out(hdml, "\"" );
2187 if ((*name == 'h' || *name == 'H') && strcasecmp(name, "height") == 0) {
2188 s_output_to_hdml_out(hdml, " height=\"");
2189 s_output_to_hdml_out(hdml, value );
2190 s_output_to_hdml_out(hdml, "\"" );
2193 if ((*name == 'h' || *name == 'H') && strcasecmp(name, "hspace") == 0) {
2194 s_output_to_hdml_out(hdml, " hspace=\"");
2195 s_output_to_hdml_out(hdml, value );
2196 s_output_to_hdml_out(hdml, "\"" );
2199 if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vspace") == 0) {
2200 s_output_to_hdml_out(hdml, " vspace=\"");
2201 s_output_to_hdml_out(hdml, value );
2202 s_output_to_hdml_out(hdml, "\"" );
2205 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alt" ) == 0) {
2206 s_output_to_hdml_out(hdml, " alt=\"" );
2207 s_output_to_hdml_out(hdml, value );
2208 s_output_to_hdml_out(hdml, "\"" );
2211 s_output_to_hdml_out(hdml, ">" );
2217 * It is a handler who processes the IMG tag.
2219 * @param hdml [i/o] The pointer to the HDML structure at the output
2220 * destination is specified.
2221 * @param node [i] The IMG tag node is specified.
2222 * @return The conversion result is returned.
2225 s_hdml_end_img_tag(hdml_t* hdml, Node* child)
2231 * It is a handler who processes the SELECT tag.
2233 * @param hdml [i/o] The pointer to the HDML structure at the output
2234 * destination is specified.
2235 * @param node [i] The SELECT tag node is specified.
2236 * @return The conversion result is returned.
2239 s_hdml_start_select_tag(hdml_t* hdml, Node* node)
2241 Doc* doc = hdml->doc;
2242 request_rec* r = doc->r;
2245 s_hdml_tag_output_upper_half(hdml, node);
2249 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2250 "<A TASK=GOSUB LABEL=\x91\x49\x91\xf0 "
2251 "VARS=\"V=$%s%02d\" DEST=#D%d "
2252 "RECEIVE=\"%s%02d;%s%02d\">"
2254 s_get_form_no(r, hdml),
2255 hdml->var_cnt[hdml->pure_form_cnt]+0,
2257 s_get_form_no(r, hdml),
2258 hdml->var_cnt[hdml->pure_form_cnt]+0,
2259 s_get_form_no(r, hdml),
2260 hdml->var_cnt[hdml->pure_form_cnt]+1,
2261 s_get_form_no(r, hdml),
2262 hdml->var_cnt[hdml->pure_form_cnt]+1));
2264 s_output_to_hdml_card(hdml,
2265 apr_psprintf(r->pool,
2266 "<CHOICE KEY=V NAME=D%d ", hdml->card_cnt));
2267 s_output_to_hdml_card(hdml,
2268 apr_psprintf(r->pool,
2269 "DEFAULT=$V METHOD=ALPHA MARKABLE=FALSE>\n"));
2270 /*--------------------------------------------------------------------------*/
2271 /* Get Attributes */
2272 /*--------------------------------------------------------------------------*/
2273 for (attr = qs_get_attr(doc,node);
2275 attr=qs_get_next_attr(doc,attr)) {
2277 char* name = qs_get_attr_name(doc,attr);
2278 char* value = qs_get_attr_value(doc,attr);
2279 char* selval = NULL;
2280 char* selvaltxt = NULL;
2282 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
2284 s_output_to_postdata(hdml,
2285 apr_psprintf(r->pool, "%s=$%s%02d",
2287 s_get_form_no(r, hdml),
2288 hdml->var_cnt[hdml->pure_form_cnt]));
2289 selval = qs_get_selected_value(doc, node, r);
2291 DBG(r, "selected value not found");
2292 selval = qs_alloc_zero_byte_string(r);
2295 DBG1(r, "selected value found[%s]" , selval);
2297 selvaltxt = qs_get_selected_value_text(doc, node, r);
2299 selvaltxt = qs_alloc_zero_byte_string(r);
2301 DBG1(r, "selvaltxt:[%s]" ,selvaltxt);
2303 s_output_to_init_vars(hdml,
2304 apr_psprintf(r->pool,
2305 "%s%02d=%s&%s%02d=%s",
2306 s_get_form_no(r, hdml),
2307 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2309 s_get_form_no(r, hdml),
2310 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2313 hdml->var_cnt[hdml->pure_form_cnt] += 2;
2322 * It is a handler who processes the SELECT tag.
2324 * @param hdml [i/o] The pointer to the HDML structure at the output
2325 * destination is specified.
2326 * @param node [i] The SELECT tag node is specified.
2327 * @return The conversion result is returned.
2330 s_hdml_end_select_tag(hdml_t* hdml, Node* node)
2332 s_output_to_hdml_card(hdml, "</CHOICE>\n");
2338 * It is a handler who processes the OPTION tag.
2340 * @param hdml [i/o] The pointer to the HDML structure at the output
2341 * destination is specified.
2342 * @param node [i] The OPTION tag node is specified.
2343 * @return The conversion result is returned.
2346 s_hdml_start_option_tag(hdml_t* hdml, Node* node)
2348 request_rec* r = hdml->doc->r;
2349 Doc* doc = hdml->doc;
2356 hdml->option_flag = 1;
2357 val = qs_get_value_attr(doc, node, r);
2359 /*--------------------------------------------------------------------------*/
2360 /* The child node of the object tag node acquires the value in assumption */
2361 /* that is the TEXT node. */
2362 /*--------------------------------------------------------------------------*/
2363 child = qs_get_child_node(doc, node);
2365 txtval = apr_palloc(r->pool, 1);
2369 txtval = qs_get_node_value(doc, child);
2371 DBG1(r, "txtval:[%s]" , txtval);
2373 if (val && txtval) {
2374 s_output_to_hdml_card(hdml,
2375 apr_psprintf(r->pool,
2376 "<CE TASK=RETURN VALUE=\"%s\" "
2377 "RETVALS=\"$V;%s\">%s</CE>\n",
2379 qs_trim_string(r,txtval),
2380 qs_trim_string(r,txtval)));
2387 * It is a handler who processes the OPTION tag.
2389 * @param hdml [i/o] The pointer to the HDML structure at the output
2390 * destination is specified.
2391 * @param node [i] The OPTION tag node is specified.
2392 * @return The conversion result is returned.
2395 s_hdml_end_option_tag(hdml_t* hdml, Node* node)
2397 hdml->option_flag = 0;
2402 * It is a handler who processes the DIV tag.
2404 * @param hdml [i/o] The pointer to the HDML structure at the output
2405 * destination is specified.
2406 * @param node [i] The DIV tag node is specified.
2407 * @return The conversion result is returned.
2410 s_hdml_start_div_tag(hdml_t* hdml, Node* node)
2412 Doc* doc = hdml->doc;
2415 /*--------------------------------------------------------------------------*/
2416 /* If the br tag is not output immediately before the div tag appears, the */
2417 /* br tag is output. */
2418 /*--------------------------------------------------------------------------*/
2419 if (hdml->hdml_br_flag == 0) {
2420 hdml->hdml_br_flag = 1;
2421 s_output_to_hdml_out(hdml, "<BR>\n");
2424 /*--------------------------------------------------------------------------*/
2425 /* The object tag node is scanned. */
2426 /*--------------------------------------------------------------------------*/
2427 for (attr = qs_get_attr(doc,node);
2429 attr = qs_get_next_attr(doc,attr)) {
2430 char* name = qs_get_attr_name(doc,attr);
2431 char* value = qs_get_attr_value(doc,attr);
2433 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align") == 0) {
2434 if ((*value == 'r' || *value == 'R') && strcasecmp(value, "right") == 0) {
2435 hdml->div_right_flag = 1;
2436 s_output_to_hdml_out(hdml, "<RIGHT>");
2437 hdml->hdml_br_flag = 0;
2441 if ((*value == 'c' || *value == 'C') && strcasecmp(value, "center") == 0) {
2442 hdml->div_center_flag = 1;
2443 s_output_to_hdml_out(hdml, "<CENTER>");
2444 hdml->hdml_br_flag = 0;
2454 * It is a handler who processes the DIV tag.
2456 * @param hdml [i/o] The pointer to the HDML structure at the output
2457 * destination is specified.
2458 * @param node [i] The DIV tag node is specified.
2459 * @return The conversion result is returned.
2462 s_hdml_end_div_tag(hdml_t* hdml, Node* node)
2464 request_rec* r = hdml->doc->r;
2467 if (hdml->div_right_flag == 1) {
2468 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\n"));
2469 hdml->div_right_flag = 0;
2471 if (hdml->div_center_flag == 1) {
2472 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\n"));
2473 hdml->div_center_flag = 0;
2474 hdml->div_in_center = 0;
2481 * It is a wrapper of the apr_pstrcat function.
2483 * @param r [i] To use POOL, the pointer to request_rec is specified.
2484 * @param o [i] The character string of connected origin is specified.
2485 * @param s [i] The character string connected with 'o' parameter is
2487 * @param len [i/o] The pointer to the area where the character string
2488 * length is stored is specified.
2489 * @return The character string after it connects it is returned.
2492 qs_out_apr_pstrcat(request_rec* r, char* o, char* s, int* len)
2494 *len = (strlen(s) + *len);
2495 return apr_pstrcat(r->pool, o, s, NULL);
2499 * The prepositive character string used to generate the variable for HDML is
2502 * @param r [i] To use POOL, the pointer to request_rec is specified.
2503 * @param hdml [i] The pointer to the HDML structure that maintains the seed
2504 * to generate it is specified.
2505 * @return The character string after it generates it is returned.
2508 s_get_form_no(request_rec* r, hdml_t* hdml)
2512 unsigned long fc = hdml->form_cnt;
2514 apr_time_exp_tz(&tm, hdml->form_cnt, 0);
2516 result = apr_psprintf(r->pool, "%c",(int)('A' + ((fc / 100) % 26)));
2517 result = apr_pstrcat(r->pool, result,
2518 apr_psprintf(r->pool, "%02d%02d%02d",
2526 * The number of tag nodes .."Input type =' radio '".. is counted.
2528 * @param hdml [i] The pointer to the HDML structure is specified.
2529 * @param node [i] The first parents node that counts the radio tag node is
2533 s_hdml_count_radio_tag(hdml_t* hdml, Node* node)
2536 Doc* doc = hdml->doc;
2537 request_rec* r = doc->r;
2539 /*--------------------------------------------------------------------------*/
2540 /* All the child nodes of the specified node are scanned. */
2541 /*--------------------------------------------------------------------------*/
2542 for (child = qs_get_child_node(doc,node);
2544 child = qs_get_next_node(doc,child)) {
2554 name = qs_get_node_name(doc,child);
2555 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "input") != 0) {
2556 s_hdml_count_radio_tag(hdml, child);
2560 DBG(r,"found input tag");
2562 type = qs_get_type_attr(doc, child, r);
2564 ERR(r, "Oops! The input tag without the type attribute has been found.Please give a type.");
2567 if ((*type == 'r' || *type == 'R') && strcasecmp(type, "radio") != 0)
2570 DBG(r, "found type=radio");
2572 rname = qs_get_name_attr (doc, child, r);
2573 rvalue = qs_get_value_attr(doc, child, r);
2576 /*----------------------------------------------------------------------*/
2577 /* Oops!. The input tag without the name attribute has been found. */
2578 /*----------------------------------------------------------------------*/
2579 DBG(r, "Oops!. The input tag without the name attribute has been found. Please give a name.");
2583 DBG(r, "found name attribute");
2585 /*------------------------------------------------------------------------*/
2586 /* It scans in radio_name_list. When the same value exists, the */
2587 /* value is overwrited. */
2588 /* The value is written in a new area when not is. */
2589 /*------------------------------------------------------------------------*/
2590 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
2591 if (! hdml->radio_name_list[ii]) {
2592 DBG1(r, "new name:[%s]", rname);
2595 if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2596 DBG1(r, "already registered name:[%s]", rname);
2600 if (ii == MAX_RADIO_COUNT) {
2601 DBG(r, apr_psprintf(r->pool,
2602 "I do not understand the name of the radiobutton "
2603 "of %d piece or more. Please decrease "
2604 "the number of radiobuttons.",
2609 DBG1(r,"add radio name:[%s]" ,rname);
2611 hdml->radio_name_list[ii] = apr_pstrdup(r->pool, rname);
2613 /*------------------------------------------------------------------------*/
2614 /* It adds it to radio_value_list. */
2615 /*------------------------------------------------------------------------*/
2616 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) {
2617 if (!hdml->radio_value_list[ii][jj])
2620 if (jj == MAX_RADIO_VALUE_COUNT) {
2621 DBG(r, apr_psprintf(r->pool,
2622 "I do not understand the value of the radiobutton "
2623 "of %d piece or more. Please decrease "
2624 "the number of radiobuttons.",
2625 MAX_RADIO_VALUE_COUNT));
2628 hdml->radio_value_list[ii][jj] = apr_pstrdup(r->pool, rvalue);
2630 /*------------------------------------------------------------------------*/
2631 /* Now let's be the checked attribute or scan. */
2632 /*------------------------------------------------------------------------*/
2633 chkd = qs_get_checked_attr(hdml->doc, child, hdml->doc->r);
2635 DBG(r,apr_psprintf(r->pool,
2636 "The tag scanned now had the checked "
2637 "attribute. The value is [%s].",
2639 hdml->radio_checked_value[ii] = apr_pstrdup(r->pool, rvalue);
2646 * The character string is added, and output to the out member of the HDML
2649 * @param hdml [i/o] The pointer to the HDML structure that maintains the out
2650 * member at the output destination is specified.
2651 * @param s [i] The character string that should be output is specified.
2652 * @return The pointer to the HDML structure after it processes it is returned.
2655 s_output_to_hdml_out(hdml_t* hdml, char* s)
2657 hdml->out = qs_out_apr_pstrcat(hdml->doc->r, hdml->out, s, &hdml->out_len);
2664 * The character string is added, and output to the card member of the HDML
2667 * @param hdml [i/o] The pointer to the HDML structure that maintains the
2668 * card member at the output destination is specified.
2669 * @param s [i] The character string that should be output is specified.
2670 * @return The pointer to the HDML structure after it processes it is returned.
2673 s_output_to_hdml_card(hdml_t* hdml, char* s)
2675 hdml->card = qs_out_apr_pstrcat(hdml->doc->r, hdml->card, s, &hdml->card_len);
2683 * The data for the post is added, and output.
2685 * @param hdml [i/o] The pointer to the HDML structure at the output
2686 * destination is specified.
2687 * @param s [i] The character string that wants to output to postdata is
2691 s_output_to_postdata(hdml_t* hdml, char* s)
2693 request_rec* r = hdml->doc->r;
2695 if (strlen(hdml->postdata[hdml->pure_form_cnt]))
2696 hdml->postdata[hdml->pure_form_cnt] =
2697 apr_pstrcat(r->pool,
2698 hdml->postdata[hdml->pure_form_cnt],
2702 hdml->postdata[hdml->pure_form_cnt] =
2703 apr_pstrcat(r->pool,
2704 hdml->postdata[hdml->pure_form_cnt],
2705 qs_trim_string(r, s),
2708 DBG1(r, "POSTDATA:[%s]", hdml->postdata[hdml->pure_form_cnt] );
2712 * The tag output upper half.
2714 * @param hdml [i/o] The pointer to the HDML structure at the output
2715 * destination is specified.
2716 * @param node [i] The A tag node is specified.
2719 s_hdml_tag_output_upper_half(hdml_t* hdml, Node* node)
2721 if (hdml->hdml_br_flag == 1
2722 && hdml->div_right_flag == 1) {
2723 s_output_to_hdml_out(hdml, "<RIGHT>");
2724 hdml->hdml_br_flag = 0;
2727 if (hdml->hdml_br_flag == 1
2729 && hdml->in_center == 0) {
2730 s_output_to_hdml_out(hdml, "<CENTER>");
2732 hdml->hdml_br_flag = 0;
2735 if (hdml->hdml_br_flag == 1
2736 && hdml->div_center_flag > 0
2737 && hdml->div_in_center == 0) {
2738 s_output_to_hdml_out(hdml, "<CENTER>");
2739 hdml->div_in_center++;
2740 hdml->hdml_br_flag = 0;
2745 * The data for the init_vars is added, and output.
2747 * @param hdml [i/o] The pointer to the HDML structure at the output
2748 * destination is specified.
2749 * @param s [i] The character string that wants to output to postdata is
2753 s_output_to_init_vars(hdml_t* hdml, char* s)
2755 request_rec* r = hdml->doc->r;
2757 if (strlen(hdml->init_vars))
2758 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, "&", NULL);
2760 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, qs_trim_string(r,s), NULL);
2761 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
2767 s_hdml_chxjif_tag(hdml_t* hdml, Node* node)
2769 Doc* doc = hdml->doc;
2772 for (child = qs_get_child_node(doc, node);
2774 child = qs_get_next_node(doc, child)) {
2775 s_output_to_hdml_out(hdml, child->otext);
2776 s_hdml_chxjif_tag(hdml, child);