[asterisk-commits] file: branch file/bucket r397584 - in /team/file/bucket: ./ include/asterisk/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 23 15:03:33 CDT 2013


Author: file
Date: Fri Aug 23 15:03:30 2013
New Revision: 397584

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397584
Log:
Incorporate review feedback.

Modified:
    team/file/bucket/configure
    team/file/bucket/configure.ac
    team/file/bucket/include/asterisk/bucket.h
    team/file/bucket/main/bucket.c
    team/file/bucket/tests/test_bucket.c

Modified: team/file/bucket/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/file/bucket/configure.ac?view=diff&rev=397584&r1=397583&r2=397584
==============================================================================
--- team/file/bucket/configure.ac (original)
+++ team/file/bucket/configure.ac Fri Aug 23 15:03:30 2013
@@ -544,12 +544,7 @@
   AC_MSG_ERROR([*** JSON support not found (this typically means the libjansson development package is missing)])
 fi
 
-# Find required uriparser support.
 AST_EXT_LIB_CHECK([URIPARSER], [uriparser], [uriParseUriA], [uriparser/Uri.h])
-
-if test "x$URIPARSER_LIB" == "x"; then
-   AC_MSG_ERROR([*** uriparser support not found (this typically means the liburiparser development package is missing)])
-fi
 
 # Another mandatory item (unless it's explicitly disabled)
 AC_ARG_ENABLE([xmldoc],

Modified: team/file/bucket/include/asterisk/bucket.h
URL: http://svnview.digium.com/svn/asterisk/team/file/bucket/include/asterisk/bucket.h?view=diff&rev=397584&r1=397583&r2=397584
==============================================================================
--- team/file/bucket/include/asterisk/bucket.h (original)
+++ team/file/bucket/include/asterisk/bucket.h Fri Aug 23 15:03:30 2013
@@ -61,8 +61,6 @@
 	struct ast_bucket_scheme *scheme_impl;
 	/*! \brief Stringfields */
 	AST_DECLARE_STRING_FIELDS(
-		/*! \brief Name of the bucket */
-		AST_STRING_FIELD(name);
 		/*! \brief Name of scheme in use */
 		AST_STRING_FIELD(scheme);
 	);
@@ -84,8 +82,6 @@
 	struct ast_bucket_scheme *scheme_impl;
 	/*! \brief Stringfields */
 	AST_DECLARE_STRING_FIELDS(
-		/*! \brief Name of the file */
-		AST_STRING_FIELD(name);
 		/*! \brief Name of scheme in use */
 		AST_STRING_FIELD(scheme);
 	);

Modified: team/file/bucket/main/bucket.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bucket/main/bucket.c?view=diff&rev=397584&r1=397583&r2=397584
==============================================================================
--- team/file/bucket/main/bucket.c (original)
+++ team/file/bucket/main/bucket.c Fri Aug 23 15:03:30 2013
@@ -24,7 +24,7 @@
  */
 
 /*** MODULEINFO
-	<depend>uriparser</depend>
+	<use type="external">uriparser</use>
 	<support_level>core</support_level>
  ***/
 
@@ -32,7 +32,9 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#ifdef HAVE_URIPARSER
 #include <uriparser/Uri.h>
+#endif
 
 #include "asterisk/logger.h"
 #include "asterisk/sorcery.h"
@@ -43,9 +45,6 @@
 #include "asterisk/json.h"
 #include "asterisk/file.h"
 #include "asterisk/module.h"
-
-/*! \brief Default scheme for when one is not specified */
-#define DEFAULT_UNSPECIFIED_SCHEME "local"
 
 /*! \brief Number of buckets for the container of schemes */
 #define SCHEME_BUCKETS 53
@@ -85,13 +84,18 @@
 static void *bucket_wizard_retrieve(const struct ast_sorcery *sorcery, void *data, const char *type,
 	const char *id)
 {
+#ifdef HAVE_URIPARSER
 	UriParserStateA state;
 	UriUriA uri;
+#else
+	char *tmp = ast_strdupa(id);
+#endif
 	SCOPED_AO2RDLOCK(lock, schemes);
 	size_t len;
 	char *uri_scheme;
 	RAII_VAR(struct ast_bucket_scheme *, scheme, NULL, ao2_cleanup);
 
+#ifdef HAVE_URIPARSER
 	state.uri = &uri;
 	if (uriParseUriA(&state, id) != URI_SUCCESS ||
 		!uri.scheme.first || !uri.scheme.afterLast) {
@@ -103,9 +107,16 @@
 	uri_scheme = ast_alloca(len);
 	ast_copy_string(uri_scheme, uri.scheme.first, len);
 
+	uriFreeUriMembersA(&uri);
+#else
+	uri_scheme = tmp;
+	if (!(tmp = strchr(':'))) {
+		return NULL;
+	}
+	*tmp = '\0';
+#endif
+
 	scheme = ao2_find(schemes, uri_scheme, OBJ_KEY | OBJ_NOLOCK);
-
-	uriFreeUriMembersA(&uri);
 
 	if (!scheme) {
 		return NULL;
@@ -142,13 +153,18 @@
 static void *bucket_file_wizard_retrieve(const struct ast_sorcery *sorcery, void *data, const char *type,
 	const char *id)
 {
+#ifdef HAVE_URIPARSER
 	UriParserStateA state;
 	UriUriA uri;
+#else
+	char *tmp = ast_strdupa(id);
+#endif
 	size_t len;
 	char *uri_scheme;
 	SCOPED_AO2RDLOCK(lock, schemes);
 	RAII_VAR(struct ast_bucket_scheme *, scheme, NULL, ao2_cleanup);
 
+#ifdef HAVE_URIPARSER
 	state.uri = &uri;
 	if (uriParseUriA(&state, id) != URI_SUCCESS ||
 		!uri.scheme.first || !uri.scheme.afterLast) {
@@ -160,9 +176,16 @@
 	uri_scheme = ast_alloca(len);
 	ast_copy_string(uri_scheme, uri.scheme.first, len);
 
+	uriFreeUriMembersA(&uri);
+#else
+	uri_scheme = tmp;
+	if (!(tmp = strchr(':'))) {
+		return NULL;
+	}
+	*tmp = '\0';
+#endif
+
 	scheme = ao2_find(schemes, uri_scheme, OBJ_KEY | OBJ_NOLOCK);
-
-	uriFreeUriMembersA(&uri);
 
 	if (!scheme) {
 		return NULL;
@@ -346,13 +369,22 @@
 
 struct ast_bucket *ast_bucket_alloc(const char *uri)
 {
+#ifdef HAVE_URIPARSER
 	UriParserStateA state;
 	UriUriA full_uri;
+#else
+	char *tmp = ast_strdupa(uri);
+#endif
 	size_t len;
-	char *uri_scheme, *uri_name;
+	char *uri_scheme;
 	RAII_VAR(struct ast_bucket_scheme *, scheme, NULL, ao2_cleanup);
 	struct ast_bucket *bucket;
 
+	if (ast_strlen_zero(uri)) {
+		return NULL;
+	}
+
+#ifdef HAVE_URIPARSER
 	state.uri = &full_uri;
 	if (uriParseUriA(&state, uri) != URI_SUCCESS ||
 		!full_uri.scheme.first || !full_uri.scheme.afterLast ||
@@ -365,11 +397,14 @@
 	uri_scheme = ast_alloca(len);
 	ast_copy_string(uri_scheme, full_uri.scheme.first, len);
 
-	len = (full_uri.pathTail->text.afterLast - full_uri.pathTail->text.first) + 1;
-	uri_name = ast_alloca(len);
-	ast_copy_string(uri_name, full_uri.pathTail->text.first, len);
-
 	uriFreeUriMembersA(&full_uri);
+#else
+	uri_scheme = tmp;
+	if (!(tmp = strchr(':'))) {
+		return NULL;
+	}
+	*tmp = '\0';
+#endif
 
 	scheme = ao2_find(schemes, uri_scheme, OBJ_KEY);
 	if (!scheme) {
@@ -384,7 +419,6 @@
 	ao2_ref(scheme, +1);
 	bucket->scheme_impl = scheme;
 
-	ast_string_field_set(bucket, name, uri_name);
 	ast_string_field_set(bucket, scheme, uri_scheme);
 
 	return bucket;
@@ -561,13 +595,22 @@
 
 struct ast_bucket_file *ast_bucket_file_alloc(const char *uri)
 {
+#ifdef HAVE_URIPARSER
 	UriParserStateA state;
 	UriUriA full_uri;
+#else
+	char *tmp = ast_strdupa(uri);
+#endif
 	size_t len;
-	char *uri_scheme, *uri_name;
+	char *uri_scheme;
 	RAII_VAR(struct ast_bucket_scheme *, scheme, NULL, ao2_cleanup);
 	struct ast_bucket_file *file;
 
+	if (ast_strlen_zero(uri)) {
+		return NULL;
+	}
+
+#ifdef HAVE_URIPARSER
 	state.uri = &full_uri;
 	if (uriParseUriA(&state, uri) != URI_SUCCESS ||
 		!full_uri.scheme.first || !full_uri.scheme.afterLast ||
@@ -580,11 +623,14 @@
 	uri_scheme = ast_alloca(len);
 	ast_copy_string(uri_scheme, full_uri.scheme.first, len);
 
-	len = (full_uri.pathTail->text.afterLast - full_uri.pathTail->text.first) + 1;
-	uri_name = ast_alloca(len);
-	ast_copy_string(uri_name, full_uri.pathTail->text.first, len);
-
 	uriFreeUriMembersA(&full_uri);
+#else
+	uri_scheme = tmp;
+	if (!(tmp = strchr(':'))) {
+		return NULL;
+	}
+	*tmp = '\0';
+#endif
 
 	scheme = ao2_find(schemes, uri_scheme, OBJ_KEY);
 	if (!scheme) {
@@ -599,7 +645,6 @@
 	ao2_ref(scheme, +1);
 	file->scheme_impl = scheme;
 
-	ast_string_field_set(file, name, uri_name);
 	ast_string_field_set(file, scheme, uri_scheme);
 
 	if (scheme->create(file)) {
@@ -866,7 +911,6 @@
 		return -1;
 	}
 
-	ast_sorcery_object_field_register(bucket_sorcery, "bucket", "name", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_bucket, name));
 	ast_sorcery_object_field_register(bucket_sorcery, "bucket", "scheme", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_bucket, scheme));
 	ast_sorcery_object_field_register_custom(bucket_sorcery, "bucket", "created", "", timeval_str2struct, timeval_struct2str, 0, FLDSET(struct ast_bucket, created));
 	ast_sorcery_object_field_register_custom(bucket_sorcery, "bucket", "modified", "", timeval_str2struct, timeval_struct2str, 0, FLDSET(struct ast_bucket, modified));
@@ -881,7 +925,6 @@
 		return -1;
 	}
 
-	ast_sorcery_object_field_register(bucket_sorcery, "file", "name", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_bucket_file, name));
 	ast_sorcery_object_field_register(bucket_sorcery, "file", "scheme", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_bucket_file, scheme));
 	ast_sorcery_object_field_register_custom(bucket_sorcery, "file", "created", "", timeval_str2struct, timeval_struct2str, 0, FLDSET(struct ast_bucket_file, created));
 	ast_sorcery_object_field_register_custom(bucket_sorcery, "file", "modified", "", timeval_str2struct, timeval_struct2str, 0, FLDSET(struct ast_bucket_file, modified));

Modified: team/file/bucket/tests/test_bucket.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bucket/tests/test_bucket.c?view=diff&rev=397584&r1=397583&r2=397584
==============================================================================
--- team/file/bucket/tests/test_bucket.c (original)
+++ team/file/bucket/tests/test_bucket.c Fri Aug 23 15:03:30 2013
@@ -192,12 +192,6 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (strcmp(bucket->name, "bob")) {
-		ast_test_status_update(test, "Bucket id is '%s' and should be bob\n",
-			bucket->name);
-		return AST_TEST_FAIL;
-	}
-
 	return AST_TEST_PASS;
 }
 
@@ -313,10 +307,10 @@
 	ast_str_container_add(bucket->buckets, "test:///tmp/bob/joe");
 	ast_str_container_add(bucket->files, "test:///tmp/bob/recording.wav");
 
-	expected = ast_json_pack("{s: s, s: s, s: [s], s: s, s: s, s: [s], s: s}",
+	expected = ast_json_pack("{s: s, s: s, s: [s], s: s, s: [s], s: s}",
 		"modified", "0.000000", "created", "0.000000",
 		"buckets", "test:///tmp/bob/joe",
-		"name", "bob", "scheme", "test",
+		"scheme", "test",
 		"files", "test:///tmp/bob/recording.wav",
 		"id", "test:///tmp/bob");
 	if (!expected) {
@@ -410,12 +404,6 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (strcmp(file->name, "bob")) {
-		ast_test_status_update(test, "File id is '%s' and should be bob\n",
-			ast_sorcery_object_get_id(file));
-		return AST_TEST_FAIL;
-	}
-
 	return AST_TEST_PASS;
 }
 
@@ -822,8 +810,8 @@
 		return AST_TEST_FAIL;
 	}
 
-	expected = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: {s :s}}",
-		"modified", "0.000000", "created", "0.000000", "name", "bob", "scheme", "test",
+	expected = ast_json_pack("{s: s, s: s, s: s, s: s, s: {s :s}}",
+		"modified", "0.000000", "created", "0.000000", "scheme", "test",
 		"id", "test:///tmp/bob", "metadata", "bob", "joe");
 	if (!expected) {
 		ast_test_status_update(test, "Could not produce JSON for expected bucket file value\n");




More information about the asterisk-commits mailing list