implement RemoveMatch

This commit is contained in:
hippoz 2023-01-16 16:24:08 +02:00
parent b318fea528
commit c397e37a05
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

@ -551,11 +551,22 @@ int handle_add_match(bus_t *s, int i, wire_message_t *msg, wire_context_t *ctx,
}
int handle_remove_match(bus_t *s, int i, wire_message_t *msg, wire_context_t *ctx, wire_context_t *reply_ctx) {
TRYPTR(wire_get_string_check(ctx, 1, MATCH_RULE_MAX));
char *match = TRYPTR(wire_get_string_check(ctx, 1, MATCH_RULE_MAX));
STUB("handle_remove_match", "does nothing and returns success");
bus_client_t *client = &s->clients[i];
int left = client->match_count;
for (int j = 0; j < BUS_MAX_MATCH && left > 0; j++) {
left--;
if (client->matches[j] && strcmp(client->matches[j]->rule_string, match) == 0) {
match_rule_free(client->matches[j]);
client->matches[j] = NULL;
_reply_begin("") {} _reply_end()
break;
}
}
_reply_error("xyz.hippoz.jitterbug.MatchRuleNotFound");
return 0;
}