diff options
author | Anas Nashif <anas.nashif@intel.com> | 2013-09-20 04:45:41 -0400 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-09-20 04:45:41 -0400 |
commit | 6b6383d52bc147134bb6b60b07e924b176c67e3a (patch) | |
tree | 9753a1ec40b1fbe2acfaa881af46e3c0f7da6401 /src/io.c | |
parent | 07bb297329b9e9754d09dcb6d70417272a626619 (diff) | |
download | xmlsec1-6b6383d52bc147134bb6b60b07e924b176c67e3a.tar.gz xmlsec1-6b6383d52bc147134bb6b60b07e924b176c67e3a.tar.bz2 xmlsec1-6b6383d52bc147134bb6b60b07e924b176c67e3a.zip |
Imported Upstream version 1.2.19
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 368 |
1 files changed, 184 insertions, 184 deletions
@@ -1,17 +1,17 @@ -/** +/** * XML Security Library (http://www.aleksey.com/xmlsec). * * Input uri transform and utility functions. * * This is free software; see Copyright file in the source * distribution for preciese wording. - * + * * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com> */ #include "globals.h" #include <stdlib.h> -#include <string.h> +#include <string.h> #include <errno.h> #include <libxml/uri.h> @@ -22,7 +22,7 @@ #include <libxml/nanohttp.h> #endif /* LIBXML_HTTP_ENABLED */ -#ifdef LIBXML_FTP_ENABLED +#ifdef LIBXML_FTP_ENABLED #include <libxml/nanoftp.h> #endif /* LIBXML_FTP_ENABLED */ @@ -45,46 +45,46 @@ typedef struct _xmlSecIOCallback { xmlInputCloseCallback closecallback; } xmlSecIOCallback, *xmlSecIOCallbackPtr; -static xmlSecIOCallbackPtr xmlSecIOCallbackCreate (xmlInputMatchCallback matchFunc, - xmlInputOpenCallback openFunc, - xmlInputReadCallback readFunc, - xmlInputCloseCallback closeFunc); -static void xmlSecIOCallbackDestroy (xmlSecIOCallbackPtr callbacks); +static xmlSecIOCallbackPtr xmlSecIOCallbackCreate (xmlInputMatchCallback matchFunc, + xmlInputOpenCallback openFunc, + xmlInputReadCallback readFunc, + xmlInputCloseCallback closeFunc); +static void xmlSecIOCallbackDestroy (xmlSecIOCallbackPtr callbacks); -static xmlSecIOCallbackPtr -xmlSecIOCallbackCreate(xmlInputMatchCallback matchFunc, xmlInputOpenCallback openFunc, - xmlInputReadCallback readFunc, xmlInputCloseCallback closeFunc) { +static xmlSecIOCallbackPtr +xmlSecIOCallbackCreate(xmlInputMatchCallback matchFunc, xmlInputOpenCallback openFunc, + xmlInputReadCallback readFunc, xmlInputCloseCallback closeFunc) { xmlSecIOCallbackPtr callbacks; - + xmlSecAssert2(matchFunc != NULL, NULL); - + /* Allocate a new xmlSecIOCallback and fill the fields. */ callbacks = (xmlSecIOCallbackPtr)xmlMalloc(sizeof(xmlSecIOCallback)); if(callbacks == NULL) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - NULL, - XMLSEC_ERRORS_R_MALLOC_FAILED, - "sizeof(xmlSecIOCallback)=%d", - sizeof(xmlSecIOCallback)); - return(NULL); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + NULL, + XMLSEC_ERRORS_R_MALLOC_FAILED, + "sizeof(xmlSecIOCallback)=%d", + sizeof(xmlSecIOCallback)); + return(NULL); } - memset(callbacks, 0, sizeof(xmlSecIOCallback)); + memset(callbacks, 0, sizeof(xmlSecIOCallback)); callbacks->matchcallback = matchFunc; callbacks->opencallback = openFunc; callbacks->readcallback = readFunc; callbacks->closecallback = closeFunc; - + return(callbacks); } -static void +static void xmlSecIOCallbackDestroy(xmlSecIOCallbackPtr callbacks) { xmlSecAssert(callbacks != NULL); - memset(callbacks, 0, sizeof(xmlSecIOCallback)); - xmlFree(callbacks); + memset(callbacks, 0, sizeof(xmlSecIOCallback)); + xmlFree(callbacks); } /******************************************************************* @@ -94,30 +94,30 @@ xmlSecIOCallbackDestroy(xmlSecIOCallbackPtr callbacks) { ******************************************************************/ static xmlSecPtrListKlass xmlSecIOCallbackPtrListKlass = { BAD_CAST "io-callbacks-list", - NULL, /* xmlSecPtrDuplicateItemMethod duplicateItem; */ + NULL, /* xmlSecPtrDuplicateItemMethod duplicateItem; */ (xmlSecPtrDestroyItemMethod)xmlSecIOCallbackDestroy,/* xmlSecPtrDestroyItemMethod destroyItem; */ - NULL, /* xmlSecPtrDebugDumpItemMethod debugDumpItem; */ - NULL /* xmlSecPtrDebugDumpItemMethod debugXmlDumpItem; */ + NULL, /* xmlSecPtrDebugDumpItemMethod debugDumpItem; */ + NULL /* xmlSecPtrDebugDumpItemMethod debugXmlDumpItem; */ }; -#define xmlSecIOCallbackPtrListId xmlSecIOCallbackPtrListGetKlass () -static xmlSecPtrListId xmlSecIOCallbackPtrListGetKlass (void); -static xmlSecIOCallbackPtr xmlSecIOCallbackPtrListFind (xmlSecPtrListPtr list, - const char* uri); +#define xmlSecIOCallbackPtrListId xmlSecIOCallbackPtrListGetKlass () +static xmlSecPtrListId xmlSecIOCallbackPtrListGetKlass (void); +static xmlSecIOCallbackPtr xmlSecIOCallbackPtrListFind (xmlSecPtrListPtr list, + const char* uri); /** - * xmlSecIOCallbackPtrListGetKlass: + * xmlSecIOCallbackPtrListGetKlass: * * The keys list klass. * * Returns: keys list id. */ -static xmlSecPtrListId +static xmlSecPtrListId xmlSecIOCallbackPtrListGetKlass(void) { return(&xmlSecIOCallbackPtrListKlass); } -static xmlSecIOCallbackPtr +static xmlSecIOCallbackPtr xmlSecIOCallbackPtrListFind(xmlSecPtrListPtr list, const char* uri) { xmlSecIOCallbackPtr callbacks; xmlSecSize i, size; @@ -127,13 +127,13 @@ xmlSecIOCallbackPtrListFind(xmlSecPtrListPtr list, const char* uri) { size = xmlSecPtrListGetSize(list); for(i = 0; i < size; ++i) { - callbacks = (xmlSecIOCallbackPtr)xmlSecPtrListGetItem(list, i); - xmlSecAssert2(callbacks != NULL, NULL); - xmlSecAssert2(callbacks->matchcallback != NULL, NULL); - - if((callbacks->matchcallback(uri)) != 0) { - return(callbacks); - } + callbacks = (xmlSecIOCallbackPtr)xmlSecPtrListGetItem(list, i); + xmlSecAssert2(callbacks != NULL, NULL); + xmlSecAssert2(callbacks->matchcallback != NULL, NULL); + + if((callbacks->matchcallback(uri)) != 0) { + return(callbacks); + } } return(NULL); } @@ -147,18 +147,18 @@ static xmlSecPtrList xmlSecAllIOCallbacks; * Applications should not call this function directly. * * Returns: 0 on success or a negative value otherwise. - */ + */ int -xmlSecIOInit(void) { +xmlSecIOInit(void) { int ret; - + ret = xmlSecPtrListInitialize(&xmlSecAllIOCallbacks, xmlSecIOCallbackPtrListId); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecPtrListPtrInitialize", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecPtrListPtrInitialize", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); return(-1); } @@ -166,9 +166,9 @@ xmlSecIOInit(void) { xmlNanoHTTPInit(); #endif /* LIBXML_HTTP_ENABLED */ -#ifdef LIBXML_FTP_ENABLED +#ifdef LIBXML_FTP_ENABLED xmlNanoFTPInit(); -#endif /* LIBXML_FTP_ENABLED */ +#endif /* LIBXML_FTP_ENABLED */ return(xmlSecIORegisterDefaultCallbacks()); } @@ -178,7 +178,7 @@ xmlSecIOInit(void) { * * The IO clenaup (called from #xmlSecShutdown function). * Applications should not call this function directly. - */ + */ void xmlSecIOShutdown(void) { @@ -186,9 +186,9 @@ xmlSecIOShutdown(void) { xmlNanoHTTPCleanup(); #endif /* LIBXML_HTTP_ENABLED */ -#ifdef LIBXML_FTP_ENABLED +#ifdef LIBXML_FTP_ENABLED xmlNanoFTPCleanup(); -#endif /* LIBXML_FTP_ENABLED */ +#endif /* LIBXML_FTP_ENABLED */ xmlSecPtrListFinalize(&xmlSecAllIOCallbacks); } @@ -197,7 +197,7 @@ xmlSecIOShutdown(void) { * xmlSecIOCleanupCallbacks: * * Clears the entire input callback table. this includes the - * compiled-in I/O. + * compiled-in I/O. */ void xmlSecIOCleanupCallbacks(void) { @@ -206,10 +206,10 @@ xmlSecIOCleanupCallbacks(void) { /** * xmlSecIORegisterCallbacks: - * @matchFunc: the protocol match callback. - * @openFunc: the open stream callback. - * @readFunc: the read from stream callback. - * @closeFunc: the close stream callback. + * @matchFunc: the protocol match callback. + * @openFunc: the open stream callback. + * @readFunc: the read from stream callback. + * @closeFunc: the close stream callback. * * Register a new set of I/O callback for handling parser input. * @@ -217,32 +217,32 @@ xmlSecIOCleanupCallbacks(void) { */ int xmlSecIORegisterCallbacks(xmlInputMatchCallback matchFunc, - xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc, - xmlInputCloseCallback closeFunc) { + xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc, + xmlInputCloseCallback closeFunc) { xmlSecIOCallbackPtr callbacks; int ret; - + xmlSecAssert2(matchFunc != NULL, -1); - + callbacks = xmlSecIOCallbackCreate(matchFunc, openFunc, readFunc, closeFunc); if(callbacks == NULL) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecIOCallbackCreate", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); - return(-1); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecIOCallbackCreate", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); + return(-1); } - + ret = xmlSecPtrListAdd(&xmlSecAllIOCallbacks, callbacks); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecPtrListAdd", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); - xmlSecIOCallbackDestroy(callbacks); - return(-1); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecPtrListAdd", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); + xmlSecIOCallbackDestroy(callbacks); + return(-1); } return(0); } @@ -258,42 +258,42 @@ xmlSecIORegisterCallbacks(xmlInputMatchCallback matchFunc, int xmlSecIORegisterDefaultCallbacks(void) { int ret; - + #ifdef LIBXML_HTTP_ENABLED ret = xmlSecIORegisterCallbacks(xmlIOHTTPMatch, xmlIOHTTPOpen, - xmlIOHTTPRead, xmlIOHTTPClose); + xmlIOHTTPRead, xmlIOHTTPClose); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecIORegisterCallbacks", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - "http"); - return(-1); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecIORegisterCallbacks", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + "http"); + return(-1); } #endif /* LIBXML_HTTP_ENABLED */ #ifdef LIBXML_FTP_ENABLED ret = xmlSecIORegisterCallbacks(xmlIOFTPMatch, xmlIOFTPOpen, - xmlIOFTPRead, xmlIOFTPClose); + xmlIOFTPRead, xmlIOFTPClose); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecIORegisterCallbacks", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - "ftp"); - return(-1); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecIORegisterCallbacks", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + "ftp"); + return(-1); } #endif /* LIBXML_FTP_ENABLED */ ret = xmlSecIORegisterCallbacks(xmlFileMatch, xmlFileOpen, - xmlFileRead, xmlFileClose); + xmlFileRead, xmlFileClose); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecIORegisterCallbacks", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - "file"); - return(-1); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecIORegisterCallbacks", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + "file"); + return(-1); } return(0); @@ -301,60 +301,60 @@ xmlSecIORegisterDefaultCallbacks(void) { - + /************************************************************** * * Input URI Transform * * xmlSecInputURICtx is located after xmlSecTransform - * + * **************************************************************/ -typedef struct _xmlSecInputURICtx xmlSecInputURICtx, - *xmlSecInputURICtxPtr; +typedef struct _xmlSecInputURICtx xmlSecInputURICtx, + *xmlSecInputURICtxPtr; struct _xmlSecInputURICtx { - xmlSecIOCallbackPtr clbks; - void* clbksCtx; + xmlSecIOCallbackPtr clbks; + void* clbksCtx; }; #define xmlSecTransformInputUriSize \ - (sizeof(xmlSecTransform) + sizeof(xmlSecInputURICtx)) + (sizeof(xmlSecTransform) + sizeof(xmlSecInputURICtx)) #define xmlSecTransformInputUriGetCtx(transform) \ ((xmlSecTransformCheckSize((transform), xmlSecTransformInputUriSize)) ? \ - (xmlSecInputURICtxPtr)(((xmlSecByte*)(transform)) + sizeof(xmlSecTransform)) : \ - (xmlSecInputURICtxPtr)NULL) + (xmlSecInputURICtxPtr)(((xmlSecByte*)(transform)) + sizeof(xmlSecTransform)) : \ + (xmlSecInputURICtxPtr)NULL) -static int xmlSecTransformInputURIInitialize (xmlSecTransformPtr transform); -static void xmlSecTransformInputURIFinalize (xmlSecTransformPtr transform); -static int xmlSecTransformInputURIPopBin (xmlSecTransformPtr transform, - xmlSecByte* data, - xmlSecSize maxDataSize, - xmlSecSize* dataSize, - xmlSecTransformCtxPtr transformCtx); +static int xmlSecTransformInputURIInitialize (xmlSecTransformPtr transform); +static void xmlSecTransformInputURIFinalize (xmlSecTransformPtr transform); +static int xmlSecTransformInputURIPopBin (xmlSecTransformPtr transform, + xmlSecByte* data, + xmlSecSize maxDataSize, + xmlSecSize* dataSize, + xmlSecTransformCtxPtr transformCtx); static xmlSecTransformKlass xmlSecTransformInputURIKlass = { /* klass/object sizes */ - sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */ - xmlSecTransformInputUriSize, /* xmlSecSize objSize */ - - BAD_CAST "input-uri", /* const xmlChar* name; */ - NULL, /* const xmlChar* href; */ - 0, /* xmlSecAlgorithmUsage usage; */ - - xmlSecTransformInputURIInitialize, /* xmlSecTransformInitializeMethod initialize; */ - xmlSecTransformInputURIFinalize, /* xmlSecTransformFinalizeMethod finalize; */ - NULL, /* xmlSecTransformNodeReadMethod readNode; */ - NULL, /* xmlSecTransformNodeWriteMethod writeNode; */ - NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */ - NULL, /* xmlSecTransformSetKeyMethod setKey; */ - NULL, /* xmlSecTransformValidateMethod validate; */ - xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */ - NULL, /* xmlSecTransformPushBinMethod pushBin; */ - xmlSecTransformInputURIPopBin, /* xmlSecTransformPopBinMethod popBin; */ - NULL, /* xmlSecTransformPushXmlMethod pushXml; */ - NULL, /* xmlSecTransformPopXmlMethod popXml; */ - NULL, /* xmlSecTransformExecuteMethod execute; */ - - NULL, /* void* reserved0; */ - NULL, /* void* reserved1; */ + sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */ + xmlSecTransformInputUriSize, /* xmlSecSize objSize */ + + BAD_CAST "input-uri", /* const xmlChar* name; */ + NULL, /* const xmlChar* href; */ + 0, /* xmlSecAlgorithmUsage usage; */ + + xmlSecTransformInputURIInitialize, /* xmlSecTransformInitializeMethod initialize; */ + xmlSecTransformInputURIFinalize, /* xmlSecTransformFinalizeMethod finalize; */ + NULL, /* xmlSecTransformNodeReadMethod readNode; */ + NULL, /* xmlSecTransformNodeWriteMethod writeNode; */ + NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */ + NULL, /* xmlSecTransformSetKeyMethod setKey; */ + NULL, /* xmlSecTransformValidateMethod validate; */ + xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */ + NULL, /* xmlSecTransformPushBinMethod pushBin; */ + xmlSecTransformInputURIPopBin, /* xmlSecTransformPopBinMethod popBin; */ + NULL, /* xmlSecTransformPushXmlMethod pushXml; */ + NULL, /* xmlSecTransformPopXmlMethod popXml; */ + NULL, /* xmlSecTransformExecuteMethod execute; */ + + NULL, /* void* reserved0; */ + NULL, /* void* reserved1; */ }; /** @@ -364,15 +364,15 @@ static xmlSecTransformKlass xmlSecTransformInputURIKlass = { * * Returns: input URI transform id. */ -xmlSecTransformId +xmlSecTransformId xmlSecTransformInputURIGetKlass(void) { return(&xmlSecTransformInputURIKlass); } -/** +/** * xmlSecTransformInputURIOpen: - * @transform: the pointer to IO transform. - * @uri: the URL to open. + * @transform: the pointer to IO transform. + * @uri: the URL to open. * * Opens the given @uri for reading. * @@ -381,7 +381,7 @@ xmlSecTransformInputURIGetKlass(void) { int xmlSecTransformInputURIOpen(xmlSecTransformPtr transform, const xmlChar *uri) { xmlSecInputURICtxPtr ctx; - + xmlSecAssert2(xmlSecTransformCheckId(transform, xmlSecTransformInputURIId), -1); xmlSecAssert2(uri != NULL, -1); @@ -396,16 +396,16 @@ xmlSecTransformInputURIOpen(xmlSecTransformPtr transform, const xmlChar *uri) { * try with an unescaped version of the uri */ if(ctx->clbks == NULL) { - char *unescaped; - + char *unescaped; + unescaped = xmlURIUnescapeString((char*)uri, 0, NULL); - if (unescaped != NULL) { - ctx->clbks = xmlSecIOCallbackPtrListFind(&xmlSecAllIOCallbacks, unescaped); - if(ctx->clbks != NULL) { - ctx->clbksCtx = ctx->clbks->opencallback(unescaped); - } - xmlFree(unescaped); - } + if (unescaped != NULL) { + ctx->clbks = xmlSecIOCallbackPtrListFind(&xmlSecAllIOCallbacks, unescaped); + if(ctx->clbks != NULL) { + ctx->clbksCtx = ctx->clbks->opencallback(unescaped); + } + xmlFree(unescaped); + } } /* @@ -413,23 +413,23 @@ xmlSecTransformInputURIOpen(xmlSecTransformPtr transform, const xmlChar *uri) { * filename */ if (ctx->clbks == NULL) { - ctx->clbks = xmlSecIOCallbackPtrListFind(&xmlSecAllIOCallbacks, (char*)uri); - if(ctx->clbks != NULL) { - ctx->clbksCtx = ctx->clbks->opencallback((char*)uri); - } + ctx->clbks = xmlSecIOCallbackPtrListFind(&xmlSecAllIOCallbacks, (char*)uri); + if(ctx->clbks != NULL) { + ctx->clbksCtx = ctx->clbks->opencallback((char*)uri); + } } if((ctx->clbks == NULL) || (ctx->clbksCtx == NULL)) { - xmlSecError(XMLSEC_ERRORS_HERE, - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)), - "opencallback", - XMLSEC_ERRORS_R_IO_FAILED, - "uri=%s;errno=%d", - xmlSecErrorsSafeString(uri), - errno); - return(-1); + xmlSecError(XMLSEC_ERRORS_HERE, + xmlSecErrorsSafeString(xmlSecTransformGetName(transform)), + "opencallback", + XMLSEC_ERRORS_R_IO_FAILED, + "uri=%s;errno=%d", + xmlSecErrorsSafeString(uri), + errno); + return(-1); } - + return(0); } @@ -441,7 +441,7 @@ xmlSecTransformInputURIInitialize(xmlSecTransformPtr transform) { ctx = xmlSecTransformInputUriGetCtx(transform); xmlSecAssert2(ctx != NULL, -1); - + memset(ctx, 0, sizeof(xmlSecInputURICtx)); return(0); } @@ -456,19 +456,19 @@ xmlSecTransformInputURIFinalize(xmlSecTransformPtr transform) { xmlSecAssert(ctx != NULL); if((ctx->clbksCtx != NULL) && (ctx->clbks != NULL) && (ctx->clbks->closecallback != NULL)) { - (ctx->clbks->closecallback)(ctx->clbksCtx); + (ctx->clbks->closecallback)(ctx->clbksCtx); } memset(ctx, 0, sizeof(xmlSecInputURICtx)); } -static int +static int xmlSecTransformInputURIPopBin(xmlSecTransformPtr transform, xmlSecByte* data, - xmlSecSize maxDataSize, xmlSecSize* dataSize, - xmlSecTransformCtxPtr transformCtx) { + xmlSecSize maxDataSize, xmlSecSize* dataSize, + xmlSecTransformCtxPtr transformCtx) { xmlSecInputURICtxPtr ctx; int ret; - + xmlSecAssert2(xmlSecTransformCheckId(transform, xmlSecTransformInputURIId), -1); xmlSecAssert2(data != NULL, -1); xmlSecAssert2(dataSize != NULL, -1); @@ -476,20 +476,20 @@ xmlSecTransformInputURIPopBin(xmlSecTransformPtr transform, xmlSecByte* data, ctx = xmlSecTransformInputUriGetCtx(transform); xmlSecAssert2(ctx != NULL, -1); - + if((ctx->clbksCtx != NULL) && (ctx->clbks != NULL) && (ctx->clbks->readcallback != NULL)) { ret = (ctx->clbks->readcallback)(ctx->clbksCtx, (char*)data, (int)maxDataSize); - if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)), - "readcallback", - XMLSEC_ERRORS_R_IO_FAILED, - "errno=%d", errno); - return(-1); - } - (*dataSize) = ret; + if(ret < 0) { + xmlSecError(XMLSEC_ERRORS_HERE, + xmlSecErrorsSafeString(xmlSecTransformGetName(transform)), + "readcallback", + XMLSEC_ERRORS_R_IO_FAILED, + "errno=%d", errno); + return(-1); + } + (*dataSize) = ret; } else { - (*dataSize) = 0; + (*dataSize) = 0; } return(0); } |