diff options
author | Bryan Ischo <bryan@ischo.com> | 2008-07-06 12:06:04 +0000 |
---|---|---|
committer | Bryan Ischo <bryan@ischo.com> | 2008-07-06 12:06:04 +0000 |
commit | 07ce7e4123f0ec6b88e65269c6edd69e13b4935c (patch) | |
tree | cb7af33122a56bd257cc20e605c22971cb446aeb /inc | |
parent | 4bd797254bb9c04218ffa304b048a600cb80cbdc (diff) | |
download | ceph-libs3-07ce7e4123f0ec6b88e65269c6edd69e13b4935c.tar.gz |
* More work in progress. Better S3 error support, still needs some cleanup work.
Diffstat (limited to 'inc')
-rw-r--r-- | inc/libs3.h | 4 | ||||
-rw-r--r-- | inc/private.h | 90 |
2 files changed, 57 insertions, 37 deletions
diff --git a/inc/libs3.h b/inc/libs3.h index 62f665a..e66d9e7 100644 --- a/inc/libs3.h +++ b/inc/libs3.h @@ -78,7 +78,9 @@ ************************************************************************** **/ /** - * S3Status is a status code as returned by a libs3 function. + * S3Status is a status code as returned by a libs3 function. These status + * codes identify the success or failure of the request to be sent to S3 + * and the response to be read. **/ typedef enum { diff --git a/inc/private.h b/inc/private.h index d3c2ed0..fe21272 100644 --- a/inc/private.h +++ b/inc/private.h @@ -77,6 +77,33 @@ typedef enum } HttpRequestType; +// Simple XML callback. +// +// elementPath: is the full "path" of the element; i.e. +// <foo><bar><baz>data</baz><bar><foo> would have 'data' in the element +// foo/bar/baz. +// +// Return of anything other than S3StatusOK causes the calling +// simplexml_add() function to immediately stop and return the status. +typedef S3Status (SimpleXmlCallback)(const char *elementPath, const char *data, + int dataLen, void *callbackData); + +typedef struct SimpleXml +{ + void *xmlParser; + + SimpleXmlCallback *callback; + + void *callbackData; + + char elementPath[512]; + + int elementPathLen; + + S3Status status; +} SimpleXml; + + // This completely describes a request. A RequestParams is not required to be // allocated from the heap and its lifetime is not assumed to extend beyond // the lifetime of the function to which it has been passed. @@ -192,8 +219,6 @@ typedef struct Request // Response meta headers S3MetaHeader responseMetaHeaders[MAX_META_HEADER_COUNT]; - // Callback stuff --------------------------------------------------------- - // Callback to make when headers are available S3ResponseHeadersCallback *headersCallback; @@ -203,6 +228,9 @@ typedef struct Request // This is set to nonzero after the haders callback has been made int headersCallbackMade; + // The HTTP response code that S3 sent back for this request + int httpResponseCode; + // This is the write callback that the user of the request wants to have // called back when data is available. size_t (*curlWriteCallback)(void *data, size_t s, size_t n, void *req); @@ -214,12 +242,31 @@ typedef struct Request // The callback to make when the response has been completely handled S3ResponseCompleteCallback *completeCallback; - // This will be 0 if S3 didn't send any XML error - int receivedS3Error; + // This is nonzero if the error XML parser has been initialized + int errorXmlParserInitialized; + + // This is the error XML parser + SimpleXml errorXmlParser; // If S3 did send an XML error, this is the parsed form of it S3Error s3Error; + // These are the buffers used to store the S3Error values + char s3ErrorCode[1024]; + int s3ErrorCodeLen; + + // These are the buffers used to store the S3Error values + char s3ErrorMessage[1024]; + int s3ErrorMessageLen; + + // These are the buffers used to store the S3Error values + char s3ErrorResource[1024]; + int s3ErrorResourceLen; + + // These are the buffers used to store the S3Error values + char s3ErrorFurtherDetails[1024]; + int s3ErrorFurtherDetailsLen; + // The callbacks to make for the data payload of the response union { S3ListServiceCallback *listServiceCallback; @@ -276,42 +323,13 @@ void request_finish(Request *request, S3Status status); // Simple XML parsing // ---------------------------------------------------------------------------- -// Simple XML callback. -// -// elementPath: is the full "path" of the element; i.e. -// <foo><bar><baz>data</baz><bar><foo> would have 'data' in the element -// foo/bar/baz. -// -// Return of anything other than S3StatusOK causes the calling -// simplexml_add() function to immediately stop and return the status. -// -// element data meaning -// ------- ---- ------- -// !0 !0 element data for element -// !0 0 empty element -typedef S3Status (SimpleXmlCallback)(const char *elementPath, const char *data, - int dataLen, void *callbackData); - -typedef struct SimpleXml -{ - void *xmlParser; - - SimpleXmlCallback *callback; - - void *callbackData; - - char elementPath[512]; - - int elementPathLen; - - S3Status status; -} SimpleXml; - - S3Status simplexml_initialize(SimpleXml *simpleXml, SimpleXmlCallback *callback, void *callbackData); S3Status simplexml_add(SimpleXml *simpleXml, const char *data, int dataLen); +void simplexml_deinitialize(SimpleXml *simpleXml); + + #endif /* PRIVATE_H */ |