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().
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 0cdf03b..252228d 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -27,4 +27,13 @@
 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