1414#include <xmlsec/xmlsec.h>
1515#include <xmlsec/crypto.h>
1616#include <xmlsec/errors.h>
17+ #include <xmlsec/base64.h>
1718
1819#define _PYXMLSEC_FREE_NONE 0
1920#define _PYXMLSEC_FREE_XMLSEC 1
@@ -127,6 +128,34 @@ static PyObject* PyXmlSec_PyEnableDebugOutput(PyObject *self, PyObject* args, Py
127128 Py_RETURN_NONE ;
128129}
129130
131+ static char PyXmlSec_PyBase64DefaultLineSize__doc__ [] = \
132+ "base64_default_line_size(size = None)\n"
133+ "Configures the default maximum columns size for base64 encoding.\n\n"
134+ "If ``size`` is not given, this function returns the current default size, acting as a getter. "
135+ "If ``size`` is given, a new value is applied and this function returns nothing, acting as a setter.\n"
136+ ":param size: new default size value (optional)\n"
137+ ":type size: :class:`int` or :data:`None`" ;
138+ static PyObject * PyXmlSec_PyBase64DefaultLineSize (PyObject * self , PyObject * args , PyObject * kwargs ) {
139+ static char * kwlist [] = { "size" , NULL };
140+ PyObject * pySize = NULL ;
141+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "|O:base64_default_line_size" , kwlist , & pySize )) {
142+ return NULL ;
143+ }
144+ if (pySize == NULL ) {
145+ return PyLong_FromLong (xmlSecBase64GetDefaultLineSize ());
146+ }
147+ int size = (int )PyLong_AsLong (pySize );
148+ if (PyErr_Occurred ()) {
149+ return NULL ;
150+ }
151+ if (size < 0 ) {
152+ PyErr_SetString (PyExc_ValueError , "size must be positive" );
153+ return NULL ;
154+ }
155+ xmlSecBase64SetDefaultLineSize (size );
156+ Py_RETURN_NONE ;
157+ }
158+
130159static PyMethodDef PyXmlSec_MainMethods [] = {
131160 {
132161 "init" ,
@@ -146,6 +175,12 @@ static PyMethodDef PyXmlSec_MainMethods[] = {
146175 METH_VARARGS |METH_KEYWORDS ,
147176 PyXmlSec_PyEnableDebugOutput__doc__
148177 },
178+ {
179+ "base64_default_line_size" ,
180+ (PyCFunction )PyXmlSec_PyBase64DefaultLineSize ,
181+ METH_VARARGS |METH_KEYWORDS ,
182+ PyXmlSec_PyBase64DefaultLineSize__doc__
183+ },
149184 {NULL , NULL } /* sentinel */
150185};
151186
0 commit comments