summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/man3/cmark.315
-rw-r--r--src/cmark.h11
-rw-r--r--src/node.c18
-rw-r--r--src/node.h2
4 files changed, 45 insertions, 1 deletions
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
index 5df89c3..1bffc5c 100644
--- a/man/man3/cmark.3
+++ b/man/man3/cmark.3
@@ -1,4 +1,4 @@
-.TH cmark 3 "January 11, 2015" "LOCAL" "Library Functions Manual"
+.TH cmark 3 "January 19, 2015" "LOCAL" "Library Functions Manual"
.SH
NAME
.PP
@@ -183,6 +183,19 @@ descendant of the root node or the root node itself.
Accessors
.PP
+\fIvoid*\f[] \fBcmark_node_get_user_data\f[](\fIcmark_node *node\f[])
+
+.PP
+Returns the user data of \f[I]node\f[]\&.
+
+.PP
+\fIint\f[] \fBcmark_node_set_user_data\f[](\fIcmark_node *node\f[], \fIvoid *user_data\f[])
+
+.PP
+Sets arbitrary user data for \f[I]node\f[]\&. Returns 1 on success,
+0 on failure.
+
+.PP
\fIcmark_node_type\f[] \fBcmark_node_get_type\f[](\fIcmark_node *node\f[])
.PP
diff --git a/src/cmark.h b/src/cmark.h
index 04ca6d7..74fa4c7 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -226,6 +226,17 @@ cmark_iter_reset(cmark_iter *iter, cmark_node *current,
* ## Accessors
*/
+/** Returns the user data of 'node'.
+ */
+CMARK_EXPORT void*
+cmark_node_get_user_data(cmark_node *node);
+
+/** Sets arbitrary user data for 'node'. Returns 1 on success,
+ * 0 on failure.
+ */
+CMARK_EXPORT int
+cmark_node_set_user_data(cmark_node *node, void *user_data);
+
/** Returns the type of 'node', or `CMARK_NODE_NONE` on error.
*/
CMARK_EXPORT cmark_node_type
diff --git a/src/node.c b/src/node.c
index 3785a27..675eb19 100644
--- a/src/node.c
+++ b/src/node.c
@@ -189,6 +189,24 @@ cmark_node_last_child(cmark_node *node)
}
}
+void*
+cmark_node_get_user_data(cmark_node *node) {
+ if (node == NULL) {
+ return NULL;
+ } else {
+ return node->user_data;
+ }
+}
+
+int
+cmark_node_set_user_data(cmark_node *node, void *user_data) {
+ if (node == NULL) {
+ return 0;
+ }
+ node->user_data = user_data;
+ return 1;
+}
+
static char*
S_strdup(const char *str)
{
diff --git a/src/node.h b/src/node.h
index c0c43d3..74eddd4 100644
--- a/src/node.h
+++ b/src/node.h
@@ -49,6 +49,8 @@ struct cmark_node {
struct cmark_node *first_child;
struct cmark_node *last_child;
+ void *user_data;
+
int start_line;
int start_column;
int end_line;