• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OSGeo / gdal / 13700616263

06 Mar 2025 02:10PM UTC coverage: 70.331% (-0.02%) from 70.35%
13700616263

Pull #11923

github

web-flow
Merge 6a40f0624 into 6d20ab96f
Pull Request #11923: [cli][gdal_contour] Port gdal_contour to cli

355 of 433 new or added lines in 7 files covered. (81.99%)

20395 existing lines in 43 files now uncovered.

553123 of 786461 relevant lines covered (70.33%)

221121.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.77
/frmts/gtiff/libtiff/tif_vsi.c
1
/******************************************************************************
2
 *
3
 * Project:  GeoTIFF Driver
4
 * Purpose:  Implement system hook functions for libtiff on top of CPL/VSI,
5
 *           including > 2GB support.  Based on tif_unix.c from libtiff
6
 *           distribution.
7
 * Author:   Frank Warmerdam, warmerdam@pobox.com
8
 *
9
 ******************************************************************************
10
 * Copyright (c) 2000, Frank Warmerdam, warmerdam@pobox.com
11
 *
12
 * SPDX-License-Identifier: MIT
13
 ****************************************************************************/
14

15
/*
16
 * TIFF Library UNIX-specific Routines.
17
 */
18
#include "tiffiop.h"
19
#include "cpl_vsi.h"
20

21
CPL_INLINE static void CPL_IGNORE_RET_VAL_INT(CPL_UNUSED int unused) {}
×
22

23
static tsize_t
24
_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size)
×
25
{
26
    return VSIFReadL( buf, 1, size, (VSILFILE *) fd );
×
27
}
28

29
static tsize_t
30
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
×
31
{
32
    return VSIFWriteL( buf, 1, size, (VSILFILE *) fd );
×
33
}
34

35
static toff_t
36
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
×
37
{
38
    if( VSIFSeekL( (VSILFILE *) fd, off, whence ) == 0 )
×
39
        return (toff_t) VSIFTellL( (VSILFILE *) fd );
×
40
    else
41
        return (toff_t) -1;
×
42
}
43

44
static int
45
_tiffCloseProc(thandle_t fd)
×
46
{
47
    return VSIFCloseL( (VSILFILE *) fd );
×
48
}
49

50
static toff_t
51
_tiffSizeProc(thandle_t fd)
×
52
{
53
    vsi_l_offset  old_off;
54
    toff_t        file_size;
55

56
    old_off = VSIFTellL( (VSILFILE *) fd );
×
57
    CPL_IGNORE_RET_VAL_INT(VSIFSeekL( (VSILFILE *) fd, 0, SEEK_END ));
×
58

59
    file_size = (toff_t) VSIFTellL( (VSILFILE *) fd );
×
60
    CPL_IGNORE_RET_VAL_INT(VSIFSeekL( (VSILFILE *) fd, old_off, SEEK_SET ));
×
61

62
    return file_size;
×
63
}
64

65
static int
66
_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
×
67
{
68
        (void) fd; (void) pbase; (void) psize;
69
        return (0);
×
70
}
71

72
static void
73
_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size)
×
74
{
75
        (void) fd; (void) base; (void) size;
76
}
×
77

78
/*
79
 * Open a TIFF file descriptor for read/writing.
80
 */
81
TIFF*
82
TIFFFdOpen(CPL_UNUSED int fd, CPL_UNUSED const char* name, CPL_UNUSED const char* mode)
×
83
{
84
        return NULL;
×
85
}
86

87
/*
88
 * Open a TIFF file for read/writing.
89
 */
90
TIFF*
91
TIFFOpen(const char* name, const char* mode)
×
92
{
93
        static const char module[] = "TIFFOpen";
94
        int           i, a_out;
95
        char          szAccess[32];
96
        VSILFILE          *fp;
97
        TIFF          *tif;
98
        char         *pszAccess = szAccess;
×
99

100
        a_out = 0;
×
101
        pszAccess[0] = '\0';
×
102
        for( i = 0; mode[i] != '\0'; i++ )
×
103
        {
104
            if( mode[i] == 'r'
×
105
                || mode[i] == 'w'
×
106
                || mode[i] == '+'
×
107
                || mode[i] == 'a' )
×
108
            {
109
                szAccess[a_out++] = mode[i];
×
110
                szAccess[a_out] = '\0';
×
111
            }
112
        }
113

114
        strcat( szAccess, "b" );
×
115

116
        fp = VSIFOpenL( name, szAccess );
×
117
        if (fp == NULL) {
×
118
            if( errno >= 0 )
×
119
                TIFFError(module,"%s: %s", name, VSIStrerror( errno ) );
×
120
            else
121
                TIFFError(module, "%s: Cannot open", name);
×
122
            return ((TIFF *)0);
×
123
        }
124

125
        tif = TIFFClientOpen(name, mode,
×
126
            (thandle_t) fp,
127
            _tiffReadProc, _tiffWriteProc,
128
            _tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
129
            _tiffMapProc, _tiffUnmapProc);
130

131
        if( tif != NULL )
×
132
            tif->tif_fd = 0;
×
133
        else
134
            CPL_IGNORE_RET_VAL_INT(VSIFCloseL( fp ));
×
135
        
136
        return tif;
×
137
}
138

139
void*
140
_TIFFmalloc(tsize_t s)
804,558✔
141
{
142
    return VSIMalloc((size_t) s);
804,558✔
143
}
144

145
void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
72,883✔
146
{
147
    if( nmemb == 0 || siz == 0 )
72,883✔
UNCOV
148
        return ((void *) NULL);
×
149

150
    return VSICalloc((size_t) nmemb, (size_t)siz);
72,883✔
151
}
152

153
void
154
_TIFFfree(tdata_t p)
1,963,660✔
155
{
156
    VSIFree( p );
1,963,660✔
157
}
1,963,680✔
158

159
void*
160
_TIFFrealloc(tdata_t p, tsize_t s)
1,643,480✔
161
{
162
    return VSIRealloc( p, s );
1,643,480✔
163
}
164

165
void
166
_TIFFmemset(void* p, int v, tmsize_t c)
1,059,800✔
167
{
168
        memset(p, v, (size_t) c);
1,059,800✔
169
}
1,059,800✔
170

171
void
172
_TIFFmemcpy(void* d, const void* s, tmsize_t c)
1,997,170✔
173
{
174
        memcpy(d, s, (size_t) c);
1,997,170✔
175
}
1,997,170✔
176

177
int
178
_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c)
8✔
179
{
180
        return (memcmp(p1, p2, (size_t) c));
8✔
181
}
182

183
static void
184
unixWarningHandler(const char* module, const char* fmt, va_list ap)
×
185
{
186
        if (module != NULL)
×
187
                fprintf(stderr, "%s: ", module);
×
188
        fprintf(stderr, "Warning, ");
×
189
        vfprintf(stderr, fmt, ap);
×
190
        fprintf(stderr, ".\n");
×
191
}
×
192
TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler;
193

194
static void
195
unixErrorHandler(const char* module, const char* fmt, va_list ap)
76✔
196
{
197
        if (module != NULL)
76✔
198
                fprintf(stderr, "%s: ", module);
76✔
199
        vfprintf(stderr, fmt, ap);
76✔
200
        fprintf(stderr, ".\n");
76✔
201
}
76✔
202
TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc