00001 /* 00002 * mgr.h 00003 */ 00004 00005 #ifndef __LIBNFSNAPI_MGR_H__ 00006 #define __LIBNFSNAPI_MGR_H__ 00007 00023 #include "error.h" 00024 00026 typedef struct { 00027 #ifdef LIBNFSNAPI_BUILDING_LIB 00028 /* Opaque! Don't touch anything here! */ 00029 libnfsnapi_error_t error; 00030 char *login, *api_key; 00031 00032 int nudge; /* time nudge */ 00033 00034 struct CURL *curl; /* Persistent libcurl handle */ 00035 00036 char *buf; /* Incoming data buffer */ 00037 size_t buf_read, buf_sz; /* Data loaded, buffer size */ 00038 struct curl_slist *headers; /* HTTP headers */ 00039 #endif 00040 } libnfsnapi_mgr_t; 00041 00042 00043 #ifdef LIBNFSNAPI_BUILDING_LIB 00044 /* HTTP methods */ 00045 #define LIBNFSNAPI_MGR_HTTP_GET 1 00046 #define LIBNFSNAPI_MGR_HTTP_PUT 2 00047 #define LIBNFSNAPI_MGR_HTTP_POST 3 00048 #endif 00049 00050 00063 libnfsnapi_mgr_t *libnfsnapi_mgr_create(const char *login, const char *api_key, 00064 int *error_out); 00069 void libnfsnapi_mgr_destroy(libnfsnapi_mgr_t *mgr); 00077 int libnfsnapi_mgr_error(libnfsnapi_mgr_t *mgr); 00082 const char *libnfsnapi_mgr_strerror(libnfsnapi_mgr_t *mgr); 00095 void libnfsnapi_mgr_set_timenudge(libnfsnapi_mgr_t *mgr, int nudge); 00096 00097 #ifdef LIBNFSNAPI_BUILDING_LIB 00098 /* Private functions */ 00099 int libnfsnapi_mgr_do(libnfsnapi_mgr_t *mgr, int method, 00100 const char *request_uri, const char *data); 00101 /* (private) These should only be called after a successful _mgr_do */ 00102 long libnfsnapi_mgr_result_long(libnfsnapi_mgr_t *mgr); 00103 float libnfsnapi_mgr_result_float(libnfsnapi_mgr_t *mgr); 00104 char *libnfsnapi_mgr_result_string(libnfsnapi_mgr_t *mgr); 00105 #endif 00106 00109 #endif /* __LIBNFSNAPI_MGR_H__ */