From 3abad6a6f9ae4cfa65c9f6d5f15208790449eefe Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 28 Mar 2011 19:24:22 +0200 Subject: utils: move OSMO_SNPRINT_RET() macro definition to osmocom/core/utils.h This is used by the logging to vty conversion functions by now, but it may be of help for other functions that plan to use snprintf(). --- include/osmocom/core/utils.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/osmocom/core/utils.h') diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 0cdf03b8..252228de 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -27,4 +27,13 @@ char *ubit_dump(const uint8_t *bits, unsigned int len); void osmo_str2lower(char *out, const char *in); void osmo_str2upper(char *out, const char *in); +#define OSMO_SNPRINTF_RET(ret, rem, offset, len) \ +do { \ + len += ret; \ + if (ret > rem) \ + ret = rem; \ + offset += ret; \ + rem -= ret; \ +} while (0) + #endif -- cgit v1.2.3