"Fossies" - the Fresh Open Source Software Archive

Member "src/Common/libzip/compat.h" (10 Oct 2018, 5025 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "compat.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.21_Source_vs_1.22_Source.

    1 #ifndef _HAD_LIBZIP_COMPAT_H
    2 #define _HAD_LIBZIP_COMPAT_H
    3 
    4 /*
    5   compat.h -- compatibility defines.
    6   Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
    7 
    8   This file is part of libzip, a library to manipulate ZIP archives.
    9   The authors can be contacted at <libzip@nih.at>
   10 
   11   Redistribution and use in source and binary forms, with or without
   12   modification, are permitted provided that the following conditions
   13   are met:
   14   1. Redistributions of source code must retain the above copyright
   15      notice, this list of conditions and the following disclaimer.
   16   2. Redistributions in binary form must reproduce the above copyright
   17      notice, this list of conditions and the following disclaimer in
   18      the documentation and/or other materials provided with the
   19      distribution.
   20   3. The names of the authors may not be used to endorse or promote
   21      products derived from this software without specific prior
   22      written permission.
   23 
   24   THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
   25   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   26   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
   28   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   30   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   31   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
   32   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
   33   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
   34   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   35 */
   36 
   37 #include "zipconf.h"
   38 
   39 #ifdef HAVE_CONFIG_H
   40 #include "config.h"
   41 #endif
   42 
   43 /* to have *_MAX definitions for all types when compiling with g++ */
   44 #define __STDC_LIMIT_MACROS
   45 
   46 #ifdef _WIN32
   47 #ifndef ZIP_EXTERN
   48 #ifndef ZIP_STATIC
   49 #define ZIP_EXTERN __declspec(dllexport)
   50 #else
   51 #define ZIP_EXTERN
   52 #endif
   53 #endif
   54 /* for dup(), close(), etc. */
   55 #include <io.h>
   56 #endif
   57 
   58 #ifdef HAVE_STDBOOL_H
   59 #include <stdbool.h>
   60 #else
   61 #ifndef __cplusplus
   62 typedef char bool;
   63 #define true 1
   64 #define false 0
   65 #endif
   66 #endif
   67 
   68 #include <errno.h>
   69 
   70 /* at least MinGW does not provide EOPNOTSUPP, see
   71  * http://sourceforge.net/p/mingw/bugs/263/
   72  */
   73 #ifndef EOPNOTSUPP
   74 #define EOPNOTSUPP EINVAL
   75 #endif
   76 
   77 /* at least MinGW does not provide EOVERFLOW, see
   78  * http://sourceforge.net/p/mingw/bugs/242/
   79  */
   80 #ifndef EOVERFLOW
   81 #define EOVERFLOW EFBIG
   82 #endif
   83 
   84 #ifdef _WIN32
   85 #if defined(HAVE__CHMOD)
   86 #define chmod _chmod
   87 #endif
   88 #if defined(HAVE__CLOSE)
   89 #define close _close
   90 #endif
   91 #if defined(HAVE__DUP)
   92 #define dup _dup
   93 #endif
   94 /* crashes reported when using fdopen instead of _fdopen on Windows/Visual Studio 10/Win64 */
   95 #if defined(HAVE__FDOPEN)
   96 #define fdopen _fdopen
   97 #endif
   98 #if !defined(HAVE_FILENO) && defined(HAVE__FILENO)
   99 #define fileno _fileno
  100 #endif
  101 /* Windows' open() doesn't understand Unix permissions */
  102 #if defined(HAVE__OPEN)
  103 #define open(a, b, c) _open((a), (b))
  104 #endif
  105 #if defined(HAVE__SNPRINTF)
  106 #define snprintf _snprintf
  107 #endif
  108 #if defined(HAVE__STRDUP)
  109 #if !defined(HAVE_STRDUP) || defined(_WIN32)
  110 #undef strdup
  111 #define strdup _strdup
  112 #endif
  113 #endif
  114 #if !defined(HAVE__SETMODE) && defined(HAVE_SETMODE)
  115 #define _setmode setmode
  116 #endif
  117 #if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64)
  118 #define strtoll _strtoi64
  119 #endif
  120 #if !defined(HAVE_STRTOULL) && defined(HAVE__STRTOUI64)
  121 #define strtoull _strtoui64
  122 #endif
  123 #if defined(HAVE__UMASK)
  124 #define umask _umask
  125 #endif
  126 #if defined(HAVE__UNLINK)
  127 #define unlink _unlink
  128 #endif
  129 #endif
  130 
  131 #ifndef HAVE_FSEEKO
  132 #define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
  133 #endif
  134 
  135 #ifndef HAVE_FTELLO
  136 #define ftello(s) ((long)ftell((s)))
  137 #endif
  138 
  139 #ifndef HAVE_MKSTEMP
  140 int _zip_mkstemp(char *);
  141 #define mkstemp _zip_mkstemp
  142 #endif
  143 
  144 #if !defined(HAVE_STRCASECMP)
  145 #if defined(HAVE__STRICMP)
  146 #define strcasecmp _stricmp
  147 #elif defined(HAVE_STRICMP)
  148 #define strcasecmp stricmp
  149 #endif
  150 #endif
  151 
  152 #if SIZEOF_OFF_T == 8
  153 #define ZIP_OFF_MAX ZIP_INT64_MAX
  154 #define ZIP_OFF_MIN ZIP_INT64_MIN
  155 #elif SIZEOF_OFF_T == 4
  156 #define ZIP_OFF_MAX ZIP_INT32_MAX
  157 #define ZIP_OFF_MIN ZIP_INT32_MIN
  158 #elif SIZEOF_OFF_T == 2
  159 #define ZIP_OFF_MAX ZIP_INT16_MAX
  160 #define ZIP_OFF_MIN ZIP_INT16_MIN
  161 #else
  162 #error unsupported size of off_t
  163 #endif
  164 
  165 #if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
  166 #define ZIP_FSEEK_MAX ZIP_OFF_MAX
  167 #define ZIP_FSEEK_MIN ZIP_OFF_MIN
  168 #else
  169 #include <limits.h>
  170 #define ZIP_FSEEK_MAX LONG_MAX
  171 #define ZIP_FSEEK_MIN LONG_MIN
  172 #endif
  173 
  174 #ifndef SIZE_MAX
  175 #if SIZEOF_SIZE_T == 8
  176 #define SIZE_MAX ZIP_INT64_MAX
  177 #elif SIZEOF_SIZE_T == 4
  178 #define SIZE_MAX ZIP_INT32_MAX
  179 #elif SIZEOF_SIZE_T == 2
  180 #define SIZE_MAX ZIP_INT16_MAX
  181 #else
  182 #error unsupported size of size_t
  183 #endif
  184 #endif
  185 
  186 #ifndef PRId64
  187 #ifdef _MSC_VER
  188 #define PRId64 "I64d"
  189 #else
  190 #define PRId64 "lld"
  191 #endif
  192 #endif
  193 
  194 #ifndef PRIu64
  195 #ifdef _MSC_VER
  196 #define PRIu64 "I64u"
  197 #else
  198 #define PRIu64 "llu"
  199 #endif
  200 #endif
  201 
  202 #ifndef S_ISDIR
  203 #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
  204 #endif
  205 
  206 #endif /* compat.h */