summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryan Ischo <bji@lolita.(none)>2009-02-13 01:16:09 +1300
committerBryan Ischo <bji@lolita.(none)>2009-02-13 01:16:09 +1300
commit87a9f31214eac06b1963411e6bc60f5f219fc305 (patch)
tree347c1207dc95b74d8e5900e8f7c9ccca365a0c0b /src
parentdbfababac17498a14985f3b8f19b184cb6e6f160 (diff)
downloadceph-libs3-87a9f31214eac06b1963411e6bc60f5f219fc305.tar.gz
* Fixed some issues that were breaking recent Windows builds with recent MinGW
Diffstat (limited to 'src')
-rw-r--r--src/request.c14
-rw-r--r--src/s3.c26
-rw-r--r--src/util.c7
3 files changed, 26 insertions, 21 deletions
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;
diff --git a/src/s3.c b/src/s3.c
index 4f8bdc1..227b380 100644
--- a/src/s3.c
+++ b/src/s3.c
@@ -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();
}
diff --git a/src/util.c b/src/util.c
index 208ed23..25397cc 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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'));
+}