Пример #1
0
PyObject *xmlsec_BufferBase64NodeContentWrite(PyObject *self, PyObject *args) {
  PyObject *buf_obj, *node_obj;
  xmlSecBufferPtr buf;
  xmlNodePtr node;
  int columns;

  if (CheckArgs(args, "OO:bufferBase64NodeContentWrite")) {
    if (!PyArg_ParseTuple(args, "OO:bufferBase64NodeContentWrite", &buf_obj,
			  &node_obj, &columns))
      return NULL;
  }
  else return NULL;

  buf = xmlSecBufferPtr_get(buf_obj);
  node = xmlNodePtr_get(node_obj);

  return (wrap_int(xmlSecBufferBase64NodeContentWrite(buf, node, columns)));
}
Пример #2
0
/**
 * xmlSecBnSetNodeValue:
 * @bn:			the pointer to BN.
 * @cur:		the poitner to an XML node.
 * @format:		the BN format.
 * @reverse:		the flag that indicates whether to reverse the buffer before writing.
 * @addLineBreaks:  	the flag; it is equal to 1 then linebreaks will be added before and after new buffer content.
 *
 * Converts the @bn and sets it to node content.
 *
 * Returns 0 on success and a negative values if an error occurs.
 */
EXPORT_C
int  
xmlSecBnSetNodeValue(xmlSecBnPtr bn, xmlNodePtr cur, xmlSecBnFormat format, int reverse, int addLineBreaks) {
    xmlChar* content;
    int ret;

    xmlSecAssert2(bn != NULL, -1);
    xmlSecAssert2(cur != NULL, -1);

    if(reverse != 0) {
    	ret = xmlSecBnReverse(bn);
	if(ret < 0) {
	    xmlSecError(XMLSEC_ERRORS_HERE,
			NULL,
			"xmlSecBnReverse",
	    		XMLSEC_ERRORS_R_XMLSEC_FAILED,
			XMLSEC_ERRORS_NO_MESSAGE);
	    return(-1);
	}
    }

    if(addLineBreaks) {
	xmlNodeAddContent(cur, xmlSecStringCR);
    }

    switch(format) {
    case xmlSecBnBase64:
	ret = xmlSecBufferBase64NodeContentWrite(bn, cur, XMLSEC_BASE64_LINESIZE);
	if(ret < 0) {
	    xmlSecError(XMLSEC_ERRORS_HERE,
			NULL,
			"xmlSecBufferBase64NodeContentWrite",
	    		XMLSEC_ERRORS_R_XMLSEC_FAILED,
			XMLSEC_ERRORS_NO_MESSAGE);
	    return(-1);
	}
	break;
    case xmlSecBnHex:
	content = xmlSecBnToHexString(bn);
	if(content == NULL) {
	    xmlSecError(XMLSEC_ERRORS_HERE,
			NULL,
			"xmlSecBnToHexString",
	    		XMLSEC_ERRORS_R_XMLSEC_FAILED,
			XMLSEC_ERRORS_NO_MESSAGE);
	    xmlFree(content);
	    return(-1);
	}
	xmlNodeSetContent(cur, content);
	xmlFree(content);
	break;
    case xmlSecBnDec:
	content = xmlSecBnToDecString(bn);
	if(content == NULL) {
	    xmlSecError(XMLSEC_ERRORS_HERE,
			NULL,
			"xmlSecBnToDecString",
	    		XMLSEC_ERRORS_R_XMLSEC_FAILED,
			XMLSEC_ERRORS_NO_MESSAGE);
	    xmlFree(content);
	    return(-1);
	}
	xmlNodeSetContent(cur, content);
	xmlFree(content);
	break;
    }

    if(addLineBreaks) {
	xmlNodeAddContent(cur, xmlSecStringCR);
    }

    return(0);
}