75 static int base64_helper(
struct ast_channel *chan,
const char *cmd,
char *data,
76 char *buf,
struct ast_str **str, ssize_t len)
78 if (ast_strlen_zero(data)) {
79 ast_log(LOG_WARNING,
"Syntax: %s(<data>) - missing argument!\n", cmd);
88 ast_str_make_space(str, len ? len :
ast_str_strlen(*str) + strlen(data) * 4 / 3 + 2);
99 buf[decoded_len <= (len - 1) ? decoded_len : len - 1] =
'\0';
102 ast_str_make_space(str, len ? len :
ast_str_strlen(*str) + strlen(data) * 3 / 4 + 2);
109 ast_str_buffer(*str)[decoded_len <= (len - 1) ? decoded_len : len - 1] =
'\0';
121 static int base64_buf_helper(
struct ast_channel *chan,
const char *cmd,
char *data,
122 char *buf,
size_t len)
124 return base64_helper(chan, cmd, data, buf, NULL, len);
127 static int base64_str_helper(
struct ast_channel *chan,
const char *cmd,
char *data,
128 struct ast_str **buf, ssize_t len)
130 return base64_helper(chan, cmd, data, NULL, buf, len);
134 .
name =
"BASE64_ENCODE",
135 .read = base64_buf_helper,
136 .read2 = base64_str_helper,
140 .
name =
"BASE64_DECODE",
141 .read = base64_buf_helper,
142 .read2 = base64_str_helper,
145 static int unload_module(
void)
151 static int load_module(
void)
157 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"base64 encode/decode dialplan functions");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_base64decode(unsigned char *dst, const char *src, int max)
Decode data from base64.
Data structure associated with a custom dialplan function.
Core PBX routines and definitions.
Support for dynamic strings.
int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max)
Encode data in base64.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define ast_custom_function_register(acf)
Register a custom function.