nc_uri.h 1.6 KB

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