1 /* Converted to D from C:/devLibs/gdal21/include/cpl_vsi.h by htod */
2 module gdal.cpl.vsi;
3 /******************************************************************************
4  * $Id: cpl_vsi.h 33758 2016-03-21 09:06:22Z rouault $
5  *
6  * Project:  CPL - Common Portability Library
7  * Author:   Frank Warmerdam, warmerdam@pobox.com
8  * Purpose:  Include file defining Virtual File System (VSI) functions, a
9  *           layer over POSIX file and other system services.
10  *
11  ******************************************************************************
12  * Copyright (c) 1998, Frank Warmerdam
13  * Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining a
16  * copy of this software and associated documentation files (the "Software"),
17  * to deal in the Software without restriction, including without limitation
18  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19  * and/or sell copies of the Software, and to permit persons to whom the
20  * Software is furnished to do so, subject to the following conditions:
21  *
22  * The above copyright notice and this permission notice shall be included
23  * in all copies or substantial portions of the Software.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31  * DEALINGS IN THE SOFTWARE.
32  ****************************************************************************/
33 
34 import gdal.cpl.port;
35 
36 import core.stdc.stdio : FILE;
37 
38 /**
39 * I did not provide bindings for all the functions in this header, I only
40 * wanted the memory management functions. The rest are not needed to use
41 * GDAL in an application.
42 */
43 /**
44  * \file cpl_vsi.h
45  *
46  * Standard C Covers
47  *
48  * The VSI functions are intended to be hookable aliases for Standard C
49  * I/O, memory allocation and other system functions. They are intended
50  * to allow virtualization of disk I/O so that non file data sources
51  * can be made to appear as files, and so that additional error trapping
52  * and reporting can be interested.  The memory access API is aliased
53  * so that special application memory management services can be used.
54  *
55  * It is intended that each of these functions retains exactly the same
56  * calling pattern as the original Standard C functions they relate to.
57  * This means we don't have to provide custom documentation, and also means
58  * that the default implementation is very simple.
59  */
60 
61 extern (C):
62 FILE * VSIFOpen(const(char) *, const(char) *) nothrow @nogc;
63 int  VSIFClose(FILE *) nothrow @nogc;
64 int  VSIFSeek(FILE *, int , int ) nothrow @nogc;
65 int  VSIFTell(FILE *) nothrow @nogc;
66 void  VSIRewind(FILE *) nothrow @nogc;
67 void  VSIFFlush(FILE *) nothrow @nogc;
68 
69 size_t  VSIFRead(void *, size_t , size_t , FILE *) nothrow @nogc;
70 size_t  VSIFWrite(void *, size_t , size_t , FILE *) nothrow @nogc;
71 char * VSIFGets(char *, int , FILE *) nothrow @nogc;
72 int  VSIFPuts(const(char) *, FILE *) nothrow @nogc;
73 int  VSIFPrintf(FILE *, const(char) *,...) nothrow @nogc;
74 
75 int  VSIFGetc(FILE *) nothrow @nogc;
76 int  VSIFPutc(int , FILE *) nothrow @nogc;
77 int  VSIUngetc(int , FILE *) nothrow @nogc;
78 int  VSIFEof(FILE *) nothrow @nogc;
79 
80 /* ==================================================================== */
81 /*      64bit stdio file access functions.  If we have a big size       */
82 /*      defined, then provide prototypes for the large file API,        */
83 /*      otherwise redefine to use the regular api.                      */
84 /* ==================================================================== */
85 alias GUIntBig vsi_l_offset;
86 
87 alias GUINTBIG_MAX VSI_L_OFFSET_MAX;
88 alias FILE VSILFILE;
89 
90 VSILFILE * VSIFOpenL(const(char) *, const(char) *) nothrow @nogc;
91 VSILFILE * VSIFOpenExL(const(char) *, const(char) *, int ) nothrow @nogc;
92 int  VSIFCloseL(VSILFILE *) nothrow @nogc;
93 int  VSIFSeekL(VSILFILE *, vsi_l_offset , int ) nothrow @nogc;
94 vsi_l_offset  VSIFTellL(VSILFILE *) nothrow @nogc;
95 void  VSIRewindL(VSILFILE *) nothrow @nogc;
96 size_t  VSIFReadL(void *, size_t , size_t , VSILFILE *) nothrow @nogc;
97 int  VSIFReadMultiRangeL(int nRanges, void **ppData, vsi_l_offset *panOffsets, size_t *panSizes, VSILFILE *) nothrow @nogc;
98 size_t  VSIFWriteL(void *, size_t , size_t , VSILFILE *) nothrow @nogc;
99 int  VSIFEofL(VSILFILE *) nothrow @nogc;
100 int  VSIFTruncateL(VSILFILE *, vsi_l_offset ) nothrow @nogc;
101 int  VSIFFlushL(VSILFILE *) nothrow @nogc;
102 int  VSIFPrintfL(VSILFILE *, const(char) *,...) nothrow @nogc;
103 int  VSIFPutcL(int , VSILFILE *) nothrow @nogc;
104 
105 int  VSIIngestFile(VSILFILE *fp, const(char) *pszFilename, GByte **ppabyRet, vsi_l_offset *pnSize, GIntBig nMaxSize) nothrow @nogc;
106 
107 /* ==================================================================== */
108 /*      Memory allocation                                               */
109 /* ==================================================================== */
110 
111 void * VSICalloc(size_t , size_t ) nothrow @nogc;
112 void * VSIMalloc(size_t ) nothrow @nogc;
113 void  VSIFree(void *) nothrow @nogc;
114 void * VSIRealloc(void *, size_t ) nothrow @nogc;
115 char * VSIStrdup(const(char) *) nothrow @nogc;
116 
117 /**
118  VSIMalloc2 allocates (nSize1 * nSize2) bytes.
119  In case of overflow of the multiplication, or if memory allocation fails, a
120  NULL pointer is returned and a CE_Failure error is raised with CPLError().
121  If nSize1 == 0 || nSize2 == 0, a NULL pointer will also be returned.
122  CPLFree() or VSIFree() can be used to free memory allocated by this function.
123 */
124 void * VSIMalloc2(size_t nSize1, size_t nSize2) nothrow @nogc;
125 
126 /**
127  VSIMalloc3 allocates (nSize1 * nSize2 * nSize3) bytes.
128  In case of overflow of the multiplication, or if memory allocation fails, a
129  NULL pointer is returned and a CE_Failure error is raised with CPLError().
130  If nSize1 == 0 || nSize2 == 0 || nSize3 == 0, a NULL pointer will also be returned.
131  CPLFree() or VSIFree() can be used to free memory allocated by this function.
132 */
133 void * VSIMalloc3(size_t nSize1, size_t nSize2, size_t nSize3) nothrow @nogc;
134 
135 void * VSIMallocVerbose(size_t nSize, const(char) *pszFile, int nLine);
136 void * VSIMalloc2Verbose(size_t nSize1, size_t nSize2, const(char) *pszFile, int nLine) nothrow @nogc;
137 
138 void * VSIMalloc3Verbose(size_t nSize1, size_t nSize2, size_t nSize3, const(char) *pszFile, int nLine) nothrow @nogc;
139 
140 void * VSICallocVerbose(size_t nCount, size_t nSize, const(char) *pszFile, int nLine) nothrow @nogc;
141 
142 void * VSIReallocVerbose(void *pOldPtr, size_t nNewSize, const(char) *pszFile, int nLine) nothrow @nogc;
143 
144 char * VSIStrdupVerbose(const(char) *pszStr, const(char) *pszFile, int nLine) nothrow @nogc;
145 
146 
147 GIntBig  CPLGetPhysicalRAM() nothrow @nogc;
148 GIntBig  CPLGetUsablePhysicalRAM() nothrow @nogc;
149 
150 /* ==================================================================== */
151 /*      Other...                                                        */
152 /* ==================================================================== */
153 
154 alias VSIReadDir CPLReadDir;
155 char ** VSIReadDir(const(char) *) nothrow @nogc;
156 char ** VSIReadDirRecursive(const(char) *pszPath) nothrow @nogc;
157 char ** VSIReadDirEx(const(char) *pszPath, int nMaxFiles) nothrow @nogc;
158 int  VSIMkdir(const(char) *pathname, int mode) nothrow @nogc;
159 int  VSIRmdir(const(char) *pathname) nothrow @nogc;
160 int  VSIUnlink(const(char) *pathname) nothrow @nogc;
161 int  VSIRename(const(char) *oldpath, const(char) *newpath) nothrow @nogc;
162 char * VSIStrerror(int ) nothrow @nogc;
163 GIntBig  VSIGetDiskFreeSpace(const(char) *pszDirname) nothrow @nogc;
164 
165 /* ==================================================================== */
166 /*      Install special file access handlers.                           */
167 /* ==================================================================== */
168 void  VSIInstallMemFileHandler() nothrow @nogc;
169 void  VSIInstallLargeFileHandler() nothrow @nogc;
170 void  VSIInstallSubFileHandler() nothrow @nogc;
171 void  VSIInstallCurlFileHandler() nothrow @nogc;
172 void  VSIInstallCurlStreamingFileHandler() nothrow @nogc;
173 void  VSIInstallS3FileHandler() nothrow @nogc;
174 void  VSIInstallS3StreamingFileHandler() nothrow @nogc;
175 void  VSIInstallGZipFileHandler() nothrow @nogc;
176 void  VSIInstallZipFileHandler() nothrow @nogc;
177 void  VSIInstallStdinHandler() nothrow @nogc;
178 void  VSIInstallStdoutHandler() nothrow @nogc;
179 void  VSIInstallSparseFileHandler() nothrow @nogc;
180 void  VSIInstallTarFileHandler() nothrow @nogc;
181 void  VSIInstallCryptFileHandler() nothrow @nogc;
182 void  VSISetCryptKey(GByte *pabyKey, int nKeySize) nothrow @nogc;
183 void  VSICleanupFileManager() nothrow @nogc;
184 
185 VSILFILE * VSIFileFromMemBuffer(const(char *)pszFilename, GByte *pabyData, vsi_l_offset nDataLength, int bTakeOwnership) nothrow @nogc;
186 GByte * VSIGetMemFileBuffer(const(char) *pszFilename, vsi_l_offset *pnDataLength, int bUnlinkAndSeize) nothrow @nogc;
187 
188 alias size_t  function(void *ptr, size_t size, size_t nmemb, FILE *stream)VSIWriteFunction;
189 void  VSIStdoutSetRedirection(VSIWriteFunction pFct, FILE *stream) nothrow @nogc;