summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorBryan Ischo <bryan@ischo.com>2008-07-08 10:03:23 +0000
committerBryan Ischo <bryan@ischo.com>2008-07-08 10:03:23 +0000
commite9e38ab98e38b35725d85cbe6101bfbbd34d1418 (patch)
treec00e14df1f242bfe51d2fc5adbb6965e8a721268 /inc
parente15c6d4cf1310f3016a3aca6f298b0c0f3986982 (diff)
downloadceph-libs3-e9e38ab98e38b35725d85cbe6101bfbbd34d1418.tar.gz
* More work, XML parsing for S3_list_service
Diffstat (limited to 'inc')
-rw-r--r--inc/libs3.h22
-rw-r--r--inc/private.h62
2 files changed, 76 insertions, 8 deletions
diff --git a/inc/libs3.h b/inc/libs3.h
index 3ad5cc3..af5c79d 100644
--- a/inc/libs3.h
+++ b/inc/libs3.h
@@ -441,11 +441,16 @@ 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.
+ * This is the number of seconds since UNIX epoch of the last modified
+ * date of the object identified by the key.
**/
- struct timeval lastModified;
+ int lastModifiedSeconds;
+ /**
+ * This is the number of microseconds within the second specified by
+ * lastModifiedSeconds of the last modified date of the object identified
+ * by the key.
+ **/
+ int lastModifiedMilliseconds;
/**
* This gives a tag which gives a signature of the contents of the object.
**/
@@ -606,13 +611,18 @@ typedef void (S3ResponseCompleteCallback)(S3Status status,
* @param ownerId is the ID of the owner of the bucket
* @param ownerDisplayName is the owner display name of the owner of the bucket
* @param bucketName is the name of the bucket
- * @param creationDate if present is the creation date of the bucket
+ * @param creationDateSeconds if < 0 indicates that no creation date was
+ * supplied for the bucket; if > 0 indicates the number of seconds
+ * since UNIX Epoch of the creation date of the bucket
+ * @param creationDateMilliseconds gives an offset from creationDateSeconds
+ * at which the bucket was created
* @return S3Status???
**/
typedef S3Status (S3ListServiceCallback)(const char *ownerId,
const char *ownerDisplayName,
const char *bucketName,
- const struct timeval *creationDate,
+ int creationDateSeconds,
+ int creationDateMilliseconds,
void *callbackData);
diff --git a/inc/private.h b/inc/private.h
index b190d5b..2ce88d9 100644
--- a/inc/private.h
+++ b/inc/private.h
@@ -85,8 +85,10 @@ typedef enum
//
// Return of anything other than S3StatusOK causes the calling
// simplexml_add() function to immediately stop and return the status.
+//
+// data is passed in as 0 on end of element
typedef S3Status (SimpleXmlCallback)(const char *elementPath, const char *data,
- int dataLen, void *callbackData);
+ int dataLen, void *callbackDatao);
typedef struct SimpleXml
{
@@ -184,6 +186,28 @@ typedef struct RequestParams
} RequestParams;
+typedef struct ListServiceXmlCallbackData
+{
+ char ownerId[256];
+ int ownerIdLen;
+
+ char ownerDisplayName[256];
+ int ownerDisplayNameLen;
+
+ char bucketName[256];
+ int bucketNameLen;
+
+ char creationDate[128];
+ int creationDateLen;
+} ListServiceXmlCallbackData;
+
+
+typedef struct ListBucketXmlCallbackData
+{
+
+} ListBucketXmlCallbackData;
+
+
// This is the stuff associated with a request that needs to be on the heap
// (and thus live while a curl_multi is in use).
typedef struct Request
@@ -285,13 +309,47 @@ typedef struct Request
// s3ErrorExtraDetailsValues
int s3ErrorExtraDetailsValuesLens[8];
+ // The following fields are used by the S3 functions themselves, not
+ // the request code.
+
+ // xxx rewrite all of this stuff, it's ugly. Do the following:
+ // * Define request as a self-contained API similar to what it is now,
+ // but supporting only get object and put object callbacks
+ // * Make the S3 functions that have to do XML parsing allocate their
+ // own callback data, that does the XML parsing, and then passes the
+ // parsed data on
+ //
+ // Alternately, something like:
+ //
+ // - An API for preparing a CURL handle to issue an S3 request
+ // - Separate APIs for handling response data
+ // - The S3 functions tie all of these together, with their own callbacks
+ // for parsing XML data if necessary
+ //
+ // In either case, break the Request structure up into separate structures
+ // with their own APIs (response header parsing, error parsing, etc),
+ // and compose them here, instead of having everything stuck into this
+ // structure directly, which is ugly.
+
// The callbacks to make for the data payload of the response
union {
S3ListServiceCallback *listServiceCallback;
S3ListBucketCallback *listBucketCallback;
S3PutObjectCallback *putObjectCallback;
S3GetObjectCallback *getObjectCallback;
- } u;
+ } callback;
+
+ // The data to use during the xml callback
+ union {
+ ListServiceXmlCallbackData listServiceXmlCallbackData;
+ ListBucketXmlCallbackData listBucketXmlCallbackData;
+ } data;
+
+ // The XML parser that the write callback will use if it needs it
+ SimpleXml dataXmlParser;
+
+ // Whoever initializes dataXmlParser has to set this to 1
+ int dataXmlParserInitialized;
} Request;