CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/ext/libzip/compat.h
Views: 1401
#ifndef _HAD_LIBZIP_COMPAT_H1#define _HAD_LIBZIP_COMPAT_H23/*4compat.h -- compatibility defines.5Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner67This file is part of libzip, a library to manipulate ZIP archives.8The authors can be contacted at <[email protected]>910Redistribution and use in source and binary forms, with or without11modification, are permitted provided that the following conditions12are met:131. Redistributions of source code must retain the above copyright14notice, this list of conditions and the following disclaimer.152. Redistributions in binary form must reproduce the above copyright16notice, this list of conditions and the following disclaimer in17the documentation and/or other materials provided with the18distribution.193. The names of the authors may not be used to endorse or promote20products derived from this software without specific prior21written permission.2223THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS24OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED25WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE26ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY27DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL28DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS30INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER31IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR32OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN33IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.34*/3536#include "zipconf.h"3738#include "config.h"3940/* to have *_MAX definitions for all types when compiling with g++ */41#define __STDC_LIMIT_MACROS4243#ifdef _WIN3244#ifndef ZIP_EXTERN45#ifndef ZIP_STATIC46#define ZIP_EXTERN __declspec(dllexport)47#endif48#endif49/* for dup(), close(), etc. */50#include <io.h>51#endif5253#ifdef HAVE_STDBOOL_H54#include <stdbool.h>55#else56typedef char bool;57#define true 158#define false 059#endif6061#include <errno.h>6263/* at least MinGW does not provide EOPNOTSUPP, see64* http://sourceforge.net/p/mingw/bugs/263/65*/66#ifndef EOPNOTSUPP67#define EOPNOTSUPP EINVAL68#endif6970/* at least MinGW does not provide EOVERFLOW, see71* http://sourceforge.net/p/mingw/bugs/242/72*/73#ifndef EOVERFLOW74#define EOVERFLOW EFBIG75#endif7677/* not supported on at least Windows */78#ifndef O_CLOEXEC79#define O_CLOEXEC 080#endif8182#ifdef _WIN3283#if defined(HAVE__CLOSE)84#define close _close85#endif86#if defined(HAVE__DUP)87#define dup _dup88#endif89/* crashes reported when using fdopen instead of _fdopen on Windows/Visual Studio 10/Win64 */90#if defined(HAVE__FDOPEN)91#define fdopen _fdopen92#endif93#if !defined(HAVE_FILENO) && defined(HAVE__FILENO)94#define fileno _fileno95#endif96#if defined(HAVE__SNPRINTF)97#define snprintf _snprintf98#endif99#if defined(HAVE__STRDUP)100#if !defined(HAVE_STRDUP) || defined(_WIN32)101#undef strdup102#define strdup _strdup103#endif104#endif105#if !defined(HAVE__SETMODE) && defined(HAVE_SETMODE)106#define _setmode setmode107#endif108#if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64)109#define strtoll _strtoi64110#endif111#if !defined(HAVE_STRTOULL) && defined(HAVE__STRTOUI64)112#define strtoull _strtoui64113#endif114#if defined(HAVE__UNLINK)115#define unlink _unlink116#endif117#endif118119#ifndef HAVE_FSEEKO120#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))121#endif122123#ifndef HAVE_FTELLO124#define ftello(s) ((long)ftell((s)))125#endif126127#if !defined(HAVE_STRCASECMP)128#if defined(HAVE__STRICMP)129#define strcasecmp _stricmp130#elif defined(HAVE_STRICMP)131#define strcasecmp stricmp132#endif133#endif134135#if SIZEOF_OFF_T == 8136#define ZIP_OFF_MAX ZIP_INT64_MAX137#define ZIP_OFF_MIN ZIP_INT64_MIN138#elif SIZEOF_OFF_T == 4139#define ZIP_OFF_MAX ZIP_INT32_MAX140#define ZIP_OFF_MIN ZIP_INT32_MIN141#elif SIZEOF_OFF_T == 2142#define ZIP_OFF_MAX ZIP_INT16_MAX143#define ZIP_OFF_MIN ZIP_INT16_MIN144#else145#error unsupported size of off_t146#endif147148#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)149#define ZIP_FSEEK_MAX ZIP_OFF_MAX150#define ZIP_FSEEK_MIN ZIP_OFF_MIN151#else152#include <limits.h>153#define ZIP_FSEEK_MAX LONG_MAX154#define ZIP_FSEEK_MIN LONG_MIN155#endif156157#ifndef SIZE_MAX158#if SIZEOF_SIZE_T == 8159#define SIZE_MAX ZIP_INT64_MAX160#elif SIZEOF_SIZE_T == 4161#define SIZE_MAX ZIP_INT32_MAX162#elif SIZEOF_SIZE_T == 2163#define SIZE_MAX ZIP_INT16_MAX164#else165#error unsupported size of size_t166#endif167#endif168169#ifndef PRId64170#ifdef _MSC_VER171#define PRId64 "I64d"172#else173#define PRId64 "lld"174#endif175#endif176177#ifndef PRIu64178#ifdef _MSC_VER179#define PRIu64 "I64u"180#else181#define PRIu64 "llu"182#endif183#endif184185#ifndef S_ISDIR186#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)187#endif188189#ifndef S_ISREG190#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)191#endif192193#endif /* compat.h */194195196