TinyTIFF
a lightweight C/C++ library for reading and writing TIFF files
Loading...
Searching...
No Matches
tinytiff_ctools_internal.h
1
/*
2
Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>), German Cancer Research Center (DKFZ) & IWR, University of Heidelberg
3
4
This software is free software: you can redistribute it and/or modify
5
it under the terms of the GNU Lesser General Public License (LGPL) as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18
*/
19
20
21
#ifndef TINYTIFF_CTOOLS_INTERNAL_H
22
#define TINYTIFF_CTOOLS_INTERNAL_H
23
24
#if defined(HAVE_FTELLI64) || defined(HAVE_FTELLO64)
25
# define TINYTIFF_MAX_FILE_SIZE (0xFFFFFFFE)
26
#else
27
# warning COMPILING TinyTIFFWriter without LARGE_FILE_SUPPORT ... File size is limited to 2GB!
28
# define TINYTIFF_MAX_FILE_SIZE (2*1024*1024*1024-1)
29
#endif
30
31
32
#if defined(__has_builtin)
33
# if __has_builtin(__builtin_object_size)
34
# define tinytiff_builtin_object_size(ptr) __builtin_object_size(ptr, 2)
35
# define tinytiff_builtin_object_size0(dest) __builtin_object_size (dest, 0)
36
# define tinytiff_builtin_object_size1(dest) __builtin_object_size (dest, 1)
37
# define TINYTIFF_HASOBJSIZE
38
# endif
39
#endif
40
41
#ifdef HAVE_STRCPY_S
42
#define TINYTIFF_SET_LAST_ERROR(tiff, message) strcpy_s(tiff->lastError, TIFF_LAST_ERROR_SIZE, message);
43
#define TINYTIFF_STRCPY_S(dest, dsize, src) strcpy_s(dest, dsize, src);
44
#else
45
# if defined(TINYTIFF_HASOBJSIZE) && __has_builtin(__builtin___strcpy_chk)
46
# define TINYTIFF_SET_LAST_ERROR(tiff, message) __builtin___strcpy_chk(tiff->lastError, message, tinytiff_builtin_object_size0(tiff->lastError))
47
# define TINYTIFF_STRCPY_S(dest, dsize, src) __builtin___strcpy_chk(dest, src, tinytiff_builtin_object_size0(dest))
48
# else
49
# define TINYTIFF_SET_LAST_ERROR(tiff, message) strcpy(tiff->lastError, message);
50
# define TINYTIFF_STRCPY_S(dest, dsize, src) strcpy(dest, src);
51
# endif
52
#endif
53
54
55
#ifdef HAVE_STRCAT_S
56
#define TINYTIFF_STRCAT_S(dest, dsize, src) strcat_s(dest, dsize, src);
57
#else
58
# if defined(TINYTIFF_HASOBJSIZE) && __has_builtin(__builtin___strcat_chk)
59
# define TINYTIFF_STRCAT_S(dest, dsize, src) __builtin___strcat_chk(dest, src, tinytiff_builtin_object_size0(dest))
60
# else
61
# define TINYTIFF_STRCAT_S(dest, dsize, src) strcat(dest, src);
62
# endif
63
#endif
64
65
66
#ifdef HAVE_SPRINTF_S
67
# define TINYTIFF_SPRINTF_S(str, ssize, message, ...) sprintf_s(str, ssize, message, __VA_ARGS__);
68
# define TINYTIFF_SPRINTF_LAST_ERROR(tiff, message, ...) sprintf_s(tiff->lastError, TIFF_LAST_ERROR_SIZE, message, __VA_ARGS__);
69
#else
70
# if defined(TINYTIFF_HASOBJSIZE) && __has_builtin(__builtin___sprintf_chk)
71
# define TINYTIFF_SPRINTF_LAST_ERROR(tiff, message, ...) __builtin___sprintf_chk(tiff->lastError, 0, tinytiff_builtin_object_size0(tiff->lastError), message, __VA_ARGS__)
72
# define TINYTIFF_SPRINTF_S(str, ssize, message, ...) __builtin___sprintf_chk(str, 0, tinytiff_builtin_object_size0(str), message, __VA_ARGS__)
73
# else
74
# define TINYTIFF_SPRINTF_S(str, ssize, message, ...) sprintf(str, message, __VA_ARGS__);
75
# define TINYTIFF_SPRINTF_LAST_ERROR(tiff, message, ...) sprintf(tiff->lastError, message, __VA_ARGS__);
76
# endif
77
#endif
78
79
84
void
TinyTIFF_memcpy_s(
void
* dest,
unsigned
long
destsz,
const
void
* src,
unsigned
long
count );
85
90
void
TinyTIFF_memset_s(
void
* dest,
unsigned
long
destsz,
char
ch,
unsigned
long
count );
91
96
unsigned
long
TinyTIFF_strlen_s(
const
char
* str,
unsigned
long
strsz);
97
98
#endif
// TINYTIFF_CTOOLS_INTERNAL_H
src
tinytiff_ctools_internal.h
Generated on Wed May 22 2024 18:28:01 for TinyTIFF by
1.9.8