Commit 14e89689d1464c09da42cb912f7c67d6c5139348
1 parent
12b3b7bc
Exists in
master
and in
5 other branches
Delimitando buffer com <form> </form> quando forem gerados campos input para fac…
…ilitar o tratamento pelo javascript android
Showing
2 changed files
with
20 additions
and
1 deletions
Show diff stats
src/lib3270/html.c
@@ -99,6 +99,7 @@ | @@ -99,6 +99,7 @@ | ||
99 | struct html_info | 99 | struct html_info |
100 | { | 100 | { |
101 | int szText; | 101 | int szText; |
102 | + int form; | ||
102 | 103 | ||
103 | enum mode | 104 | enum mode |
104 | { | 105 | { |
@@ -182,6 +183,8 @@ | @@ -182,6 +183,8 @@ | ||
182 | { | 183 | { |
183 | char name[30]; | 184 | char name[30]; |
184 | 185 | ||
186 | + info->form = 1; | ||
187 | + | ||
185 | snprintf(name,29,"F%04d",addr); | 188 | snprintf(name,29,"F%04d",addr); |
186 | 189 | ||
187 | append_string(info,"<input type=\""); | 190 | append_string(info,"<input type=\""); |
@@ -388,9 +391,25 @@ | @@ -388,9 +391,25 @@ | ||
388 | if(info.fg != 0xFF) | 391 | if(info.fg != 0xFF) |
389 | append_string(&info,element_text[HTML_ELEMENT_END_COLOR]); | 392 | append_string(&info,element_text[HTML_ELEMENT_END_COLOR]); |
390 | 393 | ||
394 | + | ||
391 | if(option & LIB3270_HTML_OPTION_HEADERS) | 395 | if(option & LIB3270_HTML_OPTION_HEADERS) |
392 | append_element(&info,HTML_ELEMENT_FOOTER); | 396 | append_element(&info,HTML_ELEMENT_FOOTER); |
393 | 397 | ||
398 | + if(info.form) | ||
399 | + { | ||
400 | + static const char * prefix = "<form name=\"" PACKAGE_NAME "\">"; | ||
401 | + static const char * suffix = "</form>"; | ||
402 | + char *text = info.text; | ||
403 | + | ||
404 | + info.text = lib3270_malloc(strlen(prefix)+strlen(suffix)+strlen(text)+4); | ||
405 | + | ||
406 | + strcpy(info.text,prefix); | ||
407 | + strcat(info.text,text); | ||
408 | + strcat(info.text,suffix); | ||
409 | + | ||
410 | + lib3270_free(text); | ||
411 | + } | ||
412 | + | ||
394 | return lib3270_realloc(info.text,strlen(info.text)+2); | 413 | return lib3270_realloc(info.text,strlen(info.text)+2); |
395 | } | 414 | } |
396 | 415 |
src/lib3270/util.c
@@ -179,7 +179,7 @@ char * lib3270_vsprintf(const char *fmt, va_list args) | @@ -179,7 +179,7 @@ char * lib3270_vsprintf(const char *fmt, va_list args) | ||
179 | char buf[16384]; | 179 | char buf[16384]; |
180 | int nc; | 180 | int nc; |
181 | 181 | ||
182 | - nc = vsprintf(buf, fmt, args); | 182 | + nc = vsnprintf(buf, sizeof(buf), fmt, args); |
183 | if (nc > sizeof(buf)) | 183 | if (nc > sizeof(buf)) |
184 | Error(NULL,"Internal buffer overflow"); | 184 | Error(NULL,"Internal buffer overflow"); |
185 | r = lib3270_malloc(nc + 1); | 185 | r = lib3270_malloc(nc + 1); |