commit eff5e4e8400b014d16790889aa601331ecf4c7b3 from: Omar Polo date: Fri Aug 06 20:00:51 2021 UTC move imsg_{event_add,compose_event} to utils commit - 58329cc131f17ea4e2c26b17fe8584888123e8d2 commit + eff5e4e8400b014d16790889aa601331ecf4c7b3 blob - c9cf6f660ed02d4ce9bdf11d80c47688a9f721a7 blob + 00d783d670eb4180e7577b988ab00b6e486cea71 --- kamid.c +++ kamid.c @@ -550,34 +550,9 @@ start_child(enum kd_process p, int fd, int debug, int /* really? */ execvp(saved_argv0, (char *const *)argv); fatal("execvp"); -} - -void -imsg_event_add(struct imsgev *iev) -{ - iev->events = EV_READ; - if (iev->ibuf.w.queued) - iev->events |= EV_WRITE; - - event_del(&iev->ev); - event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev); - event_add(&iev->ev, NULL); } int -imsg_compose_event(struct imsgev *iev, uint16_t type, uint32_t peerid, - pid_t pid, int fd, const void *data, uint16_t datalen) -{ - int ret; - - if ((ret = imsg_compose(&iev->ibuf, type, peerid, pid, fd, data, - datalen) != -1)) - imsg_event_add(iev); - - return ret; -} - -int main_imsg_compose_listener(int type, int fd, uint32_t peerid, const void *data, uint16_t datalen) { blob - a06374de892d37e7ac1f6e68abfe20c93c4e4473 blob + 20e493776432b52f9d71a48023a3602d0464d402 --- kamid.h +++ kamid.h @@ -209,9 +209,6 @@ enum { extern int verbose; int main_imsg_compose_listener(int, int, uint32_t, const void *, uint16_t); void merge_config(struct kd_conf *, struct kd_conf *); -void imsg_event_add(struct imsgev *); -int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, - int, const void *, uint16_t); struct kd_conf *config_new_empty(void); void config_clear(struct kd_conf *); blob - 85aa93ab18963a7747b411498011918c13d61f33 blob + 066fdb3d2905942ccc7328d712194ff6a03fc1a8 --- utils.c +++ utils.c @@ -157,3 +157,28 @@ hexdump(const char *label, uint8_t *data, size_t len) printf("\n"); } + +void +imsg_event_add(struct imsgev *iev) +{ + iev->events = EV_READ; + if (iev->ibuf.w.queued) + iev->events |= EV_WRITE; + + event_del(&iev->ev); + event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev); + event_add(&iev->ev, NULL); +} + +int +imsg_compose_event(struct imsgev *iev, uint16_t type, uint32_t peerid, + pid_t pid, int fd, const void *data, uint16_t datalen) +{ + int ret; + + if ((ret = imsg_compose(&iev->ibuf, type, peerid, pid, fd, data, + datalen) != -1)) + imsg_event_add(iev); + + return ret; +} blob - 5d1db0ca9655d142dd36c66b40d518738daa838c blob + 78cf40028b8b5683ce038ac20a23e0920073697f --- utils.h +++ utils.h @@ -19,6 +19,8 @@ #include "compat.h" +struct imsgev; + void *xmalloc(size_t); void *xcalloc(size_t, size_t); char *xstrdup(const char *); @@ -28,4 +30,8 @@ const char *pp_msg_type(uint8_t); void hexdump(const char *, uint8_t *data, size_t len); +void imsg_event_add(struct imsgev *); +int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, + int, const void *, uint16_t); + #endif