aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-03-28 19:24:22 +0200
committerHarald Welte <laforge@gnumonks.org>2011-03-28 20:00:45 +0200
commit3abad6a6f9ae4cfa65c9f6d5f15208790449eefe (patch)
tree32b141a3bf38a3b89589d767c795bd2d7837b59e /include
parent70004fcc6dcd5dd979c10143872b2a136371e371 (diff)
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().
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/core/utils.h9
1 files changed, 9 insertions, 0 deletions
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