diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-11-21 17:14:54 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-11-21 17:14:54 +0000 |
commit | d415d3d87cd112d26b6508d377be30f3b1d9771c (patch) | |
tree | 44355aa9144fb53b62a4748d10dc34bb39adb67a /capture_opts.c | |
parent | 03f4fa5223c5bfe90d79bcf94f34ffd2d87d78d2 (diff) | |
download | wireshark-d415d3d87cd112d26b6508d377be30f3b1d9771c.tar.gz wireshark-d415d3d87cd112d26b6508d377be30f3b1d9771c.tar.bz2 wireshark-d415d3d87cd112d26b6508d377be30f3b1d9771c.zip |
On error, have capture_opts_trim_iface() return the exit status that
should be used (on success, have it return 0). Exit with that exit
status; if the problem is that we couldn't get the interface list or if
there are no interfaces in that list, return 2, as that's not a
command-line syntax error.
svn path=/trunk/; revision=46108
Diffstat (limited to 'capture_opts.c')
-rw-r--r-- | capture_opts.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/capture_opts.c b/capture_opts.c index 76fe857efc..939a6437f5 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -446,7 +446,10 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str gchar *err_str; interface_options interface_opts; - /* retrieve the interface list to compare the option specfied against */ + /* + * Retrieve the interface list against which to compare the specified + * option. + */ if_list = capture_interface_list(&err, &err_str); if (if_list == NULL) { switch (err) { @@ -461,10 +464,9 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str cmdarg_err("There are no interfaces on which a capture can be done"); break; } - return 1; + return 2; } - /* * If the argument is a number, treat it as an index into the list * of adapters, as printed by "tshark -D". @@ -905,33 +907,27 @@ void capture_opts_trim_ring_num_files(capture_options *capture_opts) } -gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device) +int +capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device) { int status; /* Did the user specify an interface to use? */ if (capture_opts->num_selected != 0 || capture_opts->ifaces->len != 0) { - /* yes they did, exit immediately nothing further to do here */ - return TRUE; + /* yes they did, return immediately - nothing further to do here */ + return 0; } /* No - is a default specified in the preferences file? */ if (capture_device != NULL) { /* Yes - use it. */ status = capture_opts_add_iface_opt(capture_opts, capture_device); - if (status == 0) - return TRUE; /* interface found */ - return FALSE; /* some kind of error finding interface */ + return status; } /* No default in preferences file, just pick the first interface from the list of interfaces. */ - status = capture_opts_add_iface_opt(capture_opts, "1"); - if (status == 0) - return TRUE; /* success */ - return FALSE; /* some kind of error finding the first interface */ + return capture_opts_add_iface_opt(capture_opts, "1"); } - - #ifndef S_IFIFO #define S_IFIFO _S_IFIFO #endif |