diff options
author | Mark Hammond <mhammond@apache.org> | 2009-11-27 06:41:39 +0000 |
---|---|---|
committer | Mark Hammond <mhammond@apache.org> | 2009-11-27 06:41:39 +0000 |
commit | 05906b5fc0dd75fbca31463c10d07fb2eca7b83b (patch) | |
tree | 7f973dc6d6cca545ac43379265b6e6187393e2d6 /src | |
parent | 0adab205f7a901cef89c7d67bc05cb5bd091dec8 (diff) |
get windows building again
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@884751 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/priv/couch_js/http.c | 69 | ||||
-rw-r--r-- | src/couchdb/priv/couch_js/utf8.c | 4 |
2 files changed, 40 insertions, 33 deletions
diff --git a/src/couchdb/priv/couch_js/http.c b/src/couchdb/priv/couch_js/http.c index 703ab97b..c3d9f102 100644 --- a/src/couchdb/priv/couch_js/http.c +++ b/src/couchdb/priv/couch_js/http.c @@ -17,6 +17,13 @@ #include "utf8.h" +#ifdef XP_WIN +// Map some of the string function names to things which exist on Windows +#define strcasecmp _strcmpi +#define strncasecmp _strnicmp +#define snprintf _snprintf +#endif + typedef struct curl_slist CurlHeaders; typedef struct { @@ -365,7 +372,7 @@ typedef struct { * I really hate doing this but this doesn't have to be * uber awesome, it just has to work. */ -CURL* HANDLE = NULL; +CURL* HTTP_HANDLE = NULL; char ERRBUF[CURL_ERROR_SIZE]; static size_t send_body(void *ptr, size_t size, size_t nmem, void *data); @@ -392,21 +399,21 @@ go(JSContext* cx, JSObject* obj, HTTPData* http, char* body, size_t bodylen) state.recvlen = 0; state.read = 0; - if(HANDLE == NULL) + if(HTTP_HANDLE == NULL) { - HANDLE = curl_easy_init(); - curl_easy_setopt(HANDLE, CURLOPT_READFUNCTION, send_body); - curl_easy_setopt(HANDLE, CURLOPT_SEEKFUNCTION, seek_body); - curl_easy_setopt(HANDLE, CURLOPT_HEADERFUNCTION, recv_header); - curl_easy_setopt(HANDLE, CURLOPT_WRITEFUNCTION, recv_body); - curl_easy_setopt(HANDLE, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(HANDLE, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); - curl_easy_setopt(HANDLE, CURLOPT_ERRORBUFFER, ERRBUF); - curl_easy_setopt(HANDLE, CURLOPT_COOKIEFILE, ""); - curl_easy_setopt(HANDLE, CURLOPT_USERAGENT, "CouchHTTP Client - Relax"); + HTTP_HANDLE = curl_easy_init(); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_READFUNCTION, send_body); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_SEEKFUNCTION, seek_body); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_HEADERFUNCTION, recv_header); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_WRITEFUNCTION, recv_body); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_NOPROGRESS, 1); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_ERRORBUFFER, ERRBUF); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_COOKIEFILE, ""); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_USERAGENT, "CouchHTTP Client - Relax"); } - if(!HANDLE) + if(!HTTP_HANDLE) { JS_ReportError(cx, "Failed to initialize cURL handle."); goto done; @@ -418,41 +425,41 @@ go(JSContext* cx, JSObject* obj, HTTPData* http, char* body, size_t bodylen) goto done; } - curl_easy_setopt(HANDLE, CURLOPT_CUSTOMREQUEST, METHODS[http->method]); - curl_easy_setopt(HANDLE, CURLOPT_NOBODY, 0); - curl_easy_setopt(HANDLE, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(HANDLE, CURLOPT_UPLOAD, 0); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_CUSTOMREQUEST, METHODS[http->method]); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_NOBODY, 0); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_UPLOAD, 0); if(http->method == HEAD) { - curl_easy_setopt(HANDLE, CURLOPT_NOBODY, 1); - curl_easy_setopt(HANDLE, CURLOPT_FOLLOWLOCATION, 0); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_NOBODY, 1); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_FOLLOWLOCATION, 0); } else if(http->method == POST || http->method == PUT) { - curl_easy_setopt(HANDLE, CURLOPT_UPLOAD, 1); - curl_easy_setopt(HANDLE, CURLOPT_FOLLOWLOCATION, 0); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_UPLOAD, 1); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_FOLLOWLOCATION, 0); } if(body && bodylen) { - curl_easy_setopt(HANDLE, CURLOPT_INFILESIZE, bodylen); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_INFILESIZE, bodylen); } else { - curl_easy_setopt(HANDLE, CURLOPT_INFILESIZE, 0); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_INFILESIZE, 0); } - //curl_easy_setopt(HANDLE, CURLOPT_VERBOSE, 1); + //curl_easy_setopt(HTTP_HANDLE, CURLOPT_VERBOSE, 1); - curl_easy_setopt(HANDLE, CURLOPT_URL, http->url); - curl_easy_setopt(HANDLE, CURLOPT_HTTPHEADER, http->req_headers); - curl_easy_setopt(HANDLE, CURLOPT_READDATA, &state); - curl_easy_setopt(HANDLE, CURLOPT_SEEKDATA, &state); - curl_easy_setopt(HANDLE, CURLOPT_WRITEHEADER, &state); - curl_easy_setopt(HANDLE, CURLOPT_WRITEDATA, &state); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_URL, http->url); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_HTTPHEADER, http->req_headers); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_READDATA, &state); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_SEEKDATA, &state); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_WRITEHEADER, &state); + curl_easy_setopt(HTTP_HANDLE, CURLOPT_WRITEDATA, &state); - if(curl_easy_perform(HANDLE) != 0) + if(curl_easy_perform(HTTP_HANDLE) != 0) { JS_ReportError(cx, "Failed to execute HTTP request: %s", ERRBUF); goto done; diff --git a/src/couchdb/priv/couch_js/utf8.c b/src/couchdb/priv/couch_js/utf8.c index d6d6dd2b..699a6fee 100644 --- a/src/couchdb/priv/couch_js/utf8.c +++ b/src/couchdb/priv/couch_js/utf8.c @@ -12,7 +12,7 @@ #include <jsapi.h> -static inline int +static int enc_char(uint8 *utf8Buffer, uint32 ucs4Char) { int utf8Length = 1; @@ -150,7 +150,7 @@ success: return bytes; } -static inline uint32 +static uint32 dec_char(const uint8 *utf8Buffer, int utf8Length) { uint32 ucs4Char; |