Doxygen Source Code Documentation
ncio.h File Reference
#include <stddef.h>#include <sys/types.h>#include "netcdf.h"Go to the source code of this file.
Data Structures | |
| struct | ncio |
Defines | |
| #define | OFF_NONE ((off_t)(-1)) |
| #define | RGN_NOLOCK 0x1 |
| #define | RGN_NOWAIT 0x2 |
| #define | RGN_WRITE 0x4 |
| #define | RGN_MODIFIED 0x8 |
| #define | NCIO_CONST const |
Typedefs | |
| typedef ncio | ncio |
| typedef int | ncio_relfunc (ncio *const nciop, off_t offset, int rflags) |
| typedef int | ncio_getfunc (ncio *const nciop, off_t offset, size_t extent, int rflags, void **const vpp) |
| typedef int | ncio_movefunc (ncio *const nciop, off_t to, off_t from, size_t nbytes, int rflags) |
| typedef int | ncio_syncfunc (ncio *const nciop) |
| typedef void | ncio_freefunc (void *const pvt) |
Functions | |
| int | ncio_create (const char *path, int ioflags, size_t initialsz, off_t igeto, size_t igetsz, size_t *sizehintp, ncio **nciopp, void **const igetvpp) |
| int | ncio_open (const char *path, int ioflags, off_t igeto, size_t igetsz, size_t *sizehintp, ncio **nciopp, void **const igetvpp) |
| int | ncio_close (ncio *nciop, int doUnlink) |
Define Documentation
|
|
|
|
|
Definition at line 18 of file ncio.h. Referenced by ncio_ffio_free(), ncio_ffio_init(), ncio_ffio_rel(), ncio_px_free(), ncio_px_get(), ncio_px_init(), ncio_spx_free(), ncio_spx_init(), ncio_spx_rel(), px_get(), px_pgin(), px_pgout(), and rel_v1hs(). |
|
|
|
Definition at line 24 of file ncio.h. Referenced by ncio_ffio_move(), ncio_px_move(), and ncio_spx_move(). |
|
|
|
|
Typedef Documentation
|
|
|
|
|
Definition at line 75 of file ncio.h. Referenced by ncio_ffio_init(), ncio_px_init(), and ncio_spx_init(). |
|
|
Definition at line 52 of file ncio.h. Referenced by ncio_ffio_init(), ncio_px_init(), and ncio_spx_init(). |
|
|
Definition at line 61 of file ncio.h. Referenced by ncio_ffio_init(), ncio_px_init(), and ncio_spx_init(). |
|
|
Definition at line 45 of file ncio.h. Referenced by ncio_ffio_init(), ncio_px_init(), and ncio_spx_init(). |
|
|
Definition at line 68 of file ncio.h. Referenced by ncio_create(), ncio_ffio_init(), ncio_open(), ncio_px_init(), and ncio_spx_init(). |
Function Documentation
|
||||||||||||
|
Definition at line 1319 of file posixio.c. References close(), ENOERR, ncio::fd, ncio_free(), ncio::path, ncio::sync, and unlink. Referenced by main(), nc__create_mp(), nc__open_mp(), nc_abort(), nc_close(), and nc_delete_mp().
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 1151 of file posixio.c. References blksize(), close(), ENOERR, fd, ncio::fd, fgrow(), fIsSet, fSet, ncio::get, ncio::ioflags, M_RNDUP, NC_DEFAULT_CREAT_MODE, ncio_free(), NCIO_MAXBLOCKSIZE, ncio_new(), ncio_px_init2(), ncio_spx_init2(), O_BINARY, and RGN_WRITE. Referenced by main(), and nc__create_mp().
01155 {
01156 ncio *nciop;
01157 int oflags = (O_RDWR|O_CREAT);
01158 int fd;
01159 int status;
01160
01161 if(initialsz < (size_t)igeto + igetsz)
01162 initialsz = (size_t)igeto + igetsz;
01163
01164 fSet(ioflags, NC_WRITE);
01165
01166 if(path == NULL || *path == 0)
01167 return EINVAL;
01168
01169 nciop = ncio_new(path, ioflags);
01170 if(nciop == NULL)
01171 return ENOMEM;
01172
01173 if(fIsSet(ioflags, NC_NOCLOBBER))
01174 fSet(oflags, O_EXCL);
01175 else
01176 fSet(oflags, O_TRUNC);
01177 #ifdef O_BINARY
01178 fSet(oflags, O_BINARY);
01179 #endif
01180 #ifdef vms
01181 fd = open(path, oflags, NC_DEFAULT_CREAT_MODE, "ctx=stm");
01182 #else
01183 /* Should we mess with the mode based on NC_SHARE ?? */
01184 fd = open(path, oflags, NC_DEFAULT_CREAT_MODE);
01185 #endif
01186 #if 0
01187 (void) fprintf(stderr, "ncio_create(): path=\"%s\"\n", path);
01188 (void) fprintf(stderr, "ncio_create(): oflags=0x%x\n", oflags);
01189 #endif
01190 if(fd < 0)
01191 {
01192 status = errno;
01193 goto unwind_new;
01194 }
01195 *((int *)&nciop->fd) = fd; /* cast away const */
01196
01197 if(*sizehintp < NCIO_MINBLOCKSIZE || *sizehintp > NCIO_MAXBLOCKSIZE)
01198 {
01199 /* Use default */
01200 *sizehintp = blksize(fd);
01201 }
01202 else
01203 {
01204 *sizehintp = M_RNDUP(*sizehintp);
01205 }
01206
01207 if(fIsSet(nciop->ioflags, NC_SHARE))
01208 status = ncio_spx_init2(nciop, sizehintp);
01209 else
01210 status = ncio_px_init2(nciop, sizehintp, 1);
01211
01212 if(status != ENOERR)
01213 goto unwind_open;
01214
01215 if(initialsz != 0)
01216 {
01217 status = fgrow(fd, (off_t)initialsz);
01218 if(status != ENOERR)
01219 goto unwind_open;
01220 }
01221
01222 if(igetsz != 0)
01223 {
01224 status = nciop->get(nciop,
01225 igeto, igetsz,
01226 RGN_WRITE,
01227 igetvpp);
01228 if(status != ENOERR)
01229 goto unwind_open;
01230 }
01231
01232 *nciopp = nciop;
01233 return ENOERR;
01234
01235 unwind_open:
01236 (void) close(fd);
01237 /* ?? unlink */
01238 /*FALLTHRU*/
01239 unwind_new:
01240 ncio_free(nciop);
01241 return status;
01242 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 1246 of file posixio.c. References blksize(), close(), ENOERR, fd, ncio::fd, fIsSet, fSet, ncio::get, ncio::ioflags, M_RNDUP, ncio_free(), NCIO_MAXBLOCKSIZE, ncio_new(), ncio_px_init2(), ncio_spx_init2(), and O_BINARY. Referenced by main(), nc__open_mp(), and nc_delete_mp().
01250 {
01251 ncio *nciop;
01252 int oflags = fIsSet(ioflags, NC_WRITE) ? O_RDWR : O_RDONLY;
01253 int fd;
01254 int status;
01255
01256 if(path == NULL || *path == 0)
01257 return EINVAL;
01258
01259 nciop = ncio_new(path, ioflags);
01260 if(nciop == NULL)
01261 return ENOMEM;
01262
01263 #ifdef O_BINARY
01264 fSet(oflags, O_BINARY);
01265 #endif
01266 #ifdef vms
01267 fd = open(path, oflags, 0, "ctx=stm");
01268 #else
01269 fd = open(path, oflags, 0);
01270 #endif
01271 if(fd < 0)
01272 {
01273 status = errno;
01274 goto unwind_new;
01275 }
01276 *((int *)&nciop->fd) = fd; /* cast away const */
01277
01278 if(*sizehintp < NCIO_MINBLOCKSIZE || *sizehintp > NCIO_MAXBLOCKSIZE)
01279 {
01280 /* Use default */
01281 *sizehintp = blksize(fd);
01282 }
01283 else
01284 {
01285 *sizehintp = M_RNDUP(*sizehintp);
01286 }
01287
01288 if(fIsSet(nciop->ioflags, NC_SHARE))
01289 status = ncio_spx_init2(nciop, sizehintp);
01290 else
01291 status = ncio_px_init2(nciop, sizehintp, 0);
01292
01293 if(status != ENOERR)
01294 goto unwind_open;
01295
01296 if(igetsz != 0)
01297 {
01298 status = nciop->get(nciop,
01299 igeto, igetsz,
01300 0,
01301 igetvpp);
01302 if(status != ENOERR)
01303 goto unwind_open;
01304 }
01305
01306 *nciopp = nciop;
01307 return ENOERR;
01308
01309 unwind_open:
01310 (void) close(fd);
01311 /*FALLTHRU*/
01312 unwind_new:
01313 ncio_free(nciop);
01314 return status;
01315 }
|