From: Ian Jackson Date: Sat, 21 Sep 2019 15:40:15 +0000 (+0100) Subject: util: priomsg: Provide and use priomsg_update_fixed X-Git-Tag: v0.5.0~3 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=715f70157516497e5f1f3237fc1d35efe94debc8;p=secnet.git util: priomsg: Provide and use priomsg_update_fixed We are going to want to reuse this. No functional change. Signed-off-by: Ian Jackson --- diff --git a/site.c b/site.c index 8ca8769..57ccb1d 100644 --- a/site.c +++ b/site.c @@ -2084,9 +2084,8 @@ static bool_t site_incoming(void *sst, struct buffer_if *buf, return True; } - if (priomsg_update_p(whynot, comm_notify_whynot_general)) - truncmsg_add_string(&whynot->m, - "not MSG1 or PROD; unknown dest index"); + priomsg_update_fixed(whynot, comm_notify_whynot_general, + "not MSG1 or PROD; unknown dest index"); return False; } diff --git a/util.c b/util.c index e6f0141..977e131 100644 --- a/util.c +++ b/util.c @@ -427,6 +427,11 @@ const char *priomsg_getmessage(const struct priomsg *pm, const char *defmsg) return defmsg; } +bool_t priomsg_update_fixed(struct priomsg *pm, int prio, const char *m) { + if (!priomsg_update_p(pm, prio)) return False; + truncmsg_add_string(&pm->m, m); + return True; +} void buffer_new(struct buffer_if *buf, int32_t len) { diff --git a/util.h b/util.h index eddb06d..a2ef828 100644 --- a/util.h +++ b/util.h @@ -81,6 +81,9 @@ const char *priomsg_getmessage(const struct priomsg *pm, const char *defmsg); /* return value is null-terminated, valid until next call * or until defmsg is no longer valid ZM */ +bool_t priomsg_update_fixed(struct priomsg *pm, int prio, const char *m); + /* convenience combination of _update_p and truncmsg_add_string */ + /* * void BUF_ADD_BYTES(append, struct buffer_if*, const void*, int32_t size); * void BUF_ADD_BYTES(prepend, struct buffer_if*, const void*, int32_t size);