diff options
author | Bryan Ischo <bryan@ischo.com> | 2008-08-11 11:21:12 +0000 |
---|---|---|
committer | Bryan Ischo <bryan@ischo.com> | 2008-08-11 11:21:12 +0000 |
commit | 2cda77ecda9c93a03329256744b19a237f92b810 (patch) | |
tree | 21c96115b8f12768d070869b26047830b5b8eda8 /inc | |
parent | 600891ba77f46adb0de1e11779d3a06f664eb8cd (diff) | |
download | ceph-libs3-2cda77ecda9c93a03329256744b19a237f92b810.tar.gz |
* Incorporated fixes submitted by Bryan Donlan <bdonlan@gmail.com>:
- Fixed missing return statement after error in S3_list_bucket
- Fixed integer types in string functions
- Added flags to S3_initialize(), and be sure to call curl_global_init()
and curl_global_cleanup()
* Changed s3 utility to use path-style URI as default, but to refuse to
create a bucket which fails virtual-host-style validation unless the -f
(--force) option is passed to s3
* Allow S3_initialize() to be called more than once with no side effects, as
long as S3_deinitialize() is called the same number of times when libs3
is being shut down
Diffstat (limited to 'inc')
-rw-r--r-- | inc/libs3.h | 42 | ||||
-rw-r--r-- | inc/request.h | 2 | ||||
-rw-r--r-- | inc/string_buffer.h | 4 |
3 files changed, 41 insertions, 7 deletions
diff --git a/inc/libs3.h b/inc/libs3.h index c7910a7..92942c1 100644 --- a/inc/libs3.h +++ b/inc/libs3.h @@ -102,7 +102,8 @@ * not be passed to any other libs3 function by any other thread until the * function returns. * 3. All functions may be called simultaneously by multiple threads as long - * as (1) and (2) are observed. + * as (1) and (2) are observed, EXCEPT for S3_initialize(), which must be + * called from one thread at a time only. * 4. All callbacks will be made in the thread of the caller of the function * which invoked them, so the caller of all libs3 functions should not hold * locks that it would try to re-acquire in a callback, as this may @@ -181,6 +182,20 @@ #define S3_MAX_GRANTEE_DISPLAY_NAME_SIZE 128 +/** + * This constant is used by the S3_initialize() function, to specify that + * the winsock library should be initialized by libs3; only relevent on + * Microsoft Windows platforms. + **/ +#define S3_INIT_WINSOCK 1 + +/** + * This convenience constant is used by the S3_initialize() function to + * indicate that alllibraries required by libs3 should be initialized. + **/ +#define S3_INIT_ALL (S3_INIT_WINSOCK) + + /** ************************************************************************** * Enumerations ************************************************************************** **/ @@ -1139,8 +1154,10 @@ typedef struct S3GetObjectHandler /** * Initializes libs3 for use. This function must be called before any other - * libs3 function is called. It must be called once and only once before - * S3_deinitialize() is called. + * libs3 function is called. It may be called multiple times, with the same + * effect as calling it once, as long as S3_deinitialize() is called an + * equal number of times when the program has finished. This function is NOT + * thread-safe and must only be called by one thread at a time. * * @param userAgentInfo is a string that will be included in the User-Agent * header of every request made to the S3 service. You may provide @@ -1162,8 +1179,24 @@ typedef struct S3GetObjectHandler * @param mutexDestroyCallback provides the callback for the S3 library to * call to destroy a mutex, or NULL if the caller is not a * multithreaded program. + * @param flags is a bitmask of some combination of S3_INIT_XXX flag, or + * S3_INIT_ALL, indicating which of the libraries that libs3 depends + * upon should be initialized by S3_initialize(). Only if your program + * initializes one of these dependency libraries itself should anything + * other than S3_INIT_ALL be passed in for this bitmask. + * + * You should pass S3_INIT_WINSOCK if and only if your application does + * not initialize winsock elsewhere. On non-Microsoft Windows + * platforms it has no effect. + * + * As a convenience, the macro S3_INIT_ALL is provided, which will do + * all necessary initialization; however, be warned that things may + * break if your application re-initializes the dependent libraries + * later. * @return One of: * S3StatusOK on success + * S3StatusInternalError if dependent libraries could not be + * initialized * S3StatusOutOfMemory on failure due to out of memory * S3StatusFailedToCreateMutex if the mutex creation function returned * NULL for one of the mutexes that are created during the @@ -1174,7 +1207,8 @@ S3Status S3_initialize(const char *userAgentInfo, S3MutexCreateCallback *mutexCreateCallback, S3MutexLockCallback *mutexLockCallback, S3MutexUnlockCallback *mutexUnlockCallback, - S3MutexDestroyCallback *mutexDestroyCallback); + S3MutexDestroyCallback *mutexDestroyCallback, + int flags); /** diff --git a/inc/request.h b/inc/request.h index 48f07aa..750e39a 100644 --- a/inc/request.h +++ b/inc/request.h @@ -177,7 +177,7 @@ typedef struct Request // ---------------------------------------------------------------------------- // Initialize the API -S3Status request_api_initialize(const char *userAgentInfo); +S3Status request_api_initialize(const char *userAgentInfo, int flags); // Deinitialize the API void request_api_deinitialize(); diff --git a/inc/string_buffer.h b/inc/string_buffer.h index 61e458f..472baca 100644 --- a/inc/string_buffer.h +++ b/inc/string_buffer.h @@ -49,7 +49,7 @@ #define string_buffer_append(sb, str, len, all_fit) \ do { \ sb##Len += snprintf(&(sb[sb##Len]), sizeof(sb) - sb##Len - 1, \ - "%.*s", len, str); \ + "%.*s", (int) (len), str); \ if (sb##Len > (sizeof(sb) - 1)) { \ sb##Len = sizeof(sb) - 1; \ all_fit = 0; \ @@ -83,7 +83,7 @@ do { \ smb##Size += (snprintf(&(smb[smb##Size]), \ sizeof(smb) - smb##Size, \ - "%.*s", len, str) + 1); \ + "%.*s", (int) (len), str) + 1); \ if (smb##Size > sizeof(smb)) { \ smb##Size = sizeof(smb); \ all_fit = 0; \ |