summaryrefslogtreecommitdiff
path: root/src/charset/charset.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-05-01 16:34:46 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-05-01 16:34:46 +0000
commit2777a04ed2ba4fd36138b991d66a32a283361f7e (patch)
treeb0c3730533c36ca41402b6d0c5b98413f0a57bee /src/charset/charset.c
downloadlibparserutils-2777a04ed2ba4fd36138b991d66a32a283361f7e.tar.gz
libparserutils-2777a04ed2ba4fd36138b991d66a32a283361f7e.tar.bz2
Import parser construction utility library
svn path=/trunk/libparserutils/; revision=4111
Diffstat (limited to 'src/charset/charset.c')
-rw-r--r--src/charset/charset.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/charset/charset.c b/src/charset/charset.c
new file mode 100644
index 0000000..3ef1a71
--- /dev/null
+++ b/src/charset/charset.c
@@ -0,0 +1,54 @@
+/*
+ * This file is part of LibParserUtils.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ */
+
+#include "charset/aliases.h"
+#include "charset/charset.h"
+
+/**
+ * Initialise the Charset library for use.
+ *
+ * This _must_ be called before using any libparserutils charset functions
+ *
+ * \param aliases_file Pointer to name of file containing encoding alias data
+ * \param alloc Pointer to (de)allocation function
+ * \param pw Pointer to client-specific private data (may be NULL)
+ * \return PARSERUTILS_OK on success, applicable error otherwise.
+ */
+parserutils_error parserutils_charset_initialise(const char *aliases_file,
+ parserutils_alloc alloc, void *pw)
+{
+ parserutils_error error;
+
+ if (aliases_file == NULL || alloc == NULL)
+ return PARSERUTILS_BADPARM;
+
+ error = parserutils_charset_aliases_create(aliases_file, alloc, pw);
+ if (error != PARSERUTILS_OK)
+ return error;
+
+ return PARSERUTILS_OK;
+}
+
+/**
+ * Clean up after Libparserutils
+ *
+ * \param alloc Pointer to (de)allocation function
+ * \param pw Pointer to client-specific private data (may be NULL)
+ * \return PARSERUTILS_OK on success, applicable error otherwise.
+ */
+parserutils_error parserutils_charset_finalise(parserutils_alloc alloc,
+ void *pw)
+{
+ if (alloc == NULL)
+ return PARSERUTILS_BADPARM;
+
+ parserutils_charset_aliases_destroy(alloc, pw);
+
+ return PARSERUTILS_OK;
+}
+
+