mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
4636584d5b
re: https://github.com/Unidata/netcdf-c/issues/1154 Inadvertently, the behavior of NC_DISKLESS with nc_create() was changed in release 4.6.1. Previously, the NC_WRITE flag needed to be explicitly used with NC_DISKLESS in order to cause the created file to be persisted to disk. Additional analyis indicated that the current NC_DISKLESS implementation was seriously flawed. This PR attempts to clean up and regularize the situation with respect to NC_DISKLESS control. One important aspect of diskless operation is that there are two different notions of write. 1. The file is read-write vs read-only when using the netcdf API. 2. The file is persisted or not to disk at nc_close(). Previously, these two were conflated. The rules now are as follows. 1. NC_DISKLESS + NC_WRITE means that the file is read/write using the netcdf API 2. NC_DISKLESS + NC_PERSIST means that the file is persisted to a disk file at nc_close. 3. NC_DISKLESS + NC_PERSIST + NC_WRITE means both 1 and 2. The NC_PERSIST flag is new and takes over the obsolete NC_MPIPOSIX flag. NC_MPIPOSIX is still defined, but is now an alias for the NC_MPIIO flag. It is also now the case that for netcdf-4, NC_DISKLESS is independent of NC_INMEMORY and in fact it is an error to specify both flags simultaneously. Finally, the MMAP code was fixed to use NC_PERSIST as well. Also marked MMAP as deprecated. Also added a test case to test various combinations of NC_DISKLESS, NC_PERSIST, and NC_WRITE. This PR affects a number of files and especially test cases that used NC_DISKLESS. Misc. Unrelated fixes 1. fixed some warnings in ncdump/dumplib.c
62 lines
1.9 KiB
C
62 lines
1.9 KiB
C
/*
|
|
Copyright (c) 1998-2017 University Corporation for Atmospheric Research/Unidata
|
|
See LICENSE.txt for license information.
|
|
*/
|
|
|
|
/*
|
|
Common functionality for reading
|
|
and accessing rc files (e.g. .daprc).
|
|
*/
|
|
|
|
#ifndef NCRC_H
|
|
#define NCRC_H
|
|
|
|
/* Need these support includes */
|
|
#include "ncuri.h"
|
|
#include "nclist.h"
|
|
#include "ncbytes.h"
|
|
|
|
typedef struct NCTriple {
|
|
char* host; /* combined host:port */
|
|
char* key;
|
|
char* value;
|
|
} NCTriple;
|
|
|
|
/* collect all the relevant info around the rc file */
|
|
typedef struct NCRCinfo {
|
|
int ignore; /* if 1, then do not use any rc file */
|
|
int loaded; /* 1 => already loaded */
|
|
NClist* triples; /* the rc file triple store fields*/
|
|
char* rcfile; /* specified rcfile; overrides anything else */
|
|
} NCRCinfo;
|
|
|
|
/* Collect global state info in one place */
|
|
typedef struct NCRCglobalstate {
|
|
int initialized;
|
|
char* tempdir; /* track a usable temp dir */
|
|
char* home; /* track $HOME for use in creating $HOME/.oc dir */
|
|
NCRCinfo rcinfo; /* Currently only one rc file per session */
|
|
} NCRCglobalstate;
|
|
|
|
extern NCRCglobalstate ncrc_globalstate; /* singleton instance */
|
|
|
|
/* From drc.c */
|
|
/* read and compile the rc file, if any */
|
|
extern int NC_rcload(void);
|
|
extern char* NC_rclookup(const char* key, const char* hostport);
|
|
extern void NC_rcclear(NCRCinfo* info);
|
|
extern int NC_set_rcfile(const char* rcfile);
|
|
extern int NC_rcfile_insert(const char* key, const char* value, const char* hostport);
|
|
|
|
/* From dutil.c (Might later move to e.g. nc.h */
|
|
extern int NC__testurl(const char* path, char** basenamep);
|
|
extern int NC_isLittleEndian(void);
|
|
extern char* NC_backslashEscape(const char* s);
|
|
extern char* NC_backslashUnescape(const char* esc);
|
|
extern char* NC_entityescape(const char* s);
|
|
extern int NC_readfile(const char* filename, NCbytes* content);
|
|
extern int NC_writefile(const char* filename, size_t size, void* content);
|
|
extern char* NC_mktmp(const char* base);
|
|
|
|
#endif /*NCRC_H*/
|