From: Michael Gebetsroither <[EMAIL PROTECTED]> Date: Wed, 2 Nov 2005 03:24:46 +0100 Subject: Bug#336986: Sorry forgot the patch :( To: [EMAIL PROTECTED] Content-Type: multipart/mixed; boundary="mR8QP4gmHujQHb1c" User-Agent: mutt-ng devel-r316 (Debian)
Hi, sorry, i've forgotten to attach the patch[0]. [0]: http://einsteinmg.dyndns.org/projects/libdialog_output_function.patch thx&&cu Michael Gebetsroither -- /*The only secure computer is one that's unplugged, locked in a safe, and buried 20 feet under the ground in a secret location... and i'm not even too sure about that one.*/
diff -aurp dialog-1.0-20051005.orig/dialog.h dialog-1.0-20051005/dialog.h --- dialog-1.0-20051005.orig/dialog.h 2004-12-20 01:01:11.000000000 +0100 +++ dialog-1.0-20051005/dialog.h 2005-11-01 21:11:52.307556000 +0100 @@ -413,6 +413,7 @@ typedef struct { int sleep_secs; /* option "--sleep secs" */ int timeout_secs; /* option "--timeout secs" */ unsigned input_length; /* nonzero if input_result is allocated */ + void (*add_result_f)(char*); /*function pointer called from dlg_add_result if !NULL */ } DIALOG_VARS; #define USE_ITEM_HELP(s) (dialog_vars.item_help && (s) != 0) diff -aurp dialog-1.0-20051005.orig/util.c dialog-1.0-20051005/util.c --- dialog-1.0-20051005.orig/util.c 2005-10-06 01:55:38.000000000 +0200 +++ dialog-1.0-20051005/util.c 2005-11-01 21:05:18.770961500 +0100 @@ -1525,24 +1525,31 @@ dlg_set_focus(WINDOW *parent, WINDOW *wi void dlg_add_result(char *string) { + /* If there is a functionpointer, DONT TOUCH ANYTHING IN THIS FUNCTION!! + * Call the functionpointer with the string and return */ + if(dialog_vars.add_result_f != NULL) { + dialog_vars.add_result_f(string); + return; + } + unsigned have = strlen(dialog_vars.input_result); unsigned want = strlen(string) + have; if (want >= MAX_LEN) { - if (dialog_vars.input_length == 0) { - char *save = dialog_vars.input_result; - dialog_vars.input_length = want * 2; - dialog_vars.input_result = malloc(dialog_vars.input_length); - assert_ptr(dialog_vars.input_result, "dlg_add_result malloc"); - dialog_vars.input_result[0] = 0; - if (save != 0) - strcpy(dialog_vars.input_result, save); - } else if (want >= dialog_vars.input_length) { - dialog_vars.input_length = want * 2; - dialog_vars.input_result = realloc(dialog_vars.input_result, - dialog_vars.input_length); - assert_ptr(dialog_vars.input_result, "dlg_add_result realloc"); - } + if (dialog_vars.input_length == 0) { + char *save = dialog_vars.input_result; + dialog_vars.input_length = want * 2; + dialog_vars.input_result = malloc(dialog_vars.input_length); + assert_ptr(dialog_vars.input_result, "dlg_add_result malloc"); + dialog_vars.input_result[0] = 0; + if (save != 0) + strcpy(dialog_vars.input_result, save); + } else if (want >= dialog_vars.input_length) { + dialog_vars.input_length = want * 2; + dialog_vars.input_result = realloc(dialog_vars.input_result, + dialog_vars.input_length); + assert_ptr(dialog_vars.input_result, "dlg_add_result realloc"); + } } strcat(dialog_vars.input_result, string); }