implement RemoveMatch
This commit is contained in:
parent
b318fea528
commit
c397e37a05
1 changed files with 14 additions and 3 deletions
17
server.c
17
server.c
|
@ -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--;
|
||||
|
||||
_reply_begin("") {} _reply_end()
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue