--- /dev/null
+/*\r
+ * Asterisk -- An open source telephony toolkit.\r
+ *\r
+ * Copyright (C) 2005, Digium, Inc.\r
+ * Copyright (C) 2005, Claude Patry\r
+ *\r
+ * See http://www.asterisk.org for more information about\r
+ * the Asterisk project. Please do not directly contact\r
+ * any of the maintainers of this project for assistance;\r
+ * the project provides a web site, mailing lists and IRC\r
+ * channels for your use.\r
+ *\r
+ * This program is free software, distributed under the terms of\r
+ * the GNU General Public License Version 2. See the LICENSE file\r
+ * at the top of the source tree.\r
+ */\r
+\r
+/*! \file\r
+ *\r
+ * \brief Use the base64 as functions\r
+ * \r
+ */\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <sys/types.h>\r
+\r
+#include "asterisk.h"\r
+\r
+/* ASTERISK_FILE_VERSION(__FILE__, "Revision: 7221 ") */\r
+\r
+#include "asterisk/channel.h"\r
+#include "asterisk/pbx.h"\r
+#include "asterisk/logger.h"\r
+#include "asterisk/utils.h"\r
+#include "asterisk/app.h"\r
+\r
+static char *builtin_function_base64_encode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) \r
+{\r
+ int res = 0;\r
+\r
+ if (ast_strlen_zero(data) ) {\r
+ ast_log(LOG_WARNING, "Syntax: BASE64_ENCODE(<data>) - missing argument!\n");\r
+ return NULL;\r
+ }\r
+\r
+ ast_log(LOG_DEBUG, "data=%s\n",data);\r
+ res = ast_base64encode(buf, data, strlen(data), len);\r
+ ast_log(LOG_DEBUG, "res=%d\n", res);\r
+ return buf;\r
+}\r
+\r
+static char *builtin_function_base64_decode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) \r
+{\r
+ if (ast_strlen_zero(data) ) {\r
+ ast_log(LOG_WARNING, "Syntax: BASE64_DECODE(<base_64 string>) - missing argument!\n");\r
+ return NULL;\r
+ }\r
+\r
+ ast_log(LOG_DEBUG, "data=%s\n", data);\r
+ ast_base64decode(buf, data, len);\r
+ return buf;\r
+}\r
+\r
+#ifndef BUILTIN_FUNC\r
+static\r
+#endif\r
+struct ast_custom_function base64_encode_function = {\r
+ .name = "BASE64_ENCODE",\r
+ .synopsis = "Encode a string in base64",\r
+ .desc = "Returns the base64 string\n",\r
+ .syntax = "BASE64_ENCODE(<string>)",\r
+ .read = builtin_function_base64_encode,\r
+};\r
+\r
+#ifndef BUILTIN_FUNC\r
+static\r
+#endif\r
+struct ast_custom_function base64_decode_function = {\r
+ .name = "BASE64_DECODE",\r
+ .synopsis = "Decode a base64 string",\r
+ .desc = "Returns the plain text string\n",\r
+ .syntax = "BASE64_DECODE(<base64_string>)",\r
+ .read = builtin_function_base64_decode,\r
+};\r