mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-30 12:04:07 +00:00
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
This commit is contained in:
parent
4f0ec4797a
commit
9925a680a9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=219815
@ -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>
|
||||
@ -45,6 +48,27 @@ __FBSDID("$FreeBSD$");
|
||||
#include "hast.h"
|
||||
#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)
|
||||
{
|
||||
|
@ -45,6 +45,9 @@
|
||||
errno = _rerrno; \
|
||||
} while (0)
|
||||
|
||||
int vsnprlcat(char *str, size_t size, const char *fmt, va_list ap);
|
||||
int snprlcat(char *str, size_t size, const char *fmt, ...);
|
||||
|
||||
int provinfo(struct hast_resource *res, bool dowrite);
|
||||
const char *role2str(int role);
|
||||
int drop_privs(void);
|
||||
|
Loading…
Reference in New Issue
Block a user