"required": [ "type", "frequency" ]
},
- "matcher" : {
+ "filter" : {
"type" : "object",
"properties": {
"exe" : { "type" :"string" },
"properties": {
"type" : { "const": "PROCESS" },
"frequency" : { "type" : "integer" },
- "matchers" : {
+ "filters" : {
"type" : ["array"],
"items": {
- "$ref": "#/definitions/matcher"
+ "$ref": "#/definitions/filter"
}
}
},
{
configs[index].scope = PROCESS;
- configs[index].data.process = config_parse_process_data(json_object_get_array_member(entry, SCHEMA_REQUEST_DATA_MATCHERS));
+ configs[index].data.process = config_parse_process_data(json_object_get_array_member(entry, SCHEMA_REQUEST_DATA_FILTERS));
}
else if (g_strcmp0(type, SCHEMA_TYPE_LOAD_AVG) == 0)
{
return NULL;
}
-static void _process_foreach_matcher(JsonArray *array, guint index,
+static void _process_foreach_filter(JsonArray *array, guint index,
JsonNode *node, gpointer user_data)
{
config_data_process_t *ret = user_data;
- struct matcher match;
+ struct filter filter;
JsonObject *elem = json_node_get_object(node);
if (!elem) return;
const char *appid = json_object_safe_get_string_member(elem, SCHEMA_RESULT_APP_ID);
const char *exe = json_object_safe_get_string_member(elem, SCHEMA_RESULT_EXE);
- match.app_id = appid ? strdup(appid) : NULL;
- match.exe = exe ? strdup(exe) : NULL;
+ filter.app_id = appid ? strdup(appid) : NULL;
+ filter.exe = exe ? strdup(exe) : NULL;
- ret->matchers[ret->n_matchers++] = match;
+ ret->filters[ret->n_filters++] = filter;
}
static config_data_process_t config_parse_process_data(JsonArray *array)
int len = json_array_get_length(array);
if (len == 0) return ret;
- ret.matchers = calloc(len, sizeof(struct matcher));
- ret.n_matchers = 0;
+ ret.filters = calloc(len, sizeof(struct filter));
+ ret.n_filters = 0;
- json_array_foreach_element(array, _process_foreach_matcher, &ret);
+ json_array_foreach_element(array, _process_foreach_filter, &ret);
return ret;
}
for (int i=0; i < len; ++i) {
switch (configs[i].scope) {
case PROCESS:
- free(configs[i].data.process.matchers);
+ free(configs[i].data.process.filters);
break;
default:
break;
{
config_data_process_t *data = user_data;
- for (int i = 0; i < data->n_matchers; ++i) {
- struct matcher *match = &data->matchers[i];
- if (match->app_id && process_get_appid(proc)) {
- if (strcmp(match->app_id, process_get_appid(proc)) == 0)
+ if (data->n_filters == 0) {
+ return true;
+ }
+
+ for (int i = 0; i < data->n_filters; ++i) {
+ struct filter *filter = &data->filters[i];
+ if (filter->app_id && process_get_appid(proc)) {
+ if (strcmp(filter->app_id, process_get_appid(proc)) == 0)
return true;
}
- if (match->exe && process_get_exe(proc)) {
- if (strcmp(match->exe, process_get_exe(proc)) == 0)
+ if (filter->exe && process_get_exe(proc)) {
+ if (strcmp(filter->exe, process_get_exe(proc)) == 0)
return true;
}
}