ReactOS 0.4.16-dev-329-g9223134
tif_unix.c File Reference
#include "tif_config.h"
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "tiffiop.h"
Include dependency graph for tif_unix.c:

Go to the source code of this file.

Classes

union  fd_as_handle_union
 

Macros

#define TIFF_IO_MAX   2147483647U
 

Typedefs

typedef union fd_as_handle_union fd_as_handle_union_t
 

Functions

static tmsize_t _tiffReadProc (thandle_t fd, void *buf, tmsize_t size)
 
static tmsize_t _tiffWriteProc (thandle_t fd, void *buf, tmsize_t size)
 
static uint64 _tiffSeekProc (thandle_t fd, uint64 off, int whence)
 
static int _tiffCloseProc (thandle_t fd)
 
static uint64 _tiffSizeProc (thandle_t fd)
 
static int _tiffMapProc (thandle_t fd, void **pbase, toff_t *psize)
 
static void _tiffUnmapProc (thandle_t fd, void *base, toff_t size)
 
TIFFTIFFFdOpen (int fd, const char *name, const char *mode)
 
TIFFTIFFOpen (const char *name, const char *mode)
 
void_TIFFmalloc (tmsize_t s)
 
void_TIFFcalloc (tmsize_t nmemb, tmsize_t siz)
 
void _TIFFfree (void *p)
 
void_TIFFrealloc (void *p, tmsize_t s)
 
void _TIFFmemset (void *p, int v, tmsize_t c)
 
void _TIFFmemcpy (void *d, const void *s, tmsize_t c)
 
int _TIFFmemcmp (const void *p1, const void *p2, tmsize_t c)
 
static void unixWarningHandler (const char *module, const char *fmt, va_list ap)
 
static void unixErrorHandler (const char *module, const char *fmt, va_list ap)
 

Variables

TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler
 
TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler
 

Macro Definition Documentation

◆ TIFF_IO_MAX

#define TIFF_IO_MAX   2147483647U

Definition at line 57 of file tif_unix.c.

Typedef Documentation

◆ fd_as_handle_union_t

Function Documentation

◆ _TIFFcalloc()

void * _TIFFcalloc ( tmsize_t  nmemb,
tmsize_t  siz 
)

Definition at line 317 of file tif_unix.c.

318{
319 if( nmemb == 0 || siz == 0 )
320 return ((void *) NULL);
321
322 return calloc((size_t) nmemb, (size_t)siz);
323}
#define NULL
Definition: types.h:112
#define calloc
Definition: rosglue.h:14

Referenced by TIFFReadBufferSetup(), and TIFFReadDirectory().

◆ _tiffCloseProc()

static int _tiffCloseProc ( thandle_t  fd)
static

Definition at line 138 of file tif_unix.c.

139{
141 fdh.h = fd;
142 return(close(fdh.fd));
143}
#define close
Definition: acwin.h:98
static int fd
Definition: io.c:51
thandle_t h
Definition: tif_unix.c:63

Referenced by TIFFFdOpen().

◆ _TIFFfree()

void _TIFFfree ( void p)

Definition at line 326 of file tif_unix.c.

327{
328 free(p);
329}
#define free
Definition: debug_ros.c:5
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by _TIFFCreateAnonField(), _TIFFFetchStrileValue(), _TIFFFillStrilesInternal(), _TIFFRewriteField(), _TIFFSetupFields(), _TIFFVSetField(), allocChoppedUpStripArrays(), EstimateStripByteCounts(), fpAcc(), fpDiff(), gtStripContig(), gtStripSeparate(), gtTileContig(), gtTileSeparate(), initCIELabConversion(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), setExtraSamples(), setupMap(), TIFFCleanup(), TIFFClientOpen(), TIFFDefaultDirectory(), TIFFDefaultTransferFunction(), TIFFFetchDirectory(), TIFFFetchNormalTag(), TIFFFetchStripThing(), TIFFFillStrip(), TIFFFillTile(), TIFFFreeDirectory(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFPrintDirectory(), TIFFReadAndRealloc(), TIFFReadBufferSetup(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntryPersampleShort(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFRGBAImageEnd(), TIFFUnlinkDirectory(), TIFFUnRegisterCODEC(), TIFFUnsetField(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSubifd(), and TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFmalloc()

void * _TIFFmalloc ( tmsize_t  s)

◆ _tiffMapProc()

static int _tiffMapProc ( thandle_t  fd,
void **  pbase,
toff_t psize 
)
static

Definition at line 186 of file tif_unix.c.

187{
188 (void) fd; (void) pbase; (void) psize;
189 return (0);
190}
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569

Referenced by TIFFFdOpen().

◆ _TIFFmemcmp()

int _TIFFmemcmp ( const void p1,
const void p2,
tmsize_t  c 
)

Definition at line 350 of file tif_unix.c.

351{
352 return (memcmp(p1, p2, (size_t) c));
353}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
const GLubyte * c
Definition: glext.h:8905

Referenced by TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFmemcpy()

◆ _TIFFmemset()

◆ _tiffReadProc()

static tmsize_t _tiffReadProc ( thandle_t  fd,
void buf,
tmsize_t  size 
)
static

Definition at line 67 of file tif_unix.c.

68{
70 const size_t bytes_total = (size_t) size;
71 size_t bytes_read;
72 tmsize_t count = -1;
73 if ((tmsize_t) bytes_total != size)
74 {
76 return (tmsize_t) -1;
77 }
78 fdh.h = fd;
79 for (bytes_read=0; bytes_read < bytes_total; bytes_read+=count)
80 {
81 char *buf_offset = (char *) buf+bytes_read;
82 size_t io_size = bytes_total-bytes_read;
83 if (io_size > TIFF_IO_MAX)
84 io_size = TIFF_IO_MAX;
85 count=read(fdh.fd, buf_offset, (TIFFIOSize_t) io_size);
86 if (count <= 0)
87 break;
88 }
89 if (count < 0)
90 return (tmsize_t)-1;
91 return (tmsize_t) bytes_read;
92}
#define EINVAL
Definition: acclib.h:90
#define read
Definition: acwin.h:96
__kernel_size_t size_t
Definition: linux.h:237
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define errno
Definition: errno.h:18
#define TIFF_IO_MAX
Definition: tif_unix.c:57
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
size_t TIFFIOSize_t
Definition: tiffiop.h:321

Referenced by TIFFFdOpen().

◆ _TIFFrealloc()

void * _TIFFrealloc ( void p,
tmsize_t  s 
)

Definition at line 332 of file tif_unix.c.

333{
334 return (realloc(p, (size_t) s));
335}
#define realloc
Definition: debug_ros.c:6

Referenced by _TIFFCheckRealloc(), _TIFFFetchStrileValue(), _TIFFVSetField(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFReadAndRealloc(), and TIFFReadDirEntryDataAndRealloc().

◆ _tiffSeekProc()

static uint64 _tiffSeekProc ( thandle_t  fd,
uint64  off,
int  whence 
)
static

Definition at line 124 of file tif_unix.c.

125{
127 _TIFF_off_t off_io = (_TIFF_off_t) off;
128 if ((uint64) off_io != off)
129 {
131 return (uint64) -1; /* this is really gross */
132 }
133 fdh.h = fd;
134 return((uint64)_TIFF_lseek_f(fdh.fd,off_io,whence));
135}
unsigned long long uint64
Definition: platform.h:18
#define _TIFF_lseek_f(fildes, offset, whence)
Definition: tiffiop.h:322
#define _TIFF_off_t
Definition: tiffiop.h:329

Referenced by TIFFFdOpen().

◆ _tiffSizeProc()

static uint64 _tiffSizeProc ( thandle_t  fd)
static

Definition at line 146 of file tif_unix.c.

147{
150 fdh.h = fd;
151 if (_TIFF_fstat_f(fdh.fd,&sb)<0)
152 return(0);
153 else
154 return((uint64)sb.st_size);
155}
superblock * sb
Definition: btrfs.c:4261
#define _TIFF_fstat_f(fildes, stat_buff)
Definition: tiffiop.h:325
#define _TIFF_stat_s
Definition: tiffiop.h:328

Referenced by TIFFFdOpen().

◆ _tiffUnmapProc()

static void _tiffUnmapProc ( thandle_t  fd,
void base,
toff_t  size 
)
static

Definition at line 193 of file tif_unix.c.

194{
195 (void) fd; (void) base; (void) size;
196}

Referenced by TIFFFdOpen().

◆ _tiffWriteProc()

static tmsize_t _tiffWriteProc ( thandle_t  fd,
void buf,
tmsize_t  size 
)
static

Definition at line 95 of file tif_unix.c.

96{
98 const size_t bytes_total = (size_t) size;
99 size_t bytes_written;
100 tmsize_t count = -1;
101 if ((tmsize_t) bytes_total != size)
102 {
104 return (tmsize_t) -1;
105 }
106 fdh.h = fd;
107 for (bytes_written=0; bytes_written < bytes_total; bytes_written+=count)
108 {
109 const char *buf_offset = (char *) buf+bytes_written;
110 size_t io_size = bytes_total-bytes_written;
111 if (io_size > TIFF_IO_MAX)
112 io_size = TIFF_IO_MAX;
113 count=write(fdh.fd, buf_offset, (TIFFIOSize_t) io_size);
114 if (count <= 0)
115 break;
116 }
117 if (count < 0)
118 return (tmsize_t)-1;
119 return (tmsize_t) bytes_written;
120 /* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */
121}
#define write
Definition: acwin.h:97

Referenced by TIFFFdOpen().

◆ TIFFFdOpen()

TIFF * TIFFFdOpen ( int  fd,
const char name,
const char mode 
)

Definition at line 203 of file tif_unix.c.

204{
205 TIFF* tif;
206
208 fdh.fd = fd;
209 tif = TIFFClientOpen(name, mode,
210 fdh.h,
214 if (tif)
215 tif->tif_fd = fd;
216 return (tif);
217}
GLenum mode
Definition: glext.h:6217
Definition: name.c:39
Definition: tiffiop.h:115
int tif_fd
Definition: tiffiop.h:117
TIFF * TIFFClientOpen(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc)
Definition: tif_open.c:71
static tmsize_t _tiffReadProc(thandle_t fd, void *buf, tmsize_t size)
Definition: tif_unix.c:67
static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size)
Definition: tif_unix.c:193
static tmsize_t _tiffWriteProc(thandle_t fd, void *buf, tmsize_t size)
Definition: tif_unix.c:95
static uint64 _tiffSeekProc(thandle_t fd, uint64 off, int whence)
Definition: tif_unix.c:124
static int _tiffCloseProc(thandle_t fd)
Definition: tif_unix.c:138
static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize)
Definition: tif_unix.c:186
static uint64 _tiffSizeProc(thandle_t fd)
Definition: tif_unix.c:146

Referenced by TIFFOpen().

◆ TIFFOpen()

TIFF * TIFFOpen ( const char name,
const char mode 
)

Definition at line 223 of file tif_unix.c.

224{
225 static const char module[] = "TIFFOpen";
226 int m, fd;
227 TIFF* tif;
228
230 if (m == -1)
231 return ((TIFF*)0);
232
233/* for cygwin and mingw */
234#ifdef O_BINARY
235 m |= O_BINARY;
236#endif
237
238 fd = open(name, m, 0666);
239 if (fd < 0) {
240 if (errno > 0 && strerror(errno) != NULL ) {
241 TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) );
242 } else {
243 TIFFErrorExt(0, module, "%s: Cannot open", name);
244 }
245 return ((TIFF *)0);
246 }
247
248 tif = TIFFFdOpen((int)fd, name, mode);
249 if(!tif)
250 close(fd);
251 return tif;
252}
#define O_BINARY
Definition: acwin.h:109
#define open
Definition: acwin.h:95
const GLfloat * m
Definition: glext.h:10848
const char * strerror(int err)
Definition: compat_str.c:23
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
int _TIFFgetMode(const char *mode, const char *module)
Definition: tif_open.c:47
TIFF * TIFFFdOpen(int fd, const char *name, const char *mode)
Definition: tif_unix.c:203

◆ unixErrorHandler()

static void unixErrorHandler ( const char module,
const char fmt,
va_list  ap 
)
static

Definition at line 367 of file tif_unix.c.

368{
369 if (module != NULL)
370 fprintf(stderr, "%s: ", module);
372 fprintf(stderr, ".\n");
373}
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: dsound.c:943
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ unixWarningHandler()

static void unixWarningHandler ( const char module,
const char fmt,
va_list  ap 
)
static

Definition at line 356 of file tif_unix.c.

357{
358 if (module != NULL)
359 fprintf(stderr, "%s: ", module);
360 fprintf(stderr, "Warning, ");
362 fprintf(stderr, ".\n");
363}

Variable Documentation

◆ _TIFFerrorHandler

TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler

Definition at line 374 of file tif_unix.c.

Referenced by TIFFError(), TIFFErrorExt(), and TIFFSetErrorHandler().

◆ _TIFFwarningHandler

TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler

Definition at line 364 of file tif_unix.c.

Referenced by TIFFSetWarningHandler(), TIFFWarning(), and TIFFWarningExt().