summaryrefslogtreecommitdiffstats
path: root/sbin/hastd/subr.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-03-21 08:36:50 +0000
committerpjd <pjd@FreeBSD.org>2011-03-21 08:36:50 +0000
commit895e0371a1b3bfa3af33880e3c4eb133ec226102 (patch)
treeada90647abce88182f6aecb563dfef439c64f23a /sbin/hastd/subr.c
parent5b7b8f48e306ee5dc231b9cd7efa85ee92200864 (diff)
downloadFreeBSD-src-895e0371a1b3bfa3af33880e3c4eb133ec226102.zip
FreeBSD-src-895e0371a1b3bfa3af33880e3c4eb133ec226102.tar.gz
Add snprlcat() and vsnprlcat() - the functions I'm always missing.
They work as a combination of snprintf(3) and strlcat(3) - the caller can append a string build based on the given format. MFC after: 1 week
Diffstat (limited to 'sbin/hastd/subr.c')
-rw-r--r--sbin/hastd/subr.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sbin/hastd/subr.c b/sbin/hastd/subr.c
index 24d6dd5..213dcd2 100644
--- a/sbin/hastd/subr.c
+++ b/sbin/hastd/subr.c
@@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
#include <unistd.h>
#include <pjdlog.h>
@@ -46,6 +49,27 @@ __FBSDID("$FreeBSD$");
#include "subr.h"
int
+vsnprlcat(char *str, size_t size, const char *fmt, va_list ap)
+{
+ size_t len;
+
+ len = strlen(str);
+ return (vsnprintf(str + len, size - len, fmt, ap));
+}
+
+int
+snprlcat(char *str, size_t size, const char *fmt, ...)
+{
+ va_list ap;
+ int result;
+
+ va_start(ap, fmt);
+ result = vsnprlcat(str, size, fmt, ap);
+ va_end(ap);
+ return (result);
+}
+
+int
provinfo(struct hast_resource *res, bool dowrite)
{
struct stat sb;
OpenPOWER on IntegriCloud