-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathparser.c
87 lines (72 loc) · 2.48 KB
/
parser.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* $Id: parser.c 363 2006-01-01 18:03:07Z valos $
*
* PyXMLSec - Python bindings for XML Security library (XMLSec)
*
* Copyright (C) 2003 Easter-eggs, Valery Febvre
* http://pyxmlsec.labs.libre-entreprise.org/
*
* Author: Valery Febvre <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "xmlsecmod.h"
#include "parser.h"
#include "transforms.h"
PyObject *xmlsec_ParseFile(PyObject *self, PyObject *args) {
const char *filename;
xmlDocPtr doc;
if (CheckArgs(args, "S:parseFile")) {
if (!PyArg_ParseTuple(args, "s:parseFile", &filename))
return NULL;
}
else return NULL;
doc = xmlSecParseFile(filename);
return (wrap_xmlDocPtr(doc));
}
PyObject *xmlsec_ParseMemory(PyObject *self, PyObject *args) {
const xmlSecByte *buffer;
xmlSecSize size;
int recovery;
xmlDocPtr doc;
if (CheckArgs(args, "SII:parseMemory")) {
if (!PyArg_ParseTuple(args, "sii:parseMemory", &buffer, &size, &recovery))
return NULL;
}
else return NULL;
doc = xmlSecParseMemory(buffer, size, recovery);
return (wrap_xmlDocPtr(doc));
}
PyObject *xmlsec_ParseMemoryExt(PyObject *self, PyObject *args) {
const xmlSecByte *prefix;
xmlSecSize prefixSize;
const xmlSecByte *buffer;
xmlSecSize bufferSize;
const xmlSecByte *postfix;
xmlSecSize postfixSize;
xmlDocPtr doc;
if (CheckArgs(args, "SISISI:parseMemoryExt")) {
if (!PyArg_ParseTuple(args, "sisisi:parseMemoryExt", &prefix, &prefixSize,
&buffer, &bufferSize, &postfix, &postfixSize))
return NULL;
}
else return NULL;
doc = xmlSecParseMemoryExt(prefix, prefixSize,
buffer, bufferSize,
postfix, postfixSize);
return (wrap_xmlDocPtr(doc));
}
PyObject *xmlsec_TransformXmlParserId(PyObject *self, PyObject *args) {
return (wrap_xmlSecTransformId(xmlSecTransformXmlParserId));
}