int show_msg_user_input(const char * title, const char * msg, const char * defaultvalue, char ** value_ref) { String request_value = string_new(); String s_title = string_new(); String s_msg = string_new(); string_set_ascii(request_value, defaultvalue); string_set_ascii(s_title, title); string_set_ascii(s_msg, msg); String request_struct[] = {s_msg, request_value}; int len_out = -1; int no_error = _show_msgUserInput(0, request_struct, s_title->str, s_msg->str); string_free(s_title); string_free(s_msg); if (!(no_error && request_value->len > 0)) goto err; char *s = string_to_ascii(request_value); if (!s) goto err; if (value_ref) { *value_ref = strdup(s); if (!*value_ref) goto err; } len_out = strlen(s); err: string_free(request_value); return len_out; }
int show_msg_user_input(const char * title, const char * msg, char * defaultvalue, char ** value_ref) { String request_value = string_new(); String s_title = string_new(); String s_msg = string_new(); string_set_ascii(request_value, defaultvalue); string_set_ascii(s_title, title); string_set_ascii(s_msg, msg); String request_struct[] = {s_msg, request_value}; int no_error = _show_msgUserInput(0, request_struct, s_title->str, s_msg->str); unsigned len_out = (no_error) ? request_value->len : 0; string_free(s_title); string_free(s_msg); if(no_error && len_out > 0) { char * t = string_to_ascii(request_value); *value_ref = malloc(sizeof(char)*(len_out+1)); strncpy(*value_ref, t, len_out); (*value_ref)[len_out] = 0; string_free(request_value); return len_out; } else { string_free(request_value); return -1; } }