Files
kospm/include/kospm_string.h
T
keXa f76f191d62 Another commit of another iteration.
Another milestone: school project submission. Library doesn't work yet, though. Also licensing things, I guess
2025-04-19 03:33:07 +03:00

45 lines
1.2 KiB
C

/*
* kospm_string.h
*
* Copyright 2025 keXa <nikitospikalov2008@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
#ifndef KOSPM_STRING
#define KOSPM_STRING
#include <stdlib.h>
#include <string.h>
#define NAME_MAX 32
#define VERSION_MAX 16
#define DESC_MAX 256
#define FILE_MAX 4096
static inline char* strcpynew(const char *src, size_t n) {
char *dst = malloc(n + 1);
if (dst) {
strncpy(dst, src, n);
dst[n] = '\0';
}
return dst;
}
#endif