diff options
author | Bryan Ischo <bji@lolita.(none)> | 2009-02-13 01:16:48 +1300 |
---|---|---|
committer | Bryan Ischo <bji@lolita.(none)> | 2009-02-13 01:16:48 +1300 |
commit | 5987bf58546362151d2da48e3c98d2aad28425fd (patch) | |
tree | 2ec640d3ddf9300f82e85c062c68d92a4a1103be | |
parent | 611cf1e63f0f7133dc3bdb0de32e6cf58fe001eb (diff) | |
parent | 87a9f31214eac06b1963411e6bc60f5f219fc305 (diff) | |
download | ceph-libs3-5987bf58546362151d2da48e3c98d2aad28425fd.tar.gz |
Merge branch '1.4'
-rw-r--r-- | inc/util.h | 3 | ||||
-rw-r--r-- | src/request.c | 14 | ||||
-rw-r--r-- | src/s3.c | 26 | ||||
-rw-r--r-- | src/util.c | 7 |
4 files changed, 29 insertions, 21 deletions
@@ -83,5 +83,8 @@ void HMAC_SHA1(unsigned char hmac[20], const unsigned char *key, int key_len, // Compute a 64-bit hash values given a set of bytes uint64_t hash(const unsigned char *k, int length); +// Because Windows seems to be missing isblank(), use our own; it's a very +// easy function to write in any case +int is_blank(char c); #endif /* UTIL_H */ diff --git a/src/request.c b/src/request.c index 1b9e386..f06e1a6 100644 --- a/src/request.c +++ b/src/request.c @@ -365,7 +365,7 @@ static S3Status compose_standard_headers(const RequestParams *params, params->putProperties-> sourceField[0]) { \ /* Skip whitespace at beginning of val */ \ const char *val = params->putProperties-> sourceField; \ - while (*val && isblank(*val)) { \ + while (*val && is_blank(*val)) { \ val++; \ } \ if (!*val) { \ @@ -378,7 +378,7 @@ static S3Status compose_standard_headers(const RequestParams *params, return tooLongError; \ } \ /* Now remove the whitespace at the end */ \ - while (isblank(values-> destField[len])) { \ + while (is_blank(values-> destField[len])) { \ len--; \ } \ values-> destField[len] = 0; \ @@ -395,7 +395,7 @@ static S3Status compose_standard_headers(const RequestParams *params, params->getConditions-> sourceField[0]) { \ /* Skip whitespace at beginning of val */ \ const char *val = params->getConditions-> sourceField; \ - while (*val && isblank(*val)) { \ + while (*val && is_blank(*val)) { \ val++; \ } \ if (!*val) { \ @@ -408,7 +408,7 @@ static S3Status compose_standard_headers(const RequestParams *params, return tooLongError; \ } \ /* Now remove the whitespace at the end */ \ - while (isblank(values-> destField[len])) { \ + while (is_blank(values-> destField[len])) { \ len--; \ } \ values-> destField[len] = 0; \ @@ -608,16 +608,16 @@ static void canonicalize_amz_headers(RequestComputedValues *values) while (*c) { // If c points to a \r\n[whitespace] sequence, then fold // this newline out - if ((*c == '\r') && (*(c + 1) == '\n') && isblank(*(c + 2))) { + if ((*c == '\r') && (*(c + 1) == '\n') && is_blank(*(c + 2))) { c += 3; - while (isblank(*c)) { + while (is_blank(*c)) { c++; } // Also, what has most recently been copied into buffer amy // have been whitespace, and since we're folding whitespace // out around this newline sequence, back buffer up over // any whitespace it contains - while (isblank(*(buffer - 1))) { + while (is_blank(*(buffer - 1))) { buffer--; } continue; @@ -46,6 +46,9 @@ #define FOPEN_EXTRA_FLAGS "" #endif +// Also needed for Windows, because somehow MinGW doesn't define this +extern int putenv(char *); + // Command-line options, saved as globals ------------------------------------ @@ -68,6 +71,11 @@ static int statusG = 0; static char errorDetailsG[4096] = { 0 }; +// Other globals ------------------------------------------------------------- + +static char putenvBufG[256]; + + // Option prefixes ----------------------------------------------------------- #define LOCATION_PREFIX "location=" @@ -489,16 +497,13 @@ static int64_t parseIso8601Time(const char *str) // This is hokey but it's the recommended way ... char *tz = getenv("TZ"); - setenv("TZ", "UTC", 1); + snprintf(putenvBufG, sizeof(putenvBufG), "TZ=UTC"); + putenv(putenvBufG); int64_t ret = mktime(&stm); - if (tz) { - setenv("TZ", tz, 1); - } - else { - unsetenv("TZ"); - } + snprintf(putenvBufG, sizeof(putenvBufG), "TZ=%s", tz ? tz : ""); + putenv(putenvBufG); // Skip the millis @@ -1956,12 +1961,7 @@ static void get_object(int argc, char **argv, int optindex) byteCount, 0, &getObjectHandler, outfile); } while (S3_status_is_retryable(statusG) && should_retry()); - if (statusG == S3StatusOK) { - if (outfile != stdout) { - ftruncate(fileno(outfile), ftell(outfile)); - } - } - else { + if (statusG != S3StatusOK) { printError(); } @@ -159,7 +159,7 @@ int64_t parseIso8601Time(const char *str) uint64_t parseUnsignedInt(const char *str) { // Skip whitespace - while (isblank(*str)) { + while (is_blank(*str)) { str++; } @@ -560,3 +560,8 @@ uint64_t hash(const unsigned char *k, int length) end: return ((((uint64_t) c) << 32) | b); } + +int is_blank(char c) +{ + return ((c == ' ') || (c == '\t')); +} |