CurlPlugin-23 under Linux

1 message Options
Embed this post
Permalink
Marco Schmidt-3

CurlPlugin-23 under Linux

Reply Threaded More More options
Print post
Permalink
 
I have integrated CurlPlugin-dao.23.mcz into my
"platforms/unix/plugins"-tree. It builds and runs with the cmake-build
on my Ubuntu-x64. 14/14 CurlTests are green (but no CurlFtpTests).

It would be nice to review and integrate the generated plugin into the trunk.

The Mac CurlPlugin in mac vm is generated at the moment from an older
version. It is missing functions to add http headers (e.g. to
authenticate against GData ClientLogin) .

Thanks

Marco Schmidt


[CurlPlugin.patch]

diff --git a/platforms/unix/plugins/CurlPlugin/CurlPlugin.c b/platforms/unix/plugins/CurlPlugin/CurlPlugin.c
new file mode 100644
index 0000000..010ff95
--- /dev/null
+++ b/platforms/unix/plugins/CurlPlugin/CurlPlugin.c
@@ -0,0 +1,3256 @@
+/* Automatically generated from Squeak on an Array(21 October 2009 8:57:47 pm)
+by VMMaker 3.11.3
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+/* Default EXPORT macro that does nothing (see comment in sq.h): */
+#define EXPORT(returnType) returnType
+
+/* Do not include the entire sq.h file but just those parts needed. */
+/*  The virtual machine proxy definition */
+#include "sqVirtualMachine.h"
+/* Configuration options */
+#include "sqConfig.h"
+/* Platform specific definitions */
+#include "sqPlatformSpecific.h"
+
+#define true 1
+#define false 0
+#define null 0  /* using 'null' because nil is predefined in Think C */
+#ifdef SQUEAK_BUILTIN_PLUGIN
+#undef EXPORT
+// was #undef EXPORT(returnType) but screws NorCroft cc
+#define EXPORT(returnType) static returnType
+#endif
+#include <curl/curl.h>
+
+typedef struct  {
+
+ unsigned long size; /* buffer byte size */
+ struct dataBufferStruct* next; /* next buffer or 0 if last */
+ struct dataBufferStruct* prev; /* previous buffer or 0 if first */
+ int data; /* data starts here */
+ } dataBufferStruct;
+
+typedef struct   {
+ struct curlStruct* next; /* pointer to the next instance or 0 if last */
+ struct curlStruct* prev;
+ CURL* easyHandle; /* pointer to libcurl easy handle */
+ CURLM* multiHandle; /* pointer to libcurl multi handle */
+ CURLcode easyStatus; /* status of the last performed by easy handle operation */
+ CURLMcode multiStatus; /* status of the last performed by multi handle operation */
+ int isMultiRunning; /* count of transfers in progress (0/1 in our case) */
+ char* url; /* pointer to \0 terminated string, which MUST remain present (it is not copied by libcurl) */
+ struct curl_slist* httpHeader; /* list of strings representing http-header */
+ unsigned long dataSize; /* Bytes allready in buffer */
+ unsigned numberOfBuf; /* Number of buffers allready allocated */
+ unsigned readPosition; /* Current read position in the current buffer */
+ void* readPositionBuf; /* Buffer where read cursor is */
+ dataBufferStruct* dataBufHead; /* Pointer to the first data buffer (see below) structure */
+ dataBufferStruct* dataBufTail; /* Pointer to the last data buffer structure */
+ } curlStruct;
+
+
+#include "sqMemoryAccess.h"
+
+
+/*** Constants ***/
+
+/*** Function Prototypes ***/
+static sqInt adjustReadPositionForHeadBufferDeletion(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct);
+static char * asCString(int aString);
+static curlStruct* asCurlHandle(int aLargeIntegerCurlHandle);
+static int asLargeIntegerCurlHandle(curlStruct *curlHandle);
+static sqInt asString(char* strPtr);
+static void*  bufChainAddBuffer(curlStruct* curlHandle, int byteSize);
+static sqInt bufChainFreeAll(curlStruct* curlHandle);
+static sqInt bufChainFreeHeadBuffer(curlStruct* curlHandle);
+static sqInt bufChainHeadSet(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct);
+static void* bufChainHeadGet(curlStruct* curlHandle);
+static sqInt bufChainTailSet(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct);
+static void* bufChainTailGet(curlStruct* curlHandle);
+static void cFree(void* ptr);
+static void* cMalloc(int sizeInt);
+static sqInt curlHandleFree(curlStruct* curlHandle);
+static curlStruct * curlHandleNew(void);
+static sqInt curlMaxWriteSize(void);
+static sqInt dataSizeSet(curlStruct* curlHandle, unsigned long size);
+static sqInt dataBufNextSet(dataBufferStruct* dataBuffer, void* nextDataBuffer);
+static sqInt dataBufPrevSet(dataBufferStruct* dataBuffer, void* prevDataBuffer);
+static sqInt dataBufSizeSet(dataBufferStruct* dataBuffer, sqInt size);
+static void * dataBufDataGet(dataBufferStruct* dataBuffer);
+static void* dataBufNextGet(dataBufferStruct* dataBuffer);
+static void* dataBufPrevGet(dataBufferStruct* dataBuffer);
+static unsigned long  dataBufSizeGet(dataBufferStruct* dataBuffer);
+static unsigned long dataSizeGet(curlStruct* curlHandle);
+static sqInt easyHandleSet(curlStruct* curlHandle, CURL* easyHandle);
+static sqInt easyHandleFree(curlStruct* curlHandle);
+static CURL * easyHandleGet(curlStruct* curlHandle);
+static sqInt easyStatusSet(curlStruct* curlHandle, CURLcode status);
+static CURLcode easyStatusGet(curlStruct* curlHandle);
+static sqInt freeAllCurlHandles(void);
+static sqInt getInfoTypeDouble(curlStruct* curlHandle, CURLINFO infoCode);
+static sqInt getInfoTypeLong(curlStruct* curlHandle, CURLINFO infoCode);
+static sqInt getInfoTypeString(curlStruct* curlHandle, CURLINFO infoCode);
+static VirtualMachine * getInterpreter(void);
+#pragma export on
+EXPORT(const char*) getModuleName(void);
+#pragma export off
+static sqInt halt(void);
+static sqInt httpAuth(curlStruct* curlHandle, sqInt anInteger);
+static sqInt httpHeaderSet(curlStruct* curlHandle, struct curl_slist* httpHeader);
+static sqInt httpHeaderFree(curlStruct* curlHandle);
+static struct curl_slist* httpHeaderGet(curlStruct* curlHandle);
+#pragma export on
+EXPORT(sqInt) initialiseModule(void);
+#pragma export off
+static sqInt isMultiRunningSet(curlStruct* curlHandle, int running);
+static int  isMultiRunningGet(curlStruct* curlHandle);
+static int * isMultiRunningPtr(curlStruct* curlHandle);
+static sqInt msg(char * s);
+static sqInt multiHandleSet(curlStruct* curlHandle, CURLM* multiHandle);
+static sqInt multiHandleFree(curlStruct* curlHandle);
+static CURLM * multiHandleGet(curlStruct* curlHandle);
+static sqInt multiStatusSet(curlStruct* curlHandle, CURLMcode status);
+static CURLMcode multiStatusGet(curlStruct* curlHandle);
+static sqInt nextHandleSet(curlStruct* curlHandle, curlStruct* nextHandle);
+static curlStruct * nextHandleGet(curlStruct* curlHandle);
+static sqInt numberOfBufSet(curlStruct* curlHandle, unsigned size);
+static unsigned numberOfBufGet(curlStruct* curlHandle);
+static sqInt prevHandleSet(curlStruct* curlHandle, curlStruct* prevHandle);
+static curlStruct * prevHandleGet(curlStruct* curlHandle);
+#pragma export on
+EXPORT(sqInt) primCurlVersion(void);
+EXPORT(sqInt) primDataSize(void);
+EXPORT(sqInt) primEasyAutoReferer(void);
+EXPORT(sqInt) primEasyCaInfo(void);
+EXPORT(sqInt) primEasyCookie(void);
+EXPORT(sqInt) primEasyCookieFile(void);
+EXPORT(sqInt) primEasyCookieJar(void);
+EXPORT(sqInt) primEasyCookieSession(void);
+EXPORT(sqInt) primEasyCustomRequest(void);
+EXPORT(sqInt) primEasyDNSCacheTimeout(void);
+EXPORT(sqInt) primEasyEscape(void);
+EXPORT(sqInt) primEasyFailOnError(void);
+EXPORT(sqInt) primEasyFileTime(void);
+EXPORT(sqInt) primEasyFollowLocation(void);
+EXPORT(sqInt) primEasyHeader(void);
+EXPORT(sqInt) primEasyHttpGet(void);
+EXPORT(sqInt) primEasyHttpProxyTunnel(void);
+EXPORT(sqInt) primEasyMaxRedirs(void);
+EXPORT(sqInt) primEasyNoBody(void);
+EXPORT(sqInt) primEasyPost(void);
+EXPORT(sqInt) primEasyProxy(void);
+EXPORT(sqInt) primEasyProxyUserPwd(void);
+EXPORT(sqInt) primEasySSLVerifyPeer(void);
+EXPORT(sqInt) primEasyTimeout(void);
+EXPORT(sqInt) primEasyUnEscape(void);
+EXPORT(sqInt) primEasyUnrestrictedAuth(void);
+EXPORT(sqInt) primEasyUpload(void);
+EXPORT(sqInt) primEasyUrl(void);
+EXPORT(sqInt) primEasyUserPwd(void);
+EXPORT(sqInt) primEasyVerbose(void);
+EXPORT(sqInt) primEasyHttpAuthAny(void);
+EXPORT(sqInt) primEasyHttpAuthAnySafe(void);
+EXPORT(sqInt) primEasyHttpAuthBasic(void);
+EXPORT(sqInt) primEasyHttpAuthDigest(void);
+EXPORT(sqInt) primEasyHttpAuthNtlm(void);
+EXPORT(sqInt) primEasyHttpHeaders(void);
+EXPORT(sqInt) primEasyPerform(void);
+EXPORT(sqInt) primEasyProxyAuthAny(void);
+EXPORT(sqInt) primEasyProxyAuthAnySafe(void);
+EXPORT(sqInt) primEasyProxyAuthBasic(void);
+EXPORT(sqInt) primEasyProxyAuthDigest(void);
+EXPORT(sqInt) primEasyProxyAuthNtlm(void);
+EXPORT(sqInt) primEasyReset(void);
+EXPORT(sqInt) primEasyStatus(void);
+EXPORT(sqInt) primEasyStrError(void);
+EXPORT(sqInt) primEmptyBuffers(void);
+EXPORT(sqInt) primFetchBuffers(void);
+EXPORT(sqInt) primFetchNextBuffer(void);
+EXPORT(sqInt) primFreeCurlHandle(void);
+EXPORT(sqInt) primInfoConnectTime(void);
+EXPORT(sqInt) primInfoContentLengthDownload(void);
+EXPORT(sqInt) primInfoContentLengthUpload(void);
+EXPORT(sqInt) primInfoContentType(void);
+EXPORT(sqInt) primInfoEffectiveUrl(void);
+EXPORT(sqInt) primInfoFileTime(void);
+EXPORT(sqInt) primInfoFtpEntryPath(void);
+EXPORT(sqInt) primInfoHTTPAuthAvail(void);
+EXPORT(sqInt) primInfoHTTPConnectCode(void);
+EXPORT(sqInt) primInfoHeaderSize(void);
+EXPORT(sqInt) primInfoNameLookupTime(void);
+EXPORT(sqInt) primInfoOsErrNo(void);
+EXPORT(sqInt) primInfoPreTransferTime(void);
+EXPORT(sqInt) primInfoPrivate(void);
+EXPORT(sqInt) primInfoProxyAuthAvail(void);
+EXPORT(sqInt) primInfoRedirectCount(void);
+EXPORT(sqInt) primInfoRedirectTime(void);
+EXPORT(sqInt) primInfoRequestSize(void);
+EXPORT(sqInt) primInfoResponseCode(void);
+EXPORT(sqInt) primInfoSSLVerifyResult(void);
+EXPORT(sqInt) primInfoSizeDownload(void);
+EXPORT(sqInt) primInfoSizeUpload(void);
+EXPORT(sqInt) primInfoSpeedDownload(void);
+EXPORT(sqInt) primInfoSpeedUpload(void);
+EXPORT(sqInt) primInfoStartTransferTime(void);
+EXPORT(sqInt) primInfoTotalTime(void);
+EXPORT(sqInt) primIsMultiRunning(void);
+EXPORT(sqInt) primListAppend(void);
+EXPORT(sqInt) primMultiAttach(void);
+EXPORT(sqInt) primMultiDetach(void);
+EXPORT(sqInt) primMultiInfoRead(void);
+EXPORT(sqInt) primMultiPerform(void);
+EXPORT(sqInt) primMultiStatus(void);
+EXPORT(sqInt) primMultiStrError(void);
+EXPORT(sqInt) primNewCurlHandle(void);
+EXPORT(sqInt) primNumberOfBuf(void);
+EXPORT(sqInt) primNumberOfMemChunks(void);
+EXPORT(sqInt) primReadRewind(void);
+EXPORT(sqInt) primSetBuffersData(void);
+EXPORT(sqInt) primTimeFromString(void);
+#pragma export off
+static sqInt proxyAuth(curlStruct* curlHandle, sqInt anInteger);
+static sqInt pvtReadBufferItemsofBytesUserData(void *dataPtr, unsigned items, unsigned size, curlStruct* curlHandle);
+static sqInt pvtWriteNewBufferItemsofBytesUserData(void *dataPtr, unsigned items, unsigned size, curlStruct* curlHandle);
+static sqInt readPositionBufSet(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct);
+static sqInt readPositionSet(curlStruct* curlHandle, unsigned pos);
+static void* readPositionBufGet(curlStruct* curlHandle);
+static unsigned readPositionGet(curlStruct* curlHandle);
+static int readPositionIsAtEnd(curlStruct* curlHandle);
+static sqInt readPositionRewind(curlStruct* curlHandle);
+#pragma export on
+EXPORT(sqInt) setInterpreter(struct VirtualMachine* anInterpreter);
+EXPORT(sqInt) shutdownModule(void);
+#pragma export off
+static sqInt sizeOfCurlStruct(void);
+static sqInt sizeOfDataBufferStruct(void);
+static sqInt sqAssert(sqInt aBool);
+static sqInt urlSet(curlStruct* curlHandle, char*  str);
+static sqInt urlFree(curlStruct* curlHandle);
+static char * urlGet(curlStruct* curlHandle);
+/*** Variables ***/
+static curlStruct* curlHandleFirst;
+static curlStruct* curlHandleLast;
+static CURLSH *curlShare;
+
+#ifdef SQUEAK_BUILTIN_PLUGIN
+extern
+#endif
+struct VirtualMachine* interpreterProxy;
+static int memChunks;
+static const char *moduleName =
+#ifdef SQUEAK_BUILTIN_PLUGIN
+ "CurlPlugin 21 October 2009 (i)"
+#else
+ "CurlPlugin 21 October 2009 (e)"
+#endif
+;
+
+
+static sqInt adjustReadPositionForHeadBufferDeletion(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct) {
+ if ((dataBufNextGet(dataBufferStruct)) == 0) {
+ readPositionRewind(curlHandle);
+ } else {
+ if ((readPositionBufGet(curlHandle)) == dataBufferStruct) {
+ readPositionBufSet(curlHandle, dataBufNextGet(dataBufferStruct));
+ readPositionSet(curlHandle, 0);
+ }
+ }
+}
+
+static char * asCString(int aString) {
+ int strSize;
+ char *strPtr;
+
+ if (!(interpreterProxy->isBytes(aString))) {
+ return 0;
+ }
+ strSize = (interpreterProxy->stSizeOf(aString)) + 1;
+ strPtr = cMalloc(strSize);
+ if (strPtr == 0) {
+ return 0;
+ }
+ strncpy( strPtr, interpreterProxy->firstIndexableField(aString), strSize);
+ strPtr[strSize - 1] = 0;
+ return strPtr;
+}
+
+
+/* convert Smalltalk side LargeInteger representation of the pointer to the C pointer */
+
+static curlStruct* asCurlHandle(int aLargeIntegerCurlHandle) {
+ curlStruct * current;
+ curlStruct * curlHandle;
+
+ curlHandle = ((curlStruct*) (interpreterProxy->positive32BitValueOf(aLargeIntegerCurlHandle)));
+ current = curlHandleFirst;
+ while (current != 0) {
+ if (current == curlHandle) {
+ return curlHandle;
+ } else {
+ current = nextHandleGet(current);
+ }
+ }
+ return 0;
+}
+
+
+/* convert C-curlHandle to the Smalltalk LargeInteger  */
+
+static int asLargeIntegerCurlHandle(curlStruct *curlHandle) {
+ return interpreterProxy->positive32BitIntegerFor((((int) curlHandle)));
+}
+
+static sqInt asString(char* strPtr) {
+ int strSize;
+ int aString;
+
+ if (strPtr == 0) {
+ strSize = 0;
+ } else {
+ strSize = strlen(strPtr);
+ }
+ aString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), strSize);
+ if (strSize > 0) {
+ strncpy( interpreterProxy->firstIndexableField(aString), strPtr, strSize );
+ }
+ return aString;
+}
+
+static void*  bufChainAddBuffer(curlStruct* curlHandle, int byteSize) {
+ dataBufferStruct* newBuffer;
+ dataBufferStruct* prevBuffer;
+
+ newBuffer = cMalloc(byteSize + (sizeof(dataBufferStruct)));
+ if (newBuffer == 0) {
+ return 0;
+ }
+ dataBufSizeSet(newBuffer, byteSize);
+ numberOfBufSet(curlHandle, 1 + (numberOfBufGet(curlHandle)));
+ dataBufNextSet(newBuffer, 0);
+ if ((bufChainHeadGet(curlHandle)) == 0) {
+ bufChainHeadSet(curlHandle, newBuffer);
+ readPositionBufSet(curlHandle, newBuffer);
+ dataBufPrevSet(newBuffer, 0);
+ } else {
+ prevBuffer = bufChainTailGet(curlHandle);
+ dataBufNextSet(prevBuffer, newBuffer);
+ }
+ bufChainTailSet(curlHandle, newBuffer);
+ return dataBufDataGet(newBuffer);
+}
+
+static sqInt bufChainFreeAll(curlStruct* curlHandle) {
+ dataBufferStruct* headBuffer;
+ dataBufferStruct* nextBuffer;
+
+ headBuffer = bufChainHeadGet(curlHandle);
+ while (headBuffer != 0) {
+ nextBuffer = dataBufNextGet(headBuffer);
+ cFree(headBuffer);
+ headBuffer = nextBuffer;
+ }
+ bufChainHeadSet(curlHandle, 0);
+ bufChainTailSet(curlHandle, 0);
+ dataSizeSet(curlHandle, 0);
+ numberOfBufSet(curlHandle, 0);
+ readPositionRewind(curlHandle);
+}
+
+static sqInt bufChainFreeHeadBuffer(curlStruct* curlHandle) {
+ dataBufferStruct* headBuffer;
+ dataBufferStruct* nextBuffer;
+
+ headBuffer = bufChainHeadGet(curlHandle);
+ if (headBuffer != 0) {
+ nextBuffer = dataBufNextGet(headBuffer);
+ bufChainHeadSet(curlHandle, nextBuffer);
+ if (nextBuffer == 0) {
+ bufChainTailSet(curlHandle, 0);
+ } else {
+ if ((dataBufNextGet(nextBuffer)) == 0) {
+ bufChainTailSet(curlHandle, nextBuffer);
+ }
+ }
+ }
+ numberOfBufSet(curlHandle, (numberOfBufGet(curlHandle)) - 1);
+ dataSizeSet(curlHandle, (dataSizeGet(curlHandle)) - (dataBufSizeGet(headBuffer)));
+ adjustReadPositionForHeadBufferDeletion(curlHandle, headBuffer);
+ cFree(headBuffer);
+}
+
+static sqInt bufChainHeadSet(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct) {
+ curlHandle->dataBufHead = dataBufferStruct;
+}
+
+static void* bufChainHeadGet(curlStruct* curlHandle) {
+ return curlHandle->dataBufHead;
+}
+
+static sqInt bufChainTailSet(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct) {
+ curlHandle->dataBufTail = dataBufferStruct;
+}
+
+static void* bufChainTailGet(curlStruct* curlHandle) {
+ return curlHandle->dataBufTail;
+}
+
+static void cFree(void* ptr) {
+ if (ptr != 0) {
+ memChunks -= 1;
+ }
+ free(ptr);
+}
+
+static void* cMalloc(int sizeInt) {
+ void* ptr;
+
+ ptr = malloc(sizeInt);
+ if (ptr != 0) {
+ memChunks += 1;
+ }
+ return ptr;
+}
+
+static sqInt curlHandleFree(curlStruct* curlHandle) {
+ curlStruct* next;
+ curlStruct* prev;
+
+ prev = prevHandleGet(curlHandle);
+ next = nextHandleGet(curlHandle);
+ if (prev != 0) {
+ nextHandleSet(prev, next);
+ } else {
+ curlHandleFirst = next;
+ }
+ if (next == 0) {
+ curlHandleLast = prev;
+ } else {
+ prevHandleSet(next, prev);
+ }
+ bufChainFreeAll(curlHandle);
+ multiHandleFree(curlHandle);
+ easyHandleFree(curlHandle);
+ httpHeaderFree(curlHandle);
+ urlFree(curlHandle);
+ cFree(curlHandle);
+}
+
+static curlStruct * curlHandleNew(void) {
+ CURL* easyHandle;
+ CURLM* multiHandle;
+ curlStruct* curlHandle;
+
+ curlHandle = cMalloc(sizeof(curlStruct));
+ if (curlHandle == 0) {
+ return 0;
+ }
+ memset(curlHandle, 0, sizeOfCurlStruct());
+ easyHandle = curl_easy_init();
+ if (easyHandle == 0) {
+ cFree(curlHandle);
+ return 0;
+ }
+ easyHandleSet(curlHandle, easyHandle);
+ multiHandle = curl_multi_init();
+ if (multiHandle == 0) {
+ easyHandleFree(curlHandle);
+ cFree(curlHandle);
+ return 0;
+ }
+ multiHandleSet(curlHandle, multiHandle);
+ curl_easy_setopt( easyHandle, CURLOPT_WRITEFUNCTION, pvtWriteNewBufferItemsofBytesUserData);
+ curl_easy_setopt( easyHandle, CURLOPT_WRITEDATA, curlHandle);
+ curl_easy_setopt( easyHandle, CURLOPT_READFUNCTION, pvtReadBufferItemsofBytesUserData);
+ curl_easy_setopt( easyHandle, CURLOPT_READDATA, curlHandle);
+ curl_easy_setopt( easyHandle, CURLOPT_NOPROGRESS, 1);
+ curl_easy_setopt( easyHandle, CURLOPT_SHARE, curlShare);
+ prevHandleSet(curlHandle, curlHandleLast);
+ nextHandleSet(curlHandle, 0);
+ if (curlHandleFirst == 0) {
+ curlHandleFirst = curlHandle;
+ }
+ if (curlHandleLast != 0) {
+ nextHandleSet(curlHandleLast, curlHandle);
+ }
+ curlHandleLast = curlHandle;
+ return curlHandle;
+}
+
+
+/* the default buffer size used by curl library - use it when not sure about size to allocate memory
+ this is a constant defined in curl.h  */
+
+static sqInt curlMaxWriteSize(void) {
+ return CURL_MAX_WRITE_SIZE;
+}
+
+static sqInt dataSizeSet(curlStruct* curlHandle, unsigned long size) {
+ curlHandle->dataSize = size;
+}
+
+static sqInt dataBufNextSet(dataBufferStruct* dataBuffer, void* nextDataBuffer) {
+ dataBuffer->next = nextDataBuffer;
+}
+
+static sqInt dataBufPrevSet(dataBufferStruct* dataBuffer, void* prevDataBuffer) {
+ dataBuffer->prev = prevDataBuffer;
+}
+
+static sqInt dataBufSizeSet(dataBufferStruct* dataBuffer, sqInt size) {
+ dataBuffer->size = size;
+}
+
+static void * dataBufDataGet(dataBufferStruct* dataBuffer) {
+ return &dataBuffer->data;
+}
+
+static void* dataBufNextGet(dataBufferStruct* dataBuffer) {
+ return dataBuffer->next;
+}
+
+static void* dataBufPrevGet(dataBufferStruct* dataBuffer) {
+ return dataBuffer->prev;
+}
+
+static unsigned long  dataBufSizeGet(dataBufferStruct* dataBuffer) {
+ return dataBuffer->size;
+}
+
+static unsigned long dataSizeGet(curlStruct* curlHandle) {
+ return curlHandle->dataSize;
+}
+
+static sqInt easyHandleSet(curlStruct* curlHandle, CURL* easyHandle) {
+ easyHandleFree(curlHandle);
+ curlHandle->easyHandle = easyHandle;
+}
+
+static sqInt easyHandleFree(curlStruct* curlHandle) {
+ CURL* easyHandle;
+
+ easyHandle = curlHandle->easyHandle;
+ if (easyHandle != 0) {
+ curl_easy_setopt( easyHandle, CURLOPT_SHARE, 0);
+ curl_easy_cleanup(easyHandle);
+ }
+ curlHandle->easyHandle = 0;
+}
+
+static CURL * easyHandleGet(curlStruct* curlHandle) {
+ return curlHandle->easyHandle;
+}
+
+static sqInt easyStatusSet(curlStruct* curlHandle, CURLcode status) {
+ curlHandle->easyStatus = status;
+}
+
+static CURLcode easyStatusGet(curlStruct* curlHandle) {
+ return curlHandle->easyStatus;
+}
+
+static sqInt freeAllCurlHandles(void) {
+ curlStruct* nextHandle;
+ curlStruct* headHandle;
+
+ headHandle = curlHandleFirst;
+ while (headHandle != 0) {
+ nextHandle = nextHandleGet(headHandle);
+ curlHandleFree(headHandle);
+ headHandle = nextHandle;
+ }
+ curlHandleFirst = 0;
+ curlHandleLast = 0;
+}
+
+static sqInt getInfoTypeDouble(curlStruct* curlHandle, CURLINFO infoCode) {
+ double value;
+
+ value = 0;
+ easyStatusSet(curlHandle, curl_easy_getinfo( easyHandleGet(curlHandle), infoCode, &value));
+ return interpreterProxy->floatObjectOf(value);
+}
+
+static sqInt getInfoTypeLong(curlStruct* curlHandle, CURLINFO infoCode) {
+ long value;
+
+ value = 0;
+ easyStatusSet(curlHandle, curl_easy_getinfo( easyHandleGet(curlHandle), infoCode, &value));
+ return interpreterProxy->signed32BitIntegerFor(value);
+}
+
+static sqInt getInfoTypeString(curlStruct* curlHandle, CURLINFO infoCode) {
+ char* value;
+
+ value = 0;
+ easyStatusSet(curlHandle, curl_easy_getinfo( easyHandleGet(curlHandle), infoCode, &value));
+ return asString(value);
+}
+
+
+/* Note: This is coded so that plugins can be run from Squeak. */
+
+static VirtualMachine * getInterpreter(void) {
+ return interpreterProxy;
+}
+
+
+/* Note: This is hardcoded so it can be run from Squeak.
+ The module name is used for validating a module *after*
+ it is loaded to check if it does really contain the module
+ we're thinking it contains. This is important! */
+
+EXPORT(const char*) getModuleName(void) {
+ return moduleName;
+}
+
+static sqInt halt(void) {
+ ;
+}
+
+static sqInt httpAuth(curlStruct* curlHandle, sqInt anInteger) {
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_HTTPAUTH, anInteger));
+}
+
+static sqInt httpHeaderSet(curlStruct* curlHandle, struct curl_slist* httpHeader) {
+ curlHandle->httpHeader = httpHeader;
+}
+
+static sqInt httpHeaderFree(curlStruct* curlHandle) {
+ struct curl_slist* httpHeader;
+
+ httpHeader = curlHandle->httpHeader;
+ curl_slist_free_all(httpHeader);
+ curlHandle->httpHeader = NULL;
+}
+
+static struct curl_slist* httpHeaderGet(curlStruct* curlHandle) {
+ return curlHandle->httpHeader;
+}
+
+EXPORT(sqInt) initialiseModule(void) {
+ memChunks = 0;
+ if (!((curl_global_init(CURL_GLOBAL_ALL )) == 0)) {
+ return 0;
+ }
+ if ((curlShare = curl_share_init()) == 0) {
+ curl_global_cleanup();
+ return 0;
+ }
+ if (!((curl_share_setopt(curlShare, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS)) == 0)) {
+ curl_share_cleanup(curlShare);
+ curl_global_cleanup();
+ return 0;
+ }
+ curlHandleFirst = 0;
+ curlHandleLast = 0;
+ return 1;
+}
+
+static sqInt isMultiRunningSet(curlStruct* curlHandle, int running) {
+ curlHandle->isMultiRunning = running;
+}
+
+static int  isMultiRunningGet(curlStruct* curlHandle) {
+ return curlHandle->isMultiRunning;
+}
+
+static int * isMultiRunningPtr(curlStruct* curlHandle) {
+ return &curlHandle->isMultiRunning;
+}
+
+static sqInt msg(char * s) {
+ fprintf(stderr, "\n%s: %s", moduleName, s);
+}
+
+static sqInt multiHandleSet(curlStruct* curlHandle, CURLM* multiHandle) {
+ multiHandleFree(curlHandle);
+ curlHandle->multiHandle = multiHandle;
+}
+
+static sqInt multiHandleFree(curlStruct* curlHandle) {
+ CURLM* multiHandle;
+
+ multiHandle = curlHandle->multiHandle;
+ if (multiHandle != 0) {
+ curl_multi_cleanup(multiHandle);
+ }
+ curlHandle->multiHandle = 0;
+}
+
+static CURLM * multiHandleGet(curlStruct* curlHandle) {
+ return curlHandle->multiHandle;
+}
+
+static sqInt multiStatusSet(curlStruct* curlHandle, CURLMcode status) {
+ curlHandle->multiStatus = status;
+}
+
+static CURLMcode multiStatusGet(curlStruct* curlHandle) {
+ return curlHandle->multiStatus;
+}
+
+static sqInt nextHandleSet(curlStruct* curlHandle, curlStruct* nextHandle) {
+ curlHandle->next = (struct curlStruct *)nextHandle;
+}
+
+static curlStruct * nextHandleGet(curlStruct* curlHandle) {
+ return (curlStruct *) curlHandle->next;
+}
+
+static sqInt numberOfBufSet(curlStruct* curlHandle, unsigned size) {
+ curlHandle->numberOfBuf = size;
+}
+
+static unsigned numberOfBufGet(curlStruct* curlHandle) {
+ return curlHandle->numberOfBuf;
+}
+
+static sqInt prevHandleSet(curlStruct* curlHandle, curlStruct* prevHandle) {
+ curlHandle->prev = (struct curlStruct *)prevHandle;
+}
+
+static curlStruct * prevHandleGet(curlStruct* curlHandle) {
+ return (curlStruct *)curlHandle->prev;
+}
+
+EXPORT(sqInt) primCurlVersion(void) {
+ sqInt _return_value;
+
+ _return_value = asString(curl_version());
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(1, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primDataSize(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = interpreterProxy->positive32BitIntegerFor((dataSizeGet(curlHandle)));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primEasyAutoReferer(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_AUTOREFERER, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyCaInfo(void) {
+ char *cainfoStr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ cainfoStr = asCString(aString);
+ if (cainfoStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_CAINFO , cainfoStr));
+ cFree(cainfoStr);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyCookie(void) {
+ char *cookieStr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ cookieStr = asCString(aString);
+ if (cookieStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_COOKIE , cookieStr));
+ cFree(cookieStr);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyCookieFile(void) {
+ char *cookieFileStr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ cookieFileStr = asCString(aString);
+ if (cookieFileStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_COOKIEFILE , cookieFileStr));
+ cFree(cookieFileStr);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyCookieJar(void) {
+ char *cookieJarStr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ cookieJarStr = asCString(aString);
+ if (cookieJarStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_COOKIEJAR , cookieJarStr));
+ cFree(cookieJarStr);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyCookieSession(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_COOKIESESSION , anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyCustomRequest(void) {
+ char *customRequest;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ customRequest = asCString(aString);
+ if (customRequest == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_CUSTOMREQUEST, customRequest));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyDNSCacheTimeout(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_DNS_CACHE_TIMEOUT, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyEscape(void) {
+ char *urlStrPtr;
+ char *escapedStr;
+ unsigned resultString;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ urlStrPtr = asCString(aString);
+ if (urlStrPtr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ escapedStr = curl_easy_escape(easyHandleGet(curlHandle), urlStrPtr, 0);
+ cFree(urlStrPtr);
+ if (escapedStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ resultString = asString(escapedStr);
+ curl_free(escapedStr);
+ if (resultString == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ } else {
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(3, resultString);
+ return null;
+ }
+}
+
+EXPORT(sqInt) primEasyFailOnError(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_FAILONERROR, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyFileTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_FILETIME, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyFollowLocation(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_FOLLOWLOCATION, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHeader(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_HEADER , anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpGet(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_HTTPGET , anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpProxyTunnel(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_HTTPPROXYTUNNEL, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyMaxRedirs(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_MAXREDIRS , anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyNoBody(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_NOBODY , anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyPost(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_POSTFIELDSIZE, dataSizeGet(curlHandle));
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_POST, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyProxy(void) {
+ char *proxyStrPtr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ proxyStrPtr = asCString(aString);
+ if (proxyStrPtr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_PROXY, proxyStrPtr));
+ cFree(proxyStrPtr);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyProxyUserPwd(void) {
+ char *userpwdStr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ userpwdStr = asCString(aString);
+ if (userpwdStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_PROXYUSERPWD, userpwdStr));
+ cFree(userpwdStr);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasySSLVerifyPeer(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_SSL_VERIFYPEER, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyTimeout(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_TIMEOUT, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyUnEscape(void) {
+ char *unEscapedStr;
+ char *urlStrPtr;
+ unsigned resultString;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ urlStrPtr = asCString(aString);
+ if (urlStrPtr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ unEscapedStr = curl_easy_unescape(easyHandleGet(curlHandle), urlStrPtr, 0, 0);
+ cFree(urlStrPtr);
+ if (unEscapedStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ resultString = asString(unEscapedStr);
+ curl_free(unEscapedStr);
+ if (resultString == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ } else {
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(3, resultString);
+ return null;
+ }
+}
+
+EXPORT(sqInt) primEasyUnrestrictedAuth(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_UNRESTRICTED_AUTH, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyUpload(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_INFILESIZE, dataSizeGet(curlHandle));
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_UPLOAD, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyUrl(void) {
+ char *urlStrPtr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ urlStrPtr = asCString(aString);
+ if (urlStrPtr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ urlSet(curlHandle, urlStrPtr);
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_URL, urlStrPtr));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyUserPwd(void) {
+ char *userpwdStr;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ userpwdStr = asCString(aString);
+ if (userpwdStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_USERPWD, userpwdStr));
+ cFree(userpwdStr);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyVerbose(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt anInteger;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ anInteger = interpreterProxy->stackIntegerValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!((anInteger == 0) || ((anInteger & 1)))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_VERBOSE, anInteger));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpAuthAny(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ httpAuth(curlHandle, CURLAUTH_ANY);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpAuthAnySafe(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ httpAuth(curlHandle, CURLAUTH_ANYSAFE);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpAuthBasic(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ httpAuth(curlHandle, CURLAUTH_BASIC);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpAuthDigest(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ httpAuth(curlHandle, CURLAUTH_DIGEST);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpAuthNtlm(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ httpAuth(curlHandle, CURLAUTH_NTLM);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyHttpHeaders(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_setopt(easyHandleGet(curlHandle), CURLOPT_HTTPHEADER , httpHeaderGet(curlHandle)));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* execute configured easy handle in VM-blocking mode */
+
+EXPORT(sqInt) primEasyPerform(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ easyStatusSet(curlHandle, (int)curl_easy_perform( easyHandleGet(curlHandle) ));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyProxyAuthAny(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ proxyAuth(curlHandle, CURLAUTH_ANY);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyProxyAuthAnySafe(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ proxyAuth(curlHandle, CURLAUTH_ANYSAFE);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyProxyAuthBasic(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ proxyAuth(curlHandle, CURLAUTH_BASIC);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyProxyAuthDigest(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ proxyAuth(curlHandle, CURLAUTH_DIGEST);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primEasyProxyAuthNtlm(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ proxyAuth(curlHandle, CURLAUTH_NTLM);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* reset easy handle(clear all libcurl info associated with it) */
+
+EXPORT(sqInt) primEasyReset(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ curl_easy_reset( easyHandleGet(curlHandle) );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* get code of the error for the easy interface */
+
+EXPORT(sqInt) primEasyStatus(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = interpreterProxy->positive32BitIntegerFor((easyStatusGet(curlHandle)));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+
+/* get text description of the error for the easy interface */
+
+EXPORT(sqInt) primEasyStrError(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = asString((char*) curl_easy_strerror(easyStatusGet( curlHandle)));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primEmptyBuffers(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ bufChainFreeAll(curlHandle);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* fetch all buffer chain contents at once, do not free buffers */
+
+EXPORT(sqInt) primFetchBuffers(void) {
+ unsigned long dataSize;
+ dataBufferStruct* curBuffer;
+ void* dataPtr;
+ dataBufferStruct* nextBuffer;
+ int byteString;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if ((numberOfBufGet(curlHandle)) == 0) {
+ _return_value = interpreterProxy->nilObject();
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+ }
+ dataSize = dataSizeGet(curlHandle);
+
+ /* set pointer to the beginning of the data area of byteString */
+
+ byteString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), dataSize);
+
+ /* copy contents of all buffers into byte array */
+
+ dataPtr = interpreterProxy->firstIndexableField(byteString);
+ curBuffer = bufChainHeadGet(curlHandle);
+ while (curBuffer != 0) {
+ memcpy( dataPtr, dataBufDataGet(curBuffer), dataBufSizeGet(curBuffer));
+
+ /* copy the pointer to the next one from it (0-pointer there is no more buffers) */
+
+ dataPtr += dataBufSizeGet(curBuffer);
+ nextBuffer = dataBufNextGet(curBuffer);
+ curBuffer = nextBuffer;
+ }
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, byteString);
+ return null;
+}
+
+
+/* ASD */
+
+EXPORT(sqInt) primFetchNextBuffer(void) {
+ unsigned long dataSize;
+ dataBufferStruct* curBuffer;
+ int byteString;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ curBuffer = readPositionBufGet(curlHandle);
+ if (curBuffer == 0) {
+ readPositionRewind(curlHandle);
+ _return_value = interpreterProxy->nilObject();
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+ }
+ dataSize = dataBufSizeGet(curBuffer);
+
+ /* we copy our data from data part area of the buffer into the new byte array */
+
+ byteString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), dataSize);
+ memcpy( interpreterProxy->firstIndexableField(byteString), dataBufDataGet(curBuffer), dataSize );
+ readPositionBufSet(curlHandle, dataBufNextGet(curBuffer));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, byteString);
+ return null;
+}
+
+EXPORT(sqInt) primFreeCurlHandle(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ curlHandleFree(curlHandle);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+EXPORT(sqInt) primInfoConnectTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_CONNECT_TIME );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoContentLengthDownload(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoContentLengthUpload(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_CONTENT_LENGTH_UPLOAD );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoContentType(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeString(curlHandle, CURLINFO_CONTENT_TYPE );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoEffectiveUrl(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeString(curlHandle, CURLINFO_EFFECTIVE_URL );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoFileTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_FILETIME );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoFtpEntryPath(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeString(curlHandle, CURLINFO_FTP_ENTRY_PATH );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoHTTPAuthAvail(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_HTTPAUTH_AVAIL );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoHTTPConnectCode(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_HTTP_CONNECTCODE );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoHeaderSize(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_HEADER_SIZE );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoNameLookupTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_NAMELOOKUP_TIME );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoOsErrNo(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_OS_ERRNO   );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoPreTransferTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_PRETRANSFER_TIME );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoPrivate(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeString(curlHandle, CURLINFO_PRIVATE );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoProxyAuthAvail(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_PROXYAUTH_AVAIL  );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoRedirectCount(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_REDIRECT_COUNT );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoRedirectTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_REDIRECT_TIME );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoRequestSize(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_REQUEST_SIZE );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoResponseCode(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_RESPONSE_CODE );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoSSLVerifyResult(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeLong(curlHandle, CURLINFO_SSL_VERIFYRESULT );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoSizeDownload(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_SIZE_DOWNLOAD );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoSizeUpload(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_SIZE_UPLOAD );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoSpeedDownload(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_SPEED_DOWNLOAD );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoSpeedUpload(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_SPEED_UPLOAD );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoStartTransferTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_STARTTRANSFER_TIME );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primInfoTotalTime(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = getInfoTypeDouble(curlHandle, CURLINFO_TOTAL_TIME );
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+
+/* return if we have transfer in progress (otherwise multi handle has installed easy handle in it) */
+
+EXPORT(sqInt) primIsMultiRunning(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if ((isMultiRunningGet(curlHandle)) == 0) {
+ _return_value = interpreterProxy->falseObject();
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+ } else {
+ _return_value = interpreterProxy->trueObject();
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+ }
+}
+
+EXPORT(sqInt) primListAppend(void) {
+ char *theString;
+ curlStruct *curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ theString = asCString(aString);
+ if (theString == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ httpHeaderSet(curlHandle, curl_slist_append(httpHeaderGet(curlHandle), theString));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+
+/* bind the easy handle to the multi handle, this efficiently will start transfer when curl_multi_perform will be called */
+
+EXPORT(sqInt) primMultiAttach(void) {
+ CURLM* multiHandle;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ multiStatusSet(curlHandle, curl_multi_add_handle(multiHandleGet(curlHandle), easyHandleGet(curlHandle)));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* detach the easy handle from multi handle - this will stop the transfer in progress */
+
+EXPORT(sqInt) primMultiDetach(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ multiStatusSet(curlHandle, curl_multi_remove_handle(multiHandleGet(curlHandle), easyHandleGet(curlHandle)));
+ isMultiRunningSet(curlHandle, 0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* set status info for the mutli handle ,
+ currently the only useful info it can return - status of the easy transfers bound to this handle
+ we also have only one easy handle associated with the multi handle
+ all this makes decoding very easy - if there is something - return easy curl code
+ otherwise - return nil (this may mean that transfer canceled) */
+
+EXPORT(sqInt) primMultiInfoRead(void) {
+ CURLMsg* msg;
+ int msgsLeft;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ msg = curl_multi_info_read( multiHandleGet(curlHandle),   &msgsLeft);
+ if (msg == 0) {
+ null;
+ } else {
+ easyStatusSet(curlHandle, msg->data.result);
+ }
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* start or continue the transfer for the multi<-->easy association */
+
+EXPORT(sqInt) primMultiPerform(void) {
+ CURLMcode  curlCode;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ curlCode = curl_multi_perform( multiHandleGet(curlHandle), isMultiRunningPtr(curlHandle) );
+ multiStatusSet(curlHandle, curlCode);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* get code of the error for the multi interface */
+
+EXPORT(sqInt) primMultiStatus(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = interpreterProxy->signed32BitIntegerFor(multiStatusGet(curlHandle));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+
+/* get text description of the error for the multi interface */
+
+EXPORT(sqInt) primMultiStrError(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = asString((char*) curl_easy_strerror(multiStatusGet( curlHandle)));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primNewCurlHandle(void) {
+ curlStruct* curlHandle;
+ sqInt _return_value;
+
+ curlHandle = curlHandleNew();
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = asLargeIntegerCurlHandle(curlHandle);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(1, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primNumberOfBuf(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt _return_value;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ _return_value = interpreterProxy->positive32BitIntegerFor((numberOfBufGet(curlHandle)));
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primNumberOfMemChunks(void) {
+ sqInt _return_value;
+
+ _return_value = interpreterProxy->positive32BitIntegerFor(memChunks);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(1, _return_value);
+ return null;
+}
+
+EXPORT(sqInt) primReadRewind(void) {
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ readPositionRewind(curlHandle);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(1);
+ return null;
+}
+
+
+/* put aByteString into a buffer chain, delete old contents */
+
+EXPORT(sqInt) primSetBuffersData(void) {
+ void* dstPtr;
+ unsigned long dataSize;
+ void* dataPtr;
+ unsigned long dstSize;
+ curlStruct* curlHandle;
+ sqInt aLargeIntegerCurlHandle;
+ sqInt aByteString;
+
+ aLargeIntegerCurlHandle = interpreterProxy->stackValue(1);
+ aByteString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ curlHandle = asCurlHandle(aLargeIntegerCurlHandle);
+ if (curlHandle == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ if (!(interpreterProxy->isBytes(aByteString))) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ bufChainFreeAll(curlHandle);
+
+ /* set pointer to the beginning of the data area of aByteString */
+
+ dataSize = interpreterProxy->stSizeOf(aByteString);
+
+ /* while data is left continoulsy allocate buffers and fill them with data */
+
+ dataPtr = interpreterProxy->firstIndexableField(aByteString);
+ while (dataSize > 0) {
+
+ /* allocate one buffer */
+
+ dstSize = ((dataSize < (CURL_MAX_WRITE_SIZE)) ? dataSize : (CURL_MAX_WRITE_SIZE));
+ dstPtr = bufChainAddBuffer(curlHandle, dstSize);
+ if (dstPtr == 0) {
+ bufChainFreeAll(curlHandle);
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ memcpy( dstPtr, dataPtr, dstSize);
+ dataSizeSet(curlHandle, dstSize + (dataSizeGet(curlHandle)));
+ dataPtr += dstSize;
+ dataSize -= dstSize;
+ }
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->pop(2);
+ return null;
+}
+
+EXPORT(sqInt) primTimeFromString(void) {
+ char *timeStr;
+ time_t time;
+ sqInt aString;
+ sqInt _return_value;
+
+ aString = interpreterProxy->stackValue(0);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ timeStr = asCString(aString);
+ if (timeStr == 0) {
+ interpreterProxy->primitiveFail();
+ return null;
+ }
+ time = curl_getdate( timeStr, NULL);
+ cFree(timeStr);
+ _return_value = interpreterProxy->signed32BitIntegerFor(time);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->popthenPush(2, _return_value);
+ return null;
+}
+
+static sqInt proxyAuth(curlStruct* curlHandle, sqInt anInteger) {
+ easyStatusSet(curlHandle, (int)curl_easy_setopt( easyHandleGet(curlHandle), CURLOPT_PROXYAUTH, anInteger));
+}
+
+
+/* this function iterates through buffer chain and populates dataPtr with data found in buffer */
+
+static sqInt pvtReadBufferItemsofBytesUserData(void *dataPtr, unsigned items, unsigned size, curlStruct* curlHandle) {
+ void* nextBuf;
+ unsigned dataSize;
+ int unreadBytesInBuf;
+ unsigned chunkSize;
+ void* curBuf;
+ unsigned bytesRead;
+
+ if (readPositionIsAtEnd(curlHandle)) {
+ readPositionRewind(curlHandle);
+ return 0;
+ }
+ dataSize = items * size;
+
+ /*  cycle until buffers exhausted or read request satisfied */
+
+ bytesRead = 0;
+ while (1 == 1) {
+ curBuf = readPositionBufGet(curlHandle);
+ unreadBytesInBuf = (dataBufSizeGet(curBuf)) - (readPositionGet(curlHandle));
+ chunkSize = ((unreadBytesInBuf < dataSize) ? unreadBytesInBuf : dataSize);
+ memcpy( dataPtr+bytesRead, (char*)dataBufDataGet(curBuf)+ readPositionGet(curlHandle), chunkSize );
+ bytesRead += chunkSize;
+ readPositionSet(curlHandle, chunkSize + (readPositionGet(curlHandle)));
+ if (unreadBytesInBuf > dataSize) {
+ return bytesRead;
+ } else {
+ if ((nextBuf = dataBufNextGet(curBuf)) == 0) {
+ return bytesRead;
+ }
+ dataSize -= chunkSize;
+ readPositionSet(curlHandle, 0);
+ readPositionBufSet(curlHandle, nextBuf);
+ }
+ }
+}
+
+
+/* this version allocates new buffer, adds it to the chain of buffers of the curlHandle and stores the data received there */
+
+static sqInt pvtWriteNewBufferItemsofBytesUserData(void *dataPtr, unsigned items, unsigned size, curlStruct* curlHandle) {
+ void* dst;
+ unsigned byteSize;
+
+ byteSize = items * size;
+ dst = bufChainAddBuffer(curlHandle, byteSize);
+ if (dst == 0) {
+ return 0;
+ }
+ memcpy( dst, dataPtr, items*size );
+ dataSizeSet(curlHandle, byteSize + (dataSizeGet(curlHandle)));
+ return items * size;
+}
+
+static sqInt readPositionBufSet(curlStruct* curlHandle, dataBufferStruct* dataBufferStruct) {
+ curlHandle->readPositionBuf = dataBufferStruct;
+}
+
+static sqInt readPositionSet(curlStruct* curlHandle, unsigned pos) {
+ curlHandle->readPosition = pos;
+}
+
+static void* readPositionBufGet(curlStruct* curlHandle) {
+ return curlHandle->readPositionBuf;
+}
+
+static unsigned readPositionGet(curlStruct* curlHandle) {
+ return curlHandle->readPosition;
+}
+
+static int readPositionIsAtEnd(curlStruct* curlHandle) {
+ dataBufferStruct* currentBuf;
+
+ currentBuf = readPositionBufGet(curlHandle);
+ if (currentBuf == 0) {
+ return 1;
+ }
+ if ((currentBuf == 0) && ((readPositionGet(curlHandle)) == (dataBufSizeGet(currentBuf)))) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static sqInt readPositionRewind(curlStruct* curlHandle) {
+ readPositionBufSet(curlHandle, bufChainHeadGet(curlHandle));
+ readPositionSet(curlHandle, 0);
+}
+
+
+/* Note: This is coded so that is can be run from Squeak. */
+
+EXPORT(sqInt) setInterpreter(struct VirtualMachine* anInterpreter) {
+ sqInt ok;
+
+ interpreterProxy = anInterpreter;
+ ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR;
+ if (ok == 0) {
+ return 0;
+ }
+ ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR;
+ return ok;
+}
+
+EXPORT(sqInt) shutdownModule(void) {
+ curlStruct* nextHandle;
+ curlStruct* headHandle;
+
+ /* begin freeAllCurlHandles */
+ headHandle = curlHandleFirst;
+ while (headHandle != 0) {
+ nextHandle = nextHandleGet(headHandle);
+ curlHandleFree(headHandle);
+ headHandle = nextHandle;
+ }
+ curlHandleFirst = 0;
+ curlHandleLast = 0;
+ curl_share_cleanup(curlShare);
+ curl_global_cleanup();
+ return 1;
+}
+
+static sqInt sizeOfCurlStruct(void) {
+ return sizeof(curlStruct);
+}
+
+static sqInt sizeOfDataBufferStruct(void) {
+ return sizeof(dataBufferStruct);
+}
+
+static sqInt sqAssert(sqInt aBool) {
+ /* missing DebugCode */;
+}
+
+static sqInt urlSet(curlStruct* curlHandle, char*  str) {
+ urlFree(curlHandle);
+ curlHandle->url = str;
+}
+
+static sqInt urlFree(curlStruct* curlHandle) {
+ char* url;
+
+ url = curlHandle->url;
+ if (url != 0) {
+ cFree(url);
+ }
+ curlHandle->url = 0;
+}
+
+static char * urlGet(curlStruct* curlHandle) {
+ return curlHandle->url;
+}
+
+
+#ifdef SQUEAK_BUILTIN_PLUGIN
+
+
+void* CurlPlugin_exports[][3] = {
+ {"CurlPlugin", "primTimeFromString", (void*)primTimeFromString},
+ {"CurlPlugin", "primEasyTimeout", (void*)primEasyTimeout},
+ {"CurlPlugin", "primEasyHeader", (void*)primEasyHeader},
+ {"CurlPlugin", "primInfoFtpEntryPath", (void*)primInfoFtpEntryPath},
+ {"CurlPlugin", "setInterpreter", (void*)setInterpreter},
+ {"CurlPlugin", "primNumberOfBuf", (void*)primNumberOfBuf},
+ {"CurlPlugin", "primEasyProxyAuthDigest", (void*)primEasyProxyAuthDigest},
+ {"CurlPlugin", "primEasyUserPwd", (void*)primEasyUserPwd},
+ {"CurlPlugin", "primEasyCaInfo", (void*)primEasyCaInfo},
+ {"CurlPlugin", "primEasyReset", (void*)primEasyReset},
+ {"CurlPlugin", "primEasyProxyAuthAny", (void*)primEasyProxyAuthAny},
+ {"CurlPlugin", "primNumberOfMemChunks", (void*)primNumberOfMemChunks},
+ {"CurlPlugin", "primInfoRequestSize", (void*)primInfoRequestSize},
+ {"CurlPlugin", "primInfoSizeDownload", (void*)primInfoSizeDownload},
+ {"CurlPlugin", "primMultiDetach", (void*)primMultiDetach},
+ {"CurlPlugin", "primInfoProxyAuthAvail", (void*)primInfoProxyAuthAvail},
+ {"CurlPlugin", "primEasyPost", (void*)primEasyPost},
+ {"CurlPlugin", "primMultiInfoRead", (void*)primMultiInfoRead},
+ {"CurlPlugin", "primInfoSizeUpload", (void*)primInfoSizeUpload},
+ {"CurlPlugin", "primEasyProxyAuthBasic", (void*)primEasyProxyAuthBasic},
+ {"CurlPlugin", "primEasyPerform", (void*)primEasyPerform},
+ {"CurlPlugin", "primFreeCurlHandle", (void*)primFreeCurlHandle},
+ {"CurlPlugin", "primEasyAutoReferer", (void*)primEasyAutoReferer},
+ {"CurlPlugin", "primEasyHttpGet", (void*)primEasyHttpGet},
+ {"CurlPlugin", "primMultiPerform", (void*)primMultiPerform},
+ {"CurlPlugin", "initialiseModule", (void*)initialiseModule},
+ {"CurlPlugin", "primEasyFollowLocation", (void*)primEasyFollowLocation},
+ {"CurlPlugin", "primEasyProxyAuthAnySafe", (void*)primEasyProxyAuthAnySafe},
+ {"CurlPlugin", "primEasyProxy", (void*)primEasyProxy},
+ {"CurlPlugin", "primEasyMaxRedirs", (void*)primEasyMaxRedirs},
+ {"CurlPlugin", "primInfoHTTPConnectCode", (void*)primInfoHTTPConnectCode},
+ {"CurlPlugin", "primEasyCustomRequest", (void*)primEasyCustomRequest},
+ {"CurlPlugin", "primFetchBuffers", (void*)primFetchBuffers},
+ {"CurlPlugin", "primInfoEffectiveUrl", (void*)primInfoEffectiveUrl},
+ {"CurlPlugin", "primEasyHttpAuthBasic", (void*)primEasyHttpAuthBasic},
+ {"CurlPlugin", "primEasyCookieFile", (void*)primEasyCookieFile},
+ {"CurlPlugin", "primEasyUnEscape", (void*)primEasyUnEscape},
+ {"CurlPlugin", "primListAppend", (void*)primListAppend},
+ {"CurlPlugin", "primEasyDNSCacheTimeout", (void*)primEasyDNSCacheTimeout},
+ {"CurlPlugin", "primEmptyBuffers", (void*)primEmptyBuffers},
+ {"CurlPlugin", "primEasyProxyAuthNtlm", (void*)primEasyProxyAuthNtlm},
+ {"CurlPlugin", "primEasyStatus", (void*)primEasyStatus},
+ {"CurlPlugin", "primEasyCookieJar", (void*)primEasyCookieJar},
+ {"CurlPlugin", "primInfoNameLookupTime", (void*)primInfoNameLookupTime},
+ {"CurlPlugin", "primReadRewind", (void*)primReadRewind},
+ {"CurlPlugin", "primEasyHttpHeaders", (void*)primEasyHttpHeaders},
+ {"CurlPlugin", "primInfoContentType", (void*)primInfoContentType},
+ {"CurlPlugin", "primEasyUpload", (void*)primEasyUpload},
+ {"CurlPlugin", "primInfoSpeedDownload", (void*)primInfoSpeedDownload},
+ {"CurlPlugin", "primInfoContentLengthUpload", (void*)primInfoContentLengthUpload},
+ {"CurlPlugin", "primInfoResponseCode", (void*)primInfoResponseCode},
+ {"CurlPlugin", "primMultiAttach", (void*)primMultiAttach},
+ {"CurlPlugin", "primEasyVerbose", (void*)primEasyVerbose},
+ {"CurlPlugin", "primEasyFailOnError", (void*)primEasyFailOnError},
+ {"CurlPlugin", "primIsMultiRunning", (void*)primIsMultiRunning},
+ {"CurlPlugin", "primInfoOsErrNo", (void*)primInfoOsErrNo},
+ {"CurlPlugin", "primSetBuffersData", (void*)primSetBuffersData},
+ {"CurlPlugin", "primInfoConnectTime", (void*)primInfoConnectTime},
+ {"CurlPlugin", "primInfoSSLVerifyResult", (void*)primInfoSSLVerifyResult},
+ {"CurlPlugin", "primEasyUnrestrictedAuth", (void*)primEasyUnrestrictedAuth},
+ {"CurlPlugin", "primCurlVersion", (void*)primCurlVersion},
+ {"CurlPlugin", "shutdownModule", (void*)shutdownModule},
+ {"CurlPlugin", "primFetchNextBuffer", (void*)primFetchNextBuffer},
+ {"CurlPlugin", "primEasyHttpAuthAny", (void*)primEasyHttpAuthAny},
+ {"CurlPlugin", "primEasyHttpAuthNtlm", (void*)primEasyHttpAuthNtlm},
+ {"CurlPlugin", "primInfoTotalTime", (void*)primInfoTotalTime},
+ {"CurlPlugin", "primEasyProxyUserPwd", (void*)primEasyProxyUserPwd},
+ {"CurlPlugin", "primEasyHttpProxyTunnel", (void*)primEasyHttpProxyTunnel},
+ {"CurlPlugin", "primInfoPrivate", (void*)primInfoPrivate},
+ {"CurlPlugin", "primInfoHTTPAuthAvail", (void*)primInfoHTTPAuthAvail},
+ {"CurlPlugin", "primEasyStrError", (void*)primEasyStrError},
+ {"CurlPlugin", "primInfoRedirectCount", (void*)primInfoRedirectCount},
+ {"CurlPlugin", "primInfoHeaderSize", (void*)primInfoHeaderSize},
+ {"CurlPlugin", "primDataSize", (void*)primDataSize},
+ {"CurlPlugin", "primInfoContentLengthDownload", (void*)primInfoContentLengthDownload},
+ {"CurlPlugin", "primMultiStatus", (void*)primMultiStatus},
+ {"CurlPlugin", "primEasyUrl", (void*)primEasyUrl},
+ {"CurlPlugin", "primInfoFileTime", (void*)primInfoFileTime},
+ {"CurlPlugin", "getModuleName", (void*)getModuleName},
+ {"CurlPlugin", "primNewCurlHandle", (void*)primNewCurlHandle},
+ {"CurlPlugin", "primEasyFileTime", (void*)primEasyFileTime},
+ {"CurlPlugin", "primMultiStrError", (void*)primMultiStrError},
+ {"CurlPlugin", "primEasyHttpAuthAnySafe", (void*)primEasyHttpAuthAnySafe},
+ {"CurlPlugin", "primEasyEscape", (void*)primEasyEscape},
+ {"CurlPlugin", "primEasyCookieSession", (void*)primEasyCookieSession},
+ {"CurlPlugin", "primEasyCookie", (void*)primEasyCookie},
+ {"CurlPlugin", "primEasySSLVerifyPeer", (void*)primEasySSLVerifyPeer},
+ {"CurlPlugin", "primInfoRedirectTime", (void*)primInfoRedirectTime},
+ {"CurlPlugin", "primInfoStartTransferTime", (void*)primInfoStartTransferTime},
+ {"CurlPlugin", "primInfoPreTransferTime", (void*)primInfoPreTransferTime},
+ {"CurlPlugin", "primInfoSpeedUpload", (void*)primInfoSpeedUpload},
+ {"CurlPlugin", "primEasyHttpAuthDigest", (void*)primEasyHttpAuthDigest},
+ {"CurlPlugin", "primEasyNoBody", (void*)primEasyNoBody},
+ {NULL, NULL, NULL}
+};
+
+
+#endif /* ifdef SQ_BUILTIN_PLUGIN */
+
diff --git a/platforms/unix/plugins/CurlPlugin/Makefile.inc b/platforms/unix/plugins/CurlPlugin/Makefile.inc
new file mode 100644
index 0000000..ed41bec
--- /dev/null
+++ b/platforms/unix/plugins/CurlPlugin/Makefile.inc
@@ -0,0 +1 @@
+PLIBS = -lcurl
diff --git a/platforms/unix/plugins/CurlPlugin/config.cmake b/platforms/unix/plugins/CurlPlugin/config.cmake
new file mode 100644
index 0000000..6eff9f0
--- /dev/null
+++ b/platforms/unix/plugins/CurlPlugin/config.cmake
@@ -0,0 +1,3 @@
+PLUGIN_REQUIRE_LIBRARY(CURL curl)
+
+
diff --git a/platforms/unix/src/plugins.ext b/platforms/unix/src/plugins.ext
index 096e7ed..2456ae9 100644
--- a/platforms/unix/src/plugins.ext
+++ b/platforms/unix/src/plugins.ext
@@ -1,2 +1,2 @@
 # Automatically generated makefile include for external plugins
-EXTERNAL_PLUGINS = B3DAcceleratorPlugin Squeak3D ClipboardExtendedPlugin DBusPlugin SqueakFFIPrims FileCopyPlugin GStreamerPlugin HostWindowPlugin ImmX11Plugin KedamaPlugin KedamaPlugin2 MIDIPlugin Mpeg3Plugin OggPlugin PseudoTTYPlugin RomePlugin UUIDPlugin AioPlugin UnixOSProcessPlugin XDisplayControlPlugin
+EXTERNAL_PLUGINS = CurlPlugin B3DAcceleratorPlugin Squeak3D ClipboardExtendedPlugin DBusPlugin SqueakFFIPrims FileCopyPlugin GStreamerPlugin HostWindowPlugin ImmX11Plugin KedamaPlugin KedamaPlugin2 MIDIPlugin Mpeg3Plugin OggPlugin PseudoTTYPlugin RomePlugin UUIDPlugin AioPlugin UnixOSProcessPlugin XDisplayControlPlugin


CurlPlugin-23.tgz (14K) Download Attachment