[asterisk-commits] file: branch file/sorcery r380042 - /team/file/sorcery/main/sorcery.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 24 09:02:38 CST 2013
Author: file
Date: Thu Jan 24 09:02:35 2013
New Revision: 380042
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380042
Log:
Last bit of review feedback!
Modified:
team/file/sorcery/main/sorcery.c
Modified: team/file/sorcery/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/file/sorcery/main/sorcery.c?view=diff&rev=380042&r1=380041&r2=380042
==============================================================================
--- team/file/sorcery/main/sorcery.c (original)
+++ team/file/sorcery/main/sorcery.c Thu Jan 24 09:02:35 2013
@@ -123,64 +123,48 @@
static int int_handler_fn(const void *obj, const intptr_t *args, char **buf)
{
int *field = (int *)(obj + args[0]);
- char value[256];
-
- snprintf(value, sizeof(value), "%d", *field);
- *buf = ast_strdup(value);
+ return (ast_asprintf(buf, "%d", *field) < 0) ? -1 : 0;
+}
+
+static int uint_handler_fn(const void *obj, const intptr_t *args, char **buf)
+{
+ unsigned int *field = (unsigned int *)(obj + args[0]);
+ return (ast_asprintf(buf, "%u", *field) < 0) ? -1 : 0;
+}
+
+static int double_handler_fn(const void *obj, const intptr_t *args, char **buf)
+{
+ double *field = (double *)(obj + args[0]);
+ return (ast_asprintf(buf, "%f", *field) < 0) ? -1 : 0;
+}
+
+static int stringfield_handler_fn(const void *obj, const intptr_t *args, char **buf)
+{
+ ast_string_field *field = (const char **)(obj + args[0]);
+ return !(*buf = ast_strdup(*field)) ? -1 : 0;
+}
+
+static int bool_handler_fn(const void *obj, const intptr_t *args, char **buf)
+{
+ unsigned int *field = (unsigned int *)(obj + args[0]);
+ return !(*buf = ast_strdup(*field ? "true" : "false")) ? -1 : 0;
+}
+
+static int sockaddr_handler_fn(const void *obj, const intptr_t *args, char **buf)
+{
+ struct ast_sockaddr *field = (struct ast_sockaddr *)(obj + args[0]);
+ return !(*buf = ast_strdup(ast_sockaddr_stringify(field))) ? -1 : 0;
+}
+
+static int noop_handler_fn(const void *obj, const intptr_t *args, char **buf)
+{
return 0;
}
-static int uint_handler_fn(const void *obj, const intptr_t *args, char **buf)
-{
- unsigned int *field = (unsigned int *)(obj + args[0]);
- char value[256];
-
- snprintf(value, sizeof(value), "%u", *field);
- *buf = ast_strdup(value);
- return 0;
-}
-
-static int double_handler_fn(const void *obj, const intptr_t *args, char **buf)
-{
- double *field = (double *)(obj + args[0]);
- char value[256];
-
- snprintf(value, sizeof(value), "%f", *field);
- *buf = ast_strdup(value);
- return 0;
-}
-
-static int stringfield_handler_fn(const void *obj, const intptr_t *args, char **buf)
-{
- ast_string_field *field = (const char **)(obj + args[0]);
- *buf = ast_strdup(*field);
- return 0;
-}
-
-static int bool_handler_fn(const void *obj, const intptr_t *args, char **buf)
-{
- unsigned int *field = (unsigned int *)(obj + args[0]);
- *buf = ast_strdup(*field ? "true" : "false");
- return 0;
-}
-
-static int sockaddr_handler_fn(const void *obj, const intptr_t *args, char **buf)
-{
- struct ast_sockaddr *field = (struct ast_sockaddr *)(obj + args[0]);
- *buf = ast_strdup(ast_sockaddr_stringify(field));
- return 0;
-}
-
-static int noop_handler_fn(const void *obj, const intptr_t *args, char **buf)
-{
- return 0;
-}
-
static int chararray_handler_fn(const void *obj, const intptr_t *args, char **buf)
{
char *field = (char *)(obj + args[0]);
- *buf = ast_strdup(field);
- return 0;
+ return !(*buf = ast_strdup(field)) ? -1 : 0;
}
static sorcery_field_handler sorcery_field_default_handler(enum aco_option_type type)
More information about the asterisk-commits
mailing list