-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
140 changed files
with
2,351 additions
and
1,329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
|
||
/* | ||
compat.h -- compatibility defines. | ||
Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner | ||
Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner | ||
This file is part of libzip, a library to manipulate ZIP archives. | ||
The authors can be contacted at <[email protected]> | ||
The authors can be contacted at <[email protected]> | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
|
@@ -41,6 +41,9 @@ | |
/* to have *_MAX definitions for all types when compiling with g++ */ | ||
#define __STDC_LIMIT_MACROS | ||
|
||
/* to have ISO C secure library functions */ | ||
#define __STDC_WANT_LIB_EXT1__ 1 | ||
|
||
#ifdef _WIN32 | ||
#ifndef ZIP_EXTERN | ||
#ifndef ZIP_STATIC | ||
|
@@ -94,9 +97,12 @@ typedef char bool; | |
#if !defined(HAVE_FILENO) && defined(HAVE__FILENO) | ||
#define fileno _fileno | ||
#endif | ||
#if defined(HAVE__SNPRINTF) | ||
#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF) | ||
#define snprintf _snprintf | ||
#endif | ||
#if !defined(HAVE__SNWPRINTF_S) | ||
#define _snwprintf_s(buf, bufsz, len, fmt, ...) (_snwprintf((buf), (len), (fmt), __VA_ARGS__)) | ||
#endif | ||
#if defined(HAVE__STRDUP) | ||
#if !defined(HAVE_STRDUP) || defined(_WIN32) | ||
#undef strdup | ||
|
@@ -125,6 +131,33 @@ typedef char bool; | |
#define ftello(s) ((long)ftell((s))) | ||
#endif | ||
|
||
#ifdef HAVE_LOCALTIME_S | ||
#ifdef _WIN32 | ||
/* Windows is incompatible to the C11 standard, hurray! */ | ||
#define zip_localtime(t, tm) (localtime_s((tm), (t)) == 0 ? tm : NULL) | ||
#else | ||
#define zip_localtime localtime_s | ||
#endif | ||
#else | ||
#ifdef HAVE_LOCALTIME_R | ||
#define zip_localtime localtime_r | ||
#else | ||
#define zip_localtime(t, tm) (localtime(t)) | ||
#endif | ||
#endif | ||
|
||
#ifndef HAVE_MEMCPY_S | ||
#define memcpy_s(dest, destsz, src, count) (memcpy((dest), (src), (count)) == NULL) | ||
#endif | ||
|
||
#ifndef HAVE_SNPRINTF_S | ||
#ifdef HAVE__SNPRINTF_S | ||
#define snprintf_s(buf, bufsz, fmt, ...) (_snprintf_s((buf), (bufsz), (bufsz), (fmt), __VA_ARGS__)) | ||
#else | ||
#define snprintf_s snprintf | ||
#endif | ||
#endif | ||
|
||
#if !defined(HAVE_STRCASECMP) | ||
#if defined(HAVE__STRICMP) | ||
#define strcasecmp _stricmp | ||
|
@@ -133,6 +166,19 @@ typedef char bool; | |
#endif | ||
#endif | ||
|
||
#ifndef HAVE_STRNCPY_S | ||
#define strncpy_s(dest, destsz, src, count) (strncpy((dest), (src), (count)), 0) | ||
#endif | ||
|
||
#ifndef HAVE_STRERROR_S | ||
#define strerrorlen_s(errnum) (strlen(strerror(errnum))) | ||
#define strerror_s(buf, bufsz, errnum) ((void)strncpy_s((buf), (bufsz), strerror(errnum), (bufsz)), (buf)[(bufsz)-1] = '\0', strerrorlen_s(errnum) >= (bufsz)) | ||
#else | ||
#ifndef HAVE_STRERRORLEN_S | ||
#define strerrorlen_s(errnum) 8192 | ||
#endif | ||
#endif | ||
|
||
#if SIZEOF_OFF_T == 8 | ||
#define ZIP_OFF_MAX ZIP_INT64_MAX | ||
#define ZIP_OFF_MIN ZIP_INT64_MIN | ||
|
Oops, something went wrong.