90 if (one->
value < two->value)
92 else if (one->
value == two->value)
98 #define ERROR_NOARG (-1) 99 #define ERROR_NOMEM (-2) 100 #define ERROR_USAGE (-3) 104 char *strings, *ptrkey, *ptrvalue;
105 int count=1, count2, element_count=0;
115 for (ptrkey = strings; *ptrkey; ptrkey++) {
120 sortable_keys =
ast_alloca(count *
sizeof(
struct sortable_keys));
122 memset(sortable_keys, 0, count *
sizeof(
struct sortable_keys));
126 while ((ptrkey =
strsep(&strings,
","))) {
127 ptrvalue = strchr(ptrkey,
':');
133 sortable_keys[count2].
key = ptrkey;
134 sscanf(ptrvalue,
"%30f", &sortable_keys[count2].
value);
139 qsort(sortable_keys, count,
sizeof(
struct sortable_keys),
sort_subroutine);
141 for (count2 = 0; count2 < count; count2++) {
142 int blen = strlen(buffer);
143 if (element_count++) {
144 strncat(buffer + blen,
",", buflen - blen - 1);
147 strncat(buffer + blen, sortable_keys[count2].
key, buflen - blen - 1);
155 char *
parse, ds[2], *var_expr;
156 size_t delim_consumed;
175 snprintf(var_expr, strlen(
args.varname) + 4,
"${%s}",
args.varname);
188 int out_field_count = 0;
191 char *next_range =
strsep(&(
args.field),
"&");
192 int start_field, stop_field;
195 if (sscanf(next_range,
"%30d-%30d", &start_field, &stop_field) == 2) {
197 }
else if (sscanf(next_range,
"-%30d", &stop_field) == 1) {
200 }
else if ((sscanf(next_range,
"%30d%1c", &start_field, &trashchar) == 2) && (trashchar ==
'-')) {
202 stop_field = INT_MAX;
203 }
else if (sscanf(next_range,
"%30d", &start_field) == 1) {
205 stop_field = start_field;
213 while (curfieldptr !=
NULL && curfieldnum < start_field) {
219 if (curfieldnum > start_field) {
224 while (curfieldptr !=
NULL && curfieldnum <= stop_field) {
225 char *field_value =
strsep(&curfieldptr, ds);
226 ast_str_append(buf, buflen,
"%s%s", out_field_count++ ? ds :
"", field_value);
263 ast_log(
LOG_ERROR,
"Syntax: CUT(<varname>,<char-delim>,<range-spec>) - missing argument!\n");
288 ast_log(
LOG_ERROR,
"Syntax: CUT(<varname>,<char-delim>,<range-spec>) - missing argument!\n");
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
static int acf_cut_exec(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
static struct ast_custom_function acf_sort
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Core PBX routines and definitions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
static int cut_internal(struct ast_channel *chan, char *data, struct ast_str **buf, ssize_t buflen)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int load_module(void)
static void parse(struct mgcp_request *req)
static int acf_sort_exec(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
char * strsep(char **str, const char *delims)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static struct ast_custom_function acf_cut
static int unload_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static int sort_internal(struct ast_channel *chan, char *data, char *buffer, size_t buflen)
static int acf_cut_exec2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static int sort_subroutine(const void *arg1, const void *arg2)
#define ast_custom_function_register(acf)
Register a custom function.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define AST_APP_ARG(name)
Define an application argument.