Get rid of nk/copy_cmdarg.h

This commit is contained in:
Nicholas J. Kain 2022-02-25 07:01:55 -05:00
parent 12631c59bb
commit 9cd65f35d9
4 changed files with 545 additions and 551 deletions

1067
cfg.c

File diff suppressed because it is too large Load Diff

9
cfg.rl
View File

@ -15,9 +15,16 @@
#include "sockd.h" #include "sockd.h"
#include "nk/log.h" #include "nk/log.h"
#include "nk/privs.h" #include "nk/privs.h"
#include "nk/copy_cmdarg.h"
#include "nk/io.h" #include "nk/io.h"
static void copy_cmdarg(char *dest, const char *src,
size_t destlen, const char *argname)
{
ssize_t olen = snprintf(dest, destlen, "%s", src);
if (olen < 0 || (size_t)olen > destlen)
suicide("snprintf failed on %s", argname);
}
struct cfgparse { struct cfgparse {
char buf[MAX_BUF]; char buf[MAX_BUF];
size_t buflen; size_t buflen;

1
ndhc.c
View File

@ -24,7 +24,6 @@
#include "nk/log.h" #include "nk/log.h"
#include "nk/privs.h" #include "nk/privs.h"
#include "nk/io.h" #include "nk/io.h"
#include "nk/copy_cmdarg.h"
#include "ndhc.h" #include "ndhc.h"
#include "ndhc-defines.h" #include "ndhc-defines.h"

View File

@ -1,19 +0,0 @@
// Copyright 2015 Nicholas J. Kain <njkain at gmail dot com>
// SPDX-License-Identifier: MIT
#ifndef NCMLIB_COPY_CMDARG_H_
#define NCMLIB_COPY_CMDARG_H_
#include <stdio.h>
#include <stdlib.h>
#include "nk/log.h"
static inline void copy_cmdarg(char *dest, const char *src,
size_t destlen, const char *argname)
{
ssize_t olen = snprintf(dest, destlen, "%s", src);
if (olen < 0 || (size_t)olen > destlen)
suicide("snprintf failed on %s", argname);
}
#endif