2022-02-06 20:05:29 -05:00
|
|
|
// Copyright 2015 Nicholas J. Kain <njkain at gmail dot com>
|
|
|
|
// SPDX-License-Identifier: MIT
|
2020-10-20 06:44:31 -04:00
|
|
|
#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);
|
2022-02-25 06:11:16 -05:00
|
|
|
if (olen < 0 || (size_t)olen > destlen)
|
|
|
|
suicide("snprintf failed on %s", argname);
|
2020-10-20 06:44:31 -04:00
|
|
|
}
|
|
|
|
|
2022-02-06 20:05:29 -05:00
|
|
|
#endif
|
|
|
|
|