X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=ubusd_event.c;h=6d0ae3014d7e5ef69254d94ff6579e8a98fca308;hp=d12bcb8864ef27a90ddcb0335a5ec4a3129bb0f0;hb=ba607d976b77c40162637d354fd8e1560384a66d;hpb=74eddc472d8c647f21a475bbe780b4509636ae35 diff --git a/ubusd_event.c b/ubusd_event.c index d12bcb8..6d0ae30 100644 --- a/ubusd_event.c +++ b/ubusd_event.c @@ -1,3 +1,16 @@ +/* + * Copyright (C) 2011 Felix Fietkau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include #include "ubusd.h" @@ -121,7 +134,7 @@ static void ubusd_send_event_msg(struct ubus_msg_buf **ub, struct ubus_client *c ubus_msg_send(obj->client, *ub, false); } -bool strmatch_len(const char *s1, const char *s2, int *len) +static bool strmatch_len(const char *s1, const char *s2, int *len) { for (*len = 0; s1[*len] == s2[*len]; (*len)++) if (!s1[*len]) @@ -215,7 +228,7 @@ static int ubusd_forward_event(struct ubus_client *cl, struct blob_attr *msg) return ubusd_send_event(cl, id, ubusd_create_event_from_msg, data); } -static int ubusd_event_recv(struct ubus_client *cl, const char *method, struct blob_attr *msg) +static int ubusd_event_recv(struct ubus_client *cl, struct ubus_msg_buf *ub, const char *method, struct blob_attr *msg) { if (!strcmp(method, "register")) return ubusd_alloc_event_pattern(cl, msg); @@ -254,6 +267,7 @@ void ubusd_event_init(void) { ubus_init_string_tree(&patterns, true); event_obj = ubusd_create_object_internal(NULL, UBUS_SYSTEM_OBJECT_EVENT); - event_obj->recv_msg = ubusd_event_recv; + if (event_obj != NULL) + event_obj->recv_msg = ubusd_event_recv; }