- *colonp = ':';
- return FALSE;
- }
- if (strcmp(autostoparg,"duration") == 0) {
- capture_opts->has_autostop_duration = TRUE;
- capture_opts->autostop_duration = get_positive_int(p,"autostop duration");
- } else if (strcmp(autostoparg,"filesize") == 0) {
- capture_opts->has_autostop_filesize = TRUE;
- capture_opts->autostop_filesize = get_positive_int(p,"autostop filesize");
- } else if (strcmp(autostoparg,"files") == 0) {
- capture_opts->multi_files_on = TRUE;
- capture_opts->has_autostop_files = TRUE;
- capture_opts->autostop_files = get_positive_int(p,"autostop files");
- } else {
- return FALSE;
- }
- *colonp = ':'; /* put the colon back */
- return TRUE;
+ while (g_ascii_isspace(*p))
+ p++;
+ if (*p == '\0') {
+ /*
+ * Put the colon back, so if our caller uses, in an
+ * error message, the string they passed us, the message
+ * looks correct.
+ */
+ *colonp = ':';
+ return FALSE;
+ }
+ if (strcmp(autostoparg,"duration") == 0) {
+ capture_opts->has_autostop_duration = TRUE;
+ capture_opts->autostop_duration = get_positive_int(p,"autostop duration");
+ } else if (strcmp(autostoparg,"filesize") == 0) {
+ capture_opts->has_autostop_filesize = TRUE;
+ capture_opts->autostop_filesize = get_positive_int(p,"autostop filesize");
+ } else if (strcmp(autostoparg,"files") == 0) {
+ capture_opts->multi_files_on = TRUE;
+ capture_opts->has_autostop_files = TRUE;
+ capture_opts->autostop_files = get_positive_int(p,"autostop files");
+ } else {
+ return FALSE;
+ }
+ *colonp = ':'; /* put the colon back */
+ return TRUE;
+}
+
+static gboolean get_filter_arguments(capture_options* capture_opts, const char* arg)
+{
+ char* colonp;
+ char* val;
+ char* filter_exp = NULL;
+
+ colonp = strchr(arg, ':');
+ if (colonp) {
+ val = colonp;
+ *val = '\0';
+ val++;
+ if (strcmp(arg, "predef") == 0) {
+ GList* filterItem;
+
+ filterItem = get_filter_list_first(CFILTER_LIST);
+ while (filterItem != NULL) {
+ filter_def *filterDef;
+
+ filterDef = (filter_def*)filterItem->data;
+ if (strcmp(val, filterDef->name) == 0) {
+ filter_exp = g_strdup(filterDef->strval);
+ break;
+ }
+ filterItem = filterItem->next;
+ }
+ }
+ }
+
+ if (filter_exp == NULL) {
+ /* No filter expression found yet; fallback to previous implemention
+ and assume the arg contains a filter expression */
+ if (colonp) {
+ *colonp = ':'; /* restore colon */
+ }
+ filter_exp = g_strdup(arg);
+ }
+
+ if (capture_opts->ifaces->len > 0) {
+ interface_options interface_opts;
+
+ interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
+ capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
+ g_free(interface_opts.cfilter);
+ interface_opts.cfilter = filter_exp;
+ g_array_append_val(capture_opts->ifaces, interface_opts);
+ return TRUE;
+ }
+ else {
+ g_free(capture_opts->default_options.cfilter);
+ capture_opts->default_options.cfilter = filter_exp;
+ return TRUE;
+ }