2017-08-31 07:44:57 +08:00
|
|
|
/*
|
|
|
|
Copyright (c) 1998-2017 University Corporation for Atmospheric Research/Unidata
|
|
|
|
See LICENSE.txt for license information.
|
|
|
|
*/
|
2017-03-09 08:01:10 +08:00
|
|
|
|
2017-09-01 04:19:56 +08:00
|
|
|
/*
|
|
|
|
Common functionality for reading
|
|
|
|
and accessing rc files (e.g. .daprc).
|
|
|
|
*/
|
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
#ifndef NCRC_H
|
|
|
|
#define NCRC_H
|
|
|
|
|
2017-09-01 04:19:56 +08:00
|
|
|
/* Need these support includes */
|
2017-08-31 07:44:57 +08:00
|
|
|
#include "ncuri.h"
|
2017-09-01 04:19:56 +08:00
|
|
|
#include "nclist.h"
|
|
|
|
#include "ncbytes.h"
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
typedef struct NCTriple {
|
2017-08-31 07:44:57 +08:00
|
|
|
char* host; /* combined host:port */
|
2017-03-09 08:01:10 +08:00
|
|
|
char* key;
|
|
|
|
char* value;
|
|
|
|
} NCTriple;
|
|
|
|
|
2017-09-01 04:19:56 +08:00
|
|
|
/* collect all the relevant info around the rc file */
|
2017-08-31 07:44:57 +08:00
|
|
|
typedef struct NCRCinfo {
|
2017-09-01 04:19:56 +08:00
|
|
|
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 */
|
2017-08-31 07:44:57 +08:00
|
|
|
} NCRCinfo;
|
2017-03-09 08:01:10 +08:00
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
/* 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 */
|
2018-03-16 22:38:40 +08:00
|
|
|
NCRCinfo rcinfo; /* Currently only one rc file per session */
|
2017-08-31 07:44:57 +08:00
|
|
|
} NCRCglobalstate;
|
|
|
|
|
2017-09-01 04:19:56 +08:00
|
|
|
extern NCRCglobalstate ncrc_globalstate; /* singleton instance */
|
2017-08-31 07:44:57 +08:00
|
|
|
|
|
|
|
/* From drc.c */
|
2017-03-09 08:01:10 +08:00
|
|
|
/* read and compile the rc file, if any */
|
2017-08-31 07:44:57 +08:00
|
|
|
extern int NC_rcload(void);
|
|
|
|
extern char* NC_rclookup(const char* key, const char* hostport);
|
|
|
|
extern void NC_rcclear(NCRCinfo* info);
|
2017-09-01 04:19:56 +08:00
|
|
|
extern int NC_set_rcfile(const char* rcfile);
|
2017-08-31 07:44:57 +08:00
|
|
|
|
2017-09-01 04:19:56 +08:00
|
|
|
/* From dutil.c (Might later move to e.g. nc.h */
|
2017-08-31 07:44:57 +08:00
|
|
|
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);
|
2017-09-03 08:09:36 +08:00
|
|
|
extern char* NC_mktmp(const char* base);
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
#endif /*NCRC_H*/
|