aboutsummaryrefslogtreecommitdiffstats
path: root/tap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-04-23 08:20:06 +0000
committerGuy Harris <guy@alum.mit.edu>2003-04-23 08:20:06 +0000
commit1b872b3648180aa042e36dd5b3ff38a03fa131e3 (patch)
tree04f0fba9423fc1a57c5f559ee0a5fc49138ddb6e /tap.c
parent81ebec370d30901623ef24b2112e91f8004c6ad0 (diff)
Make "register_tap_listener()" return NULL on success and a "GString *"
referring to a GString containing an error message on failure, and don't have it print anything on failure. If it fails, have its Tethereal-tap callers print an error message before exiting, and have its Ethereal callers pop up a dialog box with the error (except in cases where the failure is guaranteed not to be the user's fault, and where we exit, in which case we just print an error message before we exit). In all cases, the error message includes the text of the GString. Fix a scanf format string in the DCE RPC statistics Ethereal tap, so that it properly skips the comma before the filter string. Fix some Ethereal error messages not to say "tethereal". svn path=/trunk/; revision=7542
Diffstat (limited to 'tap.c')
-rw-r--r--tap.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/tap.c b/tap.c
index 0a0b24b998..044956bb07 100644
--- a/tap.c
+++ b/tap.c
@@ -1,7 +1,7 @@
/* tap.c
* packet tap interface 2002 Ronnie Sahlberg
*
- * $Id: tap.c,v 1.8 2002/11/28 20:28:28 guy Exp $
+ * $Id: tap.c,v 1.9 2003/04/23 08:20:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -335,29 +335,35 @@ find_tap_id(char *name)
/* this function attaches the tap_listener to the named tap.
* function returns :
- * 0: ok.
- * !0: error
-*/
-int
+ * NULL: ok.
+ * non-NULL: error, return value points to GString containing error
+ * message.
+ */
+GString *
register_tap_listener(char *tapname, void *tapdata, char *fstring, tap_reset_cb reset, tap_packet_cb packet, tap_draw_cb draw)
{
tap_listener_t *tl;
int tap_id;
+ GString *error_string;
tap_id=find_tap_id(tapname);
if(!tap_id){
- fprintf(stderr, "tap not found\n");
- exit(10);
+ error_string = g_string_new("");
+ g_string_sprintf(error_string, "Tap %s not found", tapname);
+ return error_string;
}
tl=g_malloc(sizeof(tap_listener_t));
tl->code=NULL;
tl->needs_redraw=1;
if(fstring){
- if(!dfilter_compile(fstring ,&tl->code)){
+ if(!dfilter_compile(fstring, &tl->code)){
+ error_string = g_string_new("");
+ g_string_sprintf(error_string,
+ "Filter \"%s\" is invalid - %s",
+ fstring, dfilter_error_msg);
g_free(tl);
- fprintf(stderr,"register_tap_listener(): %s\n", dfilter_error_msg);
- return 1;
+ return error_string;
} else {
num_tap_filters++;
}
@@ -372,7 +378,7 @@ register_tap_listener(char *tapname, void *tapdata, char *fstring, tap_reset_cb
tap_listener_queue=tl;
- return 0;
+ return NULL;
}
/* this function removes a tap listener