Permalink
Browse files

Add an MT-safe creation interface

The old interface would use the global errstr variable so that
it would not be usable from multiple threads

Change-Id: Ib978836c3ad267f6a0c6eadfd3ab9bbbb049f2ba
Reviewed-on: http://review.couchbase.org/12970
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information...
1 parent c9f728e commit 6a97edbfe1599712df756ed29997c03ba4a15731 @trondn trondn committed with dustin Feb 3, 2012
Showing with 177 additions and 96 deletions.
  1. +2 −2 configure.ac
  2. +30 −0 include/libvbucket/vbucket.h
  3. +145 −94 src/vbucket.c
View
@@ -54,9 +54,9 @@ AM_CONDITIONAL(BUILD_DOCS, test "$with_docs" = "yes")
# to version our library. For a detailed description, check out:
# http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
#
-LIBVBUCKET_API_CURRENT=1
+LIBVBUCKET_API_CURRENT=2
LIBVBUCKET_API_REVISION=0
-LIBVBUCKET_API_AGE=0
+LIBVBUCKET_API_AGE=1
AC_SUBST(LIBVBUCKET_API_CURRENT)
AC_SUBST(LIBVBUCKET_API_REVISION)
AC_SUBST(LIBVBUCKET_API_AGE)
@@ -100,6 +100,36 @@ extern "C" {
*/
/**
+ * Create a new vbucket config handle
+ * @return handle or NULL if there is no more memory
+ */
+ LIBVBUCKET_PUBLIC_API
+ VBUCKET_CONFIG_HANDLE vbucket_config_create(void);
+
+ typedef enum {
+ LIBVBUCKET_SOURCE_FILE,
+ LIBVBUCKET_SOURCE_MEMORY
+ } vbucket_source_t;
+
+ /**
+ * Parse a vbucket configuration
+ * @param handle the vbucket config handle to store the result
+ * @param data_source what kind of datasource to parse
+ * @param data A zero terminated string representing the data to parse.
+ * For LIBVBUCKET_SOURCE_FILE this is the file to parse,
+ * for LIBVBUCKET_SOURCE_MEMORY it is the actual JSON body.
+ * @return 0 for success, the appropriate error code otherwise
+ */
+ LIBVBUCKET_PUBLIC_API
+ int vbucket_config_parse(VBUCKET_CONFIG_HANDLE handle,
+ vbucket_source_t data_source,
+ const char *data);
+
+ LIBVBUCKET_PUBLIC_API
+ const char *vbucket_get_error_message(VBUCKET_CONFIG_HANDLE handle);
+
+
+ /**
* Create an instance of vbucket config from a file.
*
* @param filename the vbucket config to parse
Oops, something went wrong.

0 comments on commit 6a97edb

Please sign in to comment.