Skip to content
Snippets Groups Projects
Commit 4da2cb5a authored by Andreas Gattringer's avatar Andreas Gattringer
Browse files

refactoring: added libbdc/bdc_cross_platform

parent dbe37f9c
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,8 @@ else ()
MESSAGE("Unknown compiler: ${CMAKE_C_COMPILER_ID}")
endif ()
add_subdirectory(bdc_cross_platform)
add_subdirectory(bdc_memory)
add_library(bdc STATIC "")
......
add_library(bdc_cross_platform STATIC)
target_sources(bdc_cross_platform
PRIVATE
bdc_cross_platform.c
PUBLIC
bdc_cross_platform.h)
set_property(TARGET bdc_cross_platform PROPERTY POSITION_INDEPENDENT_CODE ON)
\ No newline at end of file
// SPDX-License-Identifier: GPL-3.0-or-later
//
// bdc_cross_platform.c
//
// Copyright (C) 2011-2024, University of Vienna and Vienna Institute for Nature Conservation & Analyses, Andreas Gattringer.
//
// 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 3 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.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
// bdc_cross_platform.h
//
// Copyright (C) 2011-2024, University of Vienna and Vienna Institute for Nature Conservation & Analyses, Andreas Gattringer.
//
// 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 3 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 BDC_WINDOWS_H
#define BDC_WINDOWS_H
#ifdef WIN32
#define BDC_ON_WINDOWS
#endif
#if defined(__MINGW64__) || defined(__MINGW32__)
#define __USE_MINGW_ANSI_STDIO 1
#endif
#ifdef BDC_ON_WINDOWS
#define strncasecmp strnicmp
#define strcasecmp stricmp
#define strtok_r strtok_s
#define access _access
#define F_OK 0
#include <string.h>
#include <bdc_memory/bdc_memory.h>
static inline char *strndup(const char *s, size_t n)
{
char *end_pointer = memchr(s, '\0', n);
if (end_pointer != NULL) {
n = end_pointer - s;
}
char *result = malloc_or_die(n + 1);
memcpy(result, s, n);
result[n] = '\0';
return result;
}
#endif
#endif //BDC_WINDOWS_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment