*
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
#include <asterisk/file.h>
#include <asterisk/logger.h>
#include <asterisk/options.h>
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
#include <asterisk/module.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
/* Maximum length of any variable */
#define MAXRESULT 1024
static char *cut_synopsis = "Cut(newvar=varname|delimiter|fieldspec)";
static char *cut_descrip =
-"Cut(varname=varname,delimiter,field)\n"
-" newvar - result string is set to this variable\n"
+"Cut(newvar=varname,delimiter,field)\n"
+" newvar - new variable created from result string\n"
" varname - variable you want cut\n"
-" delimiter - defaults to -\n"
+" delimiter - defaults to '-'\n"
" fieldspec - number of the field you want (1-based offset)\n"
" may also be specified as a range (with -)\n"
" or group of ranges and fields (with &)\n"
/* Check and parse arguments */
if (data) {
- s = strdupa((char *)data);
+ s = ast_strdupa((char *)data);
if (s) {
newvar = strsep(&s, "=");
if (newvar && (newvar[0] != '\0')) {
char *tmp2 = alloca(MAXRESULT);
char retstring[MAXRESULT];
+ if (tmp2)
+ memset(tmp2, 0, MAXRESULT);
memset(retstring, 0, MAXRESULT);
if (tmp && tmp2) {
/* Get to start, if any */
if (num1 > 0) {
- while ((tmp2 != NULL + 1) && (curfieldnum < num1)) {
+ while ((tmp2 != (char *)NULL + 1) && (curfieldnum < num1)) {
tmp2 = index(tmp2, d) + 1;
curfieldnum++;
}
}
/* Re-null tmp2 if we added 1 to NULL */
- if (tmp2 == NULL + 1)
+ if (tmp2 == (char *)NULL + 1)
tmp2 = NULL;
/* Output fields until we either run out of fields or num2 is reached */