curltransaction.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef CURLTRANSACTION_H_INCLUDED
  2. #define CURLTRANSACTION_H_INCLUDED
  3. #include "bool.h"
  4. #include "xmlrpc-c/util.h"
  5. #include "xmlrpc-c/client.h"
  6. #include <curl/curl.h>
  7. typedef struct curlTransaction curlTransaction;
  8. typedef void curlt_finishFn(xmlrpc_env * const, void * const);
  9. typedef void curlt_progressFn(
  10. void * const, double const, double const, double const, double const,
  11. bool * const);
  12. struct curlSetup {
  13. /* This is all client transport properties that are implemented as
  14. simple Curl session properties (i.e. the transport basically just
  15. passes them through to Curl without looking at them).
  16. People occasionally want to replace all this with something where
  17. the Xmlrpc-c user simply does the curl_easy_setopt() call and this
  18. code need not know about all these options. Unfortunately, that's
  19. a significant modularity violation. Either the Xmlrpc-c user
  20. controls the Curl object or he doesn't. If he does, then he
  21. shouldn't use libxmlrpc_client -- he should just copy some of this
  22. code into his own program. If he doesn't, then he should never see
  23. the Curl library.
  24. Speaking of modularity: the only reason this is a separate struct
  25. is to make the code easier to manage. Ideally, the fact that these
  26. particular properties of the transport are implemented by simple
  27. Curl session setup would be known only at the lowest level code
  28. that does that setup.
  29. */
  30. const char * networkInterface;
  31. /* This identifies the network interface on the local side to
  32. use for the session. It is an ASCIIZ string in the form
  33. that the Curl recognizes for setting its CURLOPT_INTERFACE
  34. option (also the --interface option of the Curl program).
  35. E.g. "9.1.72.189" or "giraffe-data.com" or "eth0".
  36. It isn't necessarily valid, but it does have a terminating NUL.
  37. NULL means we have no preference.
  38. */
  39. bool sslVerifyPeer;
  40. /* In an SSL connection, we should authenticate the server's SSL
  41. certificate -- refuse to talk to him if it isn't authentic.
  42. This is equivalent to Curl's CURLOPT_SSL_VERIFY_PEER option.
  43. */
  44. bool sslVerifyHost;
  45. /* In an SSL connection, we should verify that the server's
  46. certificate (independently of whether the certificate is
  47. authentic) indicates the host name that is in the URL we
  48. are using for the server.
  49. */
  50. const char * sslCert;
  51. const char * sslCertType;
  52. const char * sslCertPasswd;
  53. const char * sslKey;
  54. const char * sslKeyType;
  55. const char * sslKeyPasswd;
  56. const char * sslEngine;
  57. bool sslEngineDefault;
  58. unsigned int sslVersion;
  59. const char * caInfo;
  60. const char * caPath;
  61. const char * randomFile;
  62. const char * egdSocket;
  63. const char * sslCipherList;
  64. const char * proxy;
  65. unsigned int proxyPort;
  66. unsigned int proxyAuth;
  67. /* e.g. CURLAUTH_BASIC, CURLAUTH_NTLM, ... */
  68. const char * proxyUserPwd;
  69. unsigned int proxyType;
  70. /* see enum curl_proxytype: CURLPROXY_HTTP, CURLPROXY_SOCKS4, ... */
  71. unsigned int timeout;
  72. /* 0 = no Curl timeout. This is in milliseconds. */
  73. bool verbose;
  74. };
  75. void
  76. curlTransaction_create(xmlrpc_env * const envP,
  77. CURL * const curlSessionP,
  78. const xmlrpc_server_info * const serverP,
  79. xmlrpc_mem_block * const callXmlP,
  80. xmlrpc_mem_block * const responseXmlP,
  81. bool const dontAdvertise,
  82. const char * const userAgent,
  83. const struct curlSetup * const curlSetupStuffP,
  84. void * const userContextP,
  85. curlt_finishFn * const finish,
  86. curlt_progressFn * const progress,
  87. curlTransaction ** const curlTransactionPP);
  88. void
  89. curlTransaction_destroy(curlTransaction * const curlTransactionP);
  90. void
  91. curlTransaction_finish(xmlrpc_env * const envP,
  92. curlTransaction * const curlTransactionP,
  93. CURLcode const result);
  94. void
  95. curlTransaction_getError(curlTransaction * const curlTransactionP,
  96. xmlrpc_env * const envP);
  97. CURL *
  98. curlTransaction_curlSession(curlTransaction * const curlTransactionP);
  99. #endif