ocinternal.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
  2. See the COPYRIGHT file for more information. */
  3. #ifndef OCINTERNAL_H
  4. #define OCINTERNAL_H
  5. #include "config.h"
  6. #ifdef _AIX
  7. #include <netinet/in.h>
  8. #endif
  9. #include <stdlib.h>
  10. #include <assert.h>
  11. #include <string.h>
  12. #ifndef WIN32
  13. #include <strings.h>
  14. #endif
  15. #include <stdarg.h>
  16. #ifdef HAVE_UNISTD_H
  17. #include <unistd.h>
  18. #endif
  19. #ifdef HAVE_SYS_TYPES_H
  20. #include <sys/types.h>
  21. #endif
  22. #define CURL_DISABLE_TYPECHECK 1
  23. #include <curl/curl.h>
  24. #include "oclist.h"
  25. #include "ocbytes.h"
  26. #include "ocuri.h"
  27. #define OCCACHEPOS
  28. #include "oc.h"
  29. #include "ocdatatypes.h"
  30. #include "occonstraints.h"
  31. #include "ocnode.h"
  32. #include "ocutil.h"
  33. #include "oclog.h"
  34. #include "xxdr.h"
  35. #include "ocdata.h"
  36. #ifndef nulldup
  37. #define nulldup(s) (s==NULL?NULL:strdup(s))
  38. #endif
  39. #define nullstring(s) (s==NULL?"(null)":s)
  40. #define PATHSEPARATOR "."
  41. /* Default initial memory packet size */
  42. #define DFALTPACKETSIZE 0x20000 /*approximately 100k bytes*/
  43. /* Default maximum memory packet size */
  44. #define DFALTMAXPACKETSIZE 0x3000000 /*approximately 50M bytes*/
  45. /* Extend the OCdxd type */
  46. #define OCVER 3
  47. /* Define a magic number to mark externally visible oc objects */
  48. #define OCMAGIC ((unsigned int)0x0c0c0c0c) /*clever, huh?*/
  49. /*! Specifies the OCstate. */
  50. typedef struct OCstate
  51. {
  52. unsigned int magic; /* Mark each structure type */
  53. CURL* curl; /* curl handle*/
  54. OClist* trees; /* list<OCnode*> ; all root objects */
  55. OCURI* uri; /* base URI*/
  56. OCbytes* packet; /* shared by all trees during construction */
  57. /* OCContent information */
  58. struct OCcontent* contentlist;
  59. struct OCerrdata {/* Hold info for an error return from server */
  60. char* code;
  61. char* message;
  62. long httpcode;
  63. char curlerrorbuf[CURL_ERROR_SIZE]; /* to get curl error message */
  64. } error;
  65. /* Store .rc file info */
  66. struct OCcurlflags {
  67. int compress;
  68. int verbose;
  69. int timeout;
  70. int followlocation;
  71. int maxredirs;
  72. char* useragent;
  73. char* cookiejar;
  74. char* cookiefile;
  75. } curlflags;
  76. struct OCSSL {
  77. int validate;
  78. char* certificate;
  79. char* key;
  80. char* keypasswd;
  81. char* cainfo; /* certificate authority */
  82. char* capath;
  83. int verifypeer;
  84. } ssl;
  85. struct OCproxy {
  86. char *host;
  87. int port;
  88. } proxy;
  89. struct OCcredentials {
  90. char *username;
  91. char *password;
  92. } creds;
  93. long ddslastmodified;
  94. long datalastmodified;
  95. } OCstate;
  96. /*! Specifies all the info about a particular DAP tree
  97. i.e. DAS, DDS, or DATADDS as obtained from a fetch response
  98. This is associated with the root object.
  99. */
  100. typedef struct OCtree
  101. {
  102. OCdxd dxdclass;
  103. char* constraint;
  104. char* text;
  105. struct OCnode* root; /* cross link */
  106. struct OCstate* state; /* cross link */
  107. OClist* nodes; /* all nodes in tree*/
  108. /* when dxdclass == OCDATADDS */
  109. struct {
  110. char* memory; /* allocated memory if OC_INMEMORY is set */
  111. char* filename;
  112. FILE* file;
  113. unsigned long datasize; /* xdr size on disk or in memory */
  114. unsigned long bod; /* offset of the beginning of packet data */
  115. unsigned long ddslen; /* length of ddslen (assert(ddslen <= bod)) */
  116. XXDR* xdrs; /* access either memory or file */
  117. } data;
  118. } OCtree;
  119. /* (Almost) All shared procedure definitions are kept here
  120. except for: ocdebug.h ocutil.h
  121. The true external interface is defined in oc.h
  122. */
  123. /* Location: ocnode.c */
  124. extern OCnode* ocmakenode(char* name, OCtype ptype, OCnode* root);
  125. extern void occollectpathtonode(OCnode* node, OClist* path);
  126. extern void occomputefullnames(OCnode* root);
  127. extern void occomputesemantics(OClist*);
  128. extern void ocaddattribute(OCattribute* attr, OCnode* parent);
  129. extern OCattribute* ocmakeattribute(char* name, OCtype ptype, OClist* values);
  130. extern size_t ocsetsize(OCnode* node);
  131. extern OCerror occorrelate(OCnode*,OCnode*);
  132. extern OCerror occomputeskipdata(OCstate*, OCnode*);
  133. extern void ocmarkcacheable(OCstate* state, OCnode* ddsroot);
  134. /* Location: dapparselex.c*/
  135. extern int dapdebug;
  136. extern OCerror DAPparse(OCstate*, struct OCtree*, char*);
  137. extern char* dimnameanon(char* basename, unsigned int index);
  138. /* Location: ceparselex.c*/
  139. extern int cedebug;
  140. extern OClist* CEparse(OCstate*,char* input);
  141. /* Location: ocinternal.c*/
  142. extern OCerror ocopen(OCstate** statep, const char* url);
  143. extern void occlose(OCstate* state);
  144. extern OCerror ocfetchf(OCstate*, const char*, OCdxd, OCflags, OCnode**);
  145. /* Location: ocinternal.c */
  146. extern int oc_network_order;
  147. extern int oc_invert_xdr_double;
  148. extern int ocinternalinitialize(void);
  149. /* Location: ocnode.c */
  150. extern void ocfreetree(OCtree* tree);
  151. extern void ocfreeroot(OCnode* root);
  152. extern void ocfreenodes(OClist*);
  153. extern void ocddsclear(struct OCstate*);
  154. extern void ocdasclear(struct OCstate*);
  155. extern void ocdataddsclear(struct OCstate*);
  156. extern void* oclinearize(OCtype etype, unsigned int, char**);
  157. /* Merge DAS with DDS or DATADDS*/
  158. extern int ocddsdasmerge(struct OCstate*, OCnode* das, OCnode* dds);
  159. extern OCerror ocupdatelastmodifieddata(OCstate* state);
  160. extern int ocinternalinitialize(void);
  161. extern OCerror ocsetrcfile(char* rcfile);
  162. /* Global stateflags */
  163. extern int oc_curl_file_supported;
  164. extern int oc_curl_https_supported;
  165. #endif /*COMMON_H*/