mirror of https://github.com/Cisco-Talos/clamav
parent
ed026d3677
commit
db1cae229c
@ -0,0 +1,55 @@ |
||||
/*
|
||||
* Copyright (C) 2004 Bastian Kleineidam <calvin@debian.org> |
||||
* |
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
|
||||
#if HAVE_CONFIG_H |
||||
#include "clamav-config.h" |
||||
#endif |
||||
|
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
|
||||
#if !defined(HAVE_STRLCPY) |
||||
size_t strlcpy(char *dst, const char *src, size_t size) |
||||
{ |
||||
size_t ret = strlen(src); |
||||
|
||||
if (size) { |
||||
size_t len = (ret >= size) ? size-1 : ret; |
||||
memcpy(dst, src, len); |
||||
dst[len] = '\0'; |
||||
} |
||||
|
||||
return ret; |
||||
} |
||||
#endif |
||||
|
||||
#if !defined(HAVE_STRLCAT) |
||||
size_t strlcat(char *dst, const char *src, size_t size) |
||||
{ |
||||
size_t dst_len = strlen(dst); |
||||
size_t src_len = strlen(src); |
||||
|
||||
if (size) { |
||||
size_t len = (src_len >= size-dst_len) ? (size-dst_len-1) : src_len; |
||||
memcpy(&dst[dst_len], src, len); |
||||
dst[dst_len + len] = '\0'; |
||||
} |
||||
|
||||
return dst_len + src_len; |
||||
} |
||||
#endif |
||||
@ -0,0 +1,37 @@ |
||||
/*
|
||||
* Copyright (C) 2004 Bastian Kleineidam <calvin@debian.org> |
||||
* |
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
|
||||
#ifndef __STRUTIL_H |
||||
#define __STRUTIL_H |
||||
|
||||
#if HAVE_CONFIG_H |
||||
#include "clamav-config.h" |
||||
#endif |
||||
|
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
|
||||
#if !defined(HAVE_STRLCPY) |
||||
size_t strlcpy(char *dst, const char *src, size_t size); |
||||
#endif |
||||
|
||||
#if !defined(HAVE_STRLCAT) |
||||
size_t strlcat(char *dst, const char *src, size_t size); |
||||
#endif |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue