aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-05 15:07:49 +0000
committeranthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-05 15:07:49 +0000
commitd4dd060a57c6b29d509f5a921617abf28858c510 (patch)
tree900b49271b8197254a3641049785b9e956048843
parent69bfd8b964aff8f4c7a298cb47b658d00d5f3b36 (diff)
expose function execution routines and warn about trying to set a read-only cdr var
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5589 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xcdr.c12
-rwxr-xr-xinclude/asterisk/pbx.h23
-rwxr-xr-xpbx.c4
3 files changed, 36 insertions, 3 deletions
diff --git a/cdr.c b/cdr.c
index 51c40dbb9..938533565 100755
--- a/cdr.c
+++ b/cdr.c
@@ -209,7 +209,19 @@ int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int
{
struct ast_var_t *newvariable;
struct varshead *headp;
+ const char *read_only[] = { "clid", "src", "dst", "dcontext", "channel", "dstchannel",
+ "lastapp", "lastdata", "start", "answer", "end", "duration",
+ "billsec", "disposition", "amaflags", "accountcode", "uniqueid",
+ "userfield", NULL };
+ int x;
+ for(x = 0; read_only[x]; x++) {
+ if (!strcasecmp(name, read_only[x])) {
+ ast_log(LOG_ERROR, "Attempt to set a read-only variable!.\n");
+ return -1;
+ }
+ }
+
if (!cdr) {
ast_log(LOG_ERROR, "Attempt to set a variable on a nonexistent CDR record.\n");
return -1;
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index 07d8fbbaa..19331acff 100755
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -602,6 +602,29 @@ int ast_async_goto_if_exists(struct ast_channel *chan, char* context, char *exte
struct ast_custom_function* ast_custom_function_find(char *name);
int ast_custom_function_unregister(struct ast_custom_function *acf);
int ast_custom_function_register(struct ast_custom_function *acf);
+
+/*! executes a read operation on a function */
+/*!
+ * \param chan Channel to execute on
+ * \param in Data containing the function call string
+ * \param workspace A pointer to safe memory to use for a return value
+ * \param len the number of bytes in workspace
+ * This application executes an function in read mode on a given channel.
+ * It returns a pointer to workspace if the buffer contains any new data
+ * or NULL if there was a problem.
+ */
+
+char *ast_func_read(struct ast_channel *chan, const char *in, char *workspace, size_t len);
+
+/*! executes a write operation on a function */
+/*!
+ * \param chan Channel to execute on
+ * \param in Data containing the function call string
+ * \param value A value parameter to pass for writing
+ * This application executes an function in write mode on a given channel.
+ * It has no return value.
+ */
+void ast_func_write(struct ast_channel *chan, const char *in, const char *value);
#if defined(__cplusplus) || defined(c_plusplus)
}
diff --git a/pbx.c b/pbx.c
index 7f6cc176e..0f62e5814 100755
--- a/pbx.c
+++ b/pbx.c
@@ -207,8 +207,6 @@ static int pbx_builtin_saycharacters(struct ast_channel *, void *);
static int pbx_builtin_sayphonetic(struct ast_channel *, void *);
int pbx_builtin_setvar(struct ast_channel *, void *);
static int pbx_builtin_importvar(struct ast_channel *, void *);
-static char *ast_func_read(struct ast_channel *chan, const char *in, char *workspace, size_t len);
-static void ast_func_write(struct ast_channel *chan, const char *in, const char *value);
static struct varshead globals;
@@ -1313,7 +1311,7 @@ char *ast_func_read(struct ast_channel *chan, const char *in, char *workspace, s
return ret;
}
-static void ast_func_write(struct ast_channel *chan, const char *in, const char *value)
+void ast_func_write(struct ast_channel *chan, const char *in, const char *value)
{
char *args = NULL, *function, *p;
struct ast_custom_function *acfptr;