diff options
author | Bryan Ischo <bryan@ischo.com> | 2008-07-05 12:35:32 +0000 |
---|---|---|
committer | Bryan Ischo <bryan@ischo.com> | 2008-07-05 12:35:32 +0000 |
commit | 4bd797254bb9c04218ffa304b048a600cb80cbdc (patch) | |
tree | af6278eb785af3574398032da615bf937a86b427 /inc | |
parent | ea29aa811f469e9fa3616eb73199185d7b5191a5 (diff) | |
download | ceph-libs3-4bd797254bb9c04218ffa304b048a600cb80cbdc.tar.gz |
* Work in progress. Completed simplexml API.
Diffstat (limited to 'inc')
-rw-r--r-- | inc/libs3.h | 23 | ||||
-rw-r--r-- | inc/private.h | 47 |
2 files changed, 56 insertions, 14 deletions
diff --git a/inc/libs3.h b/inc/libs3.h index ea05926..62f665a 100644 --- a/inc/libs3.h +++ b/inc/libs3.h @@ -109,7 +109,8 @@ typedef enum S3StatusContentEncodingTooLong , S3StatusHeadersTooLong , S3StatusKeyTooLong , - S3StatusUriTooLong + S3StatusUriTooLong , + S3StatusXmlParseFailure } S3Status; @@ -322,9 +323,11 @@ typedef struct S3ResponseHeaders const char *eTag; /** * This optional field provides the last modified time, relative to the - * Unix epoch, of the contents. It may or may not be provided. + * Unix epoch, of the contents. If this value is > 0, then the last + * modified date of the contents are availableb as a number of seconds + * since the UNIX epoch. Note that this is second precision. **/ - struct timeval *lastModified; + long lastModified; /** * This is the number of user-provided metadata headers associated with * the resource. @@ -438,6 +441,8 @@ typedef struct ListBucketContent const char *key; /** * This is the last modified date of the object identified by the key. + * It is relative to UNIX epoch. Note that this can have sub-second + * accuracy. **/ struct timeval lastModified; /** @@ -1013,18 +1018,18 @@ S3Status S3_copy_object(S3BucketContext *bucketContext, // The response has to have the exact same set of ranges, or it is an error. // In this way, the caller can be sure that they will get exactly what they // expect. +// ifModifiedSince and ifUnmodifiedSince if > 0 will be used */ -S3Status S3_get_object(S3BucketContext *bucketContext, - const char *key, const struct timeval *ifModifiedSince, - const struct timeval *ifUnmodifiedSince, +S3Status S3_get_object(S3BucketContext *bucketContext, const char *key, + long ifModifiedSince, long ifUnmodifiedSince, const char *ifMatchETag, const char *ifNotMatchETag, const char *byteRange, S3RequestContext *requestContext, S3GetObjectHandler *handler, void *callbackData); -S3Status S3_head_object(S3BucketContext *bucketContext, - const char *key, const struct timeval *ifModifiedSince, - const struct timeval *ifUnmodifiedSince, +// ifModifiedSince and ifUnmodifiedSince if > 0 will be used +S3Status S3_head_object(S3BucketContext *bucketContext, const char *key, + long ifModifiedSince, long ifUnmodifiedSince, const char *ifMatchETag, const char *ifNotMatchETag, S3RequestContext *requestContext, S3ResponseHandler *handler, void *callbackData); diff --git a/inc/private.h b/inc/private.h index 1264aa2..d3c2ed0 100644 --- a/inc/private.h +++ b/inc/private.h @@ -183,10 +183,6 @@ typedef struct Request // The length thus far of responseHeaderStrings int responseHeaderStringsLen; - // responseHeaders.lastModified will be set to this if there is a - // LastModified header - struct timeval lastModified; - // responseHeaders.metaHeaders strings get copied into here char responseMetaHeaderStrings[COMPACTED_META_HEADER_BUFFER_SIZE]; @@ -258,7 +254,7 @@ void mutex_destroy(struct S3Mutex *mutex); // Request functions -// ------------------------------------------------------ +// ---------------------------------------------------------------------------- // Initialize the API S3Status request_api_initialize(const char *userAgentInfo); @@ -277,4 +273,45 @@ S3Status request_perform(RequestParams *params, S3RequestContext *context); 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); + + #endif /* PRIVATE_H */ |