[409] | 1 | /* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. |
---|
| 2 | See the COPYRIGHT file for more information. */ |
---|
| 3 | |
---|
| 4 | #ifndef NC_URI_H |
---|
| 5 | #define NC_URI_H |
---|
| 6 | |
---|
| 7 | /*! This is an open structure meaning |
---|
| 8 | it is ok to directly access its fields*/ |
---|
| 9 | typedef struct NC_URI { |
---|
| 10 | char* uri; /* as passed by the caller */ |
---|
| 11 | char* protocol; |
---|
| 12 | char* user; /* from user:password@ */ |
---|
| 13 | char* password; /* from user:password@ */ |
---|
| 14 | char* host; /*!< host*/ |
---|
| 15 | char* port; /*!< host */ |
---|
| 16 | char* file; /*!< file */ |
---|
| 17 | char* constraint; /*!< projection+selection */ |
---|
| 18 | char* projection; /*!< without leading '?'*/ |
---|
| 19 | char* selection; /*!< with leading '&'*/ |
---|
| 20 | char* params; /* all params */ |
---|
| 21 | char** paramlist; /*!<null terminated list */ |
---|
| 22 | } NC_URI; |
---|
| 23 | |
---|
| 24 | extern int nc_uriparse(const char* s, NC_URI** nc_uri); |
---|
| 25 | extern void nc_urifree(NC_URI* nc_uri); |
---|
| 26 | |
---|
| 27 | /* Replace the constraints */ |
---|
| 28 | extern void nc_urisetconstraints(NC_URI*,const char* constraints); |
---|
| 29 | |
---|
| 30 | /* Construct a complete NC_ URI; caller frees returned string */ |
---|
| 31 | |
---|
| 32 | /* Define flags to control what is included */ |
---|
| 33 | #define NC_URICONSTRAINTS 1 |
---|
| 34 | #define NC_URIUSERPWD 2 |
---|
| 35 | #define NC_URIPARAMS 4 |
---|
| 36 | #define NC_URIALL (NC_URICONSTRAINTS|NC_URIUSERPWD|NC_URIPARAMS) |
---|
| 37 | |
---|
| 38 | extern char* nc_uribuild(NC_URI*,const char* prefix, const char* suffix, int flags); |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /* Param Management */ |
---|
| 42 | extern int nc_uridecodeparams(NC_URI* nc_uri); |
---|
| 43 | extern int nc_urisetparams(NC_URI* nc_uri,const char*); |
---|
| 44 | |
---|
| 45 | /*! 0 result => entry not found; 1=>found; result holds value (may be null). |
---|
| 46 | In any case, the result is imutable and should not be free'd. |
---|
| 47 | */ |
---|
| 48 | extern int nc_urilookup(NC_URI*, const char* param, const char** result); |
---|
| 49 | |
---|
| 50 | #endif /*NC_URI_H*/ |
---|