diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index 0a7318fb..6e37cc36 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -665,6 +665,7 @@
+
@@ -8586,6 +8587,11 @@ crash if you try to modify the tree)'/>
+
+ Get the current options of the parser context. Available since 2.14.0.
+
+
+
Parse an XML document and return the resulting document tree. Takes ownership of the input object. Available since 2.13.0.
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 6cf2e0a5..5a3914fd 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -1402,6 +1402,8 @@ XMLPUBFUN int
XMLPUBFUN int
xmlCtxtSetOptions (xmlParserCtxtPtr ctxt,
int options);
+XMLPUBFUN int
+ xmlCtxtGetOptions (xmlParserCtxtPtr ctxt);
XMLPUBFUN int
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
int options);
diff --git a/parser.c b/parser.c
index 046909bd..0ea677df 100644
--- a/parser.c
+++ b/parser.c
@@ -13594,6 +13594,25 @@ xmlCtxtSetOptions(xmlParserCtxtPtr ctxt, int options)
return(xmlCtxtSetOptionsInternal(ctxt, options, 0));
}
+/**
+ * xmlCtxtGetOptions:
+ * @ctxt: an XML parser context
+ *
+ * Get the current options of the parser context.
+ *
+ * Available since 2.14.0.
+ *
+ * Returns the current options set in the parser context, or -1 if ctxt is NULL.
+ */
+int
+xmlCtxtGetOptions(xmlParserCtxtPtr ctxt)
+{
+ if (ctxt == NULL)
+ return(-1);
+
+ return(ctxt->options);
+}
+
/**
* xmlCtxtUseOptions:
* @ctxt: an XML parser context
diff --git a/testapi.c b/testapi.c
index 2e334f29..614d6d3c 100644
--- a/testapi.c
+++ b/testapi.c
@@ -11820,6 +11820,38 @@ test_xmlCreatePushParserCtxt(void) {
}
+static int
+test_xmlCtxtGetOptions(void) {
+ int test_ret = 0;
+
+ int mem_base;
+ int ret_val;
+ xmlParserCtxtPtr ctxt; /* an XML parser context */
+ int n_ctxt;
+
+ for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+ mem_base = xmlMemBlocks();
+ ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
+
+ ret_val = xmlCtxtGetOptions(ctxt);
+ desret_int(ret_val);
+ call_tests++;
+ des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
+ xmlResetLastError();
+ if (mem_base != xmlMemBlocks()) {
+ printf("Leak of %d blocks found in xmlCtxtGetOptions",
+ xmlMemBlocks() - mem_base);
+ test_ret++;
+ printf(" %d", n_ctxt);
+ printf("\n");
+ }
+ }
+ function_tests++;
+
+ return(test_ret);
+}
+
+
static int
test_xmlCtxtParseDocument(void) {
int test_ret = 0;
@@ -14721,13 +14753,14 @@ static int
test_parser(void) {
int test_ret = 0;
- if (quiet == 0) printf("Testing parser : 71 of 83 functions ...\n");
+ if (quiet == 0) printf("Testing parser : 72 of 84 functions ...\n");
test_ret += test_xmlByteConsumed();
test_ret += test_xmlCleanupGlobals();
test_ret += test_xmlClearNodeInfoSeq();
test_ret += test_xmlClearParserCtxt();
test_ret += test_xmlCreateDocParserCtxt();
test_ret += test_xmlCreatePushParserCtxt();
+ test_ret += test_xmlCtxtGetOptions();
test_ret += test_xmlCtxtParseDocument();
test_ret += test_xmlCtxtReadDoc();
test_ret += test_xmlCtxtReadFile();