Factor out copy_cmdarg() to common ncmlib header.

This commit is contained in:
Nicholas J. Kain 2014-03-20 05:25:40 -04:00
parent f365498188
commit a73a28588f

View File

@ -70,6 +70,7 @@
#include "seccomp.h"
#include "ifchd.h"
#include "duiaid.h"
#include "copy_cmdarg.h"
struct client_state_t cs = {
.ifchWorking = 0,
@ -418,19 +419,6 @@ void background(void)
write_pid(pidfile);
}
static void copy_cmdarg(char *dest, char *src, size_t destlen, char *argname)
{
ssize_t olen = snprintf(dest, destlen, "%s", src);
if (olen < 0) {
log_error("snprintf failed on %s; your system is broken?", argname);
exit(EXIT_FAILURE);
}
if ((size_t)olen >= destlen) {
log_error("snprintf would truncate %s arg; it's too long", argname);
exit(EXIT_FAILURE);
}
}
int main(int argc, char **argv)
{
static const struct option arg_options[] = {