94 if (one->
value < two->value)
96 else if (one->
value == two->value)
102#define ERROR_NOARG (-1)
103#define ERROR_NOMEM (-2)
104#define ERROR_USAGE (-3)
108 char *strings, *ptrkey, *ptrvalue;
109 int count=1, count2, element_count=0;
119 for (ptrkey = strings; *ptrkey; ptrkey++) {
130 while ((ptrkey =
strsep(&strings,
","))) {
131 ptrvalue = strchr(ptrkey,
':');
145 for (count2 = 0; count2 < count; count2++) {
146 int blen = strlen(buffer);
147 if (element_count++) {
148 strncat(buffer + blen,
",", buflen - blen - 1);
159 char *parse, ds[2], *var_expr;
160 size_t delim_consumed;
179 snprintf(var_expr, strlen(
args.varname) + 4,
"${%s}",
args.varname);
192 int out_field_count = 0;
195 char *next_range =
strsep(&(
args.field),
"&");
196 int start_field, stop_field;
199 if (sscanf(next_range,
"%30d-%30d", &start_field, &stop_field) == 2) {
201 }
else if (sscanf(next_range,
"-%30d", &stop_field) == 1) {
204 }
else if ((sscanf(next_range,
"%30d%1c", &start_field, &trashchar) == 2) && (trashchar ==
'-')) {
206 stop_field = INT_MAX;
207 }
else if (sscanf(next_range,
"%30d", &start_field) == 1) {
209 stop_field = start_field;
217 while (curfieldptr !=
NULL && curfieldnum < start_field) {
223 if (curfieldnum > start_field) {
228 while (curfieldptr !=
NULL && curfieldnum <= stop_field) {
229 char *field_value =
strsep(&curfieldptr, ds);
267 ast_log(
LOG_ERROR,
"Syntax: CUT(<varname>,<char-delim>,<range-spec>) - missing argument!\n");
292 ast_log(
LOG_ERROR,
"Syntax: CUT(<varname>,<char-delim>,<range-spec>) - missing argument!\n");
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdupa(s)
duplicate a string in memory from the stack
General Asterisk PBX channel definitions.
Generic File Format Support. Should be included by clients of the file handling routines....
static int sort_internal(struct ast_channel *chan, char *data, char *buffer, size_t buflen)
static int acf_sort_exec(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function acf_cut
static struct ast_custom_function acf_sort
static int acf_cut_exec(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int sort_subroutine(const void *arg1, const void *arg2)
static int acf_cut_exec2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static int load_module(void)
static int unload_module(void)
static int cut_internal(struct ast_channel *chan, char *data, struct ast_str **buf, ssize_t buflen)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * strsep(char **str, const char *delims)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Core PBX routines and definitions.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Support for dynamic strings.