~davewalker/ubuntu/maverick/asterisk/lp_705014

« back to all changes in this revision

Viewing changes to apps/app_macro.c

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2005-03-09 22:09:05 UTC
  • mto: (1.2.1 upstream) (8.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050309220905-9afy6hcpw96xbr6j
Tags: upstream-1.0.6
ImportĀ upstreamĀ versionĀ 1.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <asterisk/pbx.h>
19
19
#include <asterisk/module.h>
20
20
#include <asterisk/options.h>
 
21
#include <asterisk/utils.h>
 
22
#include <asterisk/lock.h>
21
23
#include <stdlib.h>
22
24
#include <unistd.h>
23
25
#include <string.h>
24
26
#include <stdlib.h>
25
27
 
26
 
#include <pthread.h>
27
 
 
28
28
#define MAX_ARGS 80
29
29
 
30
30
static char *tdesc = "Extension Macros";
73
73
  char *save_macro_priority;
74
74
  char *save_macro_offset;
75
75
  
76
 
  if (!data || !strlen(data)) {
 
76
  if (!data || ast_strlen_zero(data)) {
77
77
    ast_log(LOG_WARNING, "Invalid Macro incantation\n");
78
78
    return 0;
79
79
  }
80
80
  strncpy(tmp, data, sizeof(tmp) - 1);
81
81
  rest = tmp;
82
82
  macro = strsep(&rest, "|");
83
 
  if (!macro || !strlen(macro)) {
 
83
  if (!macro || ast_strlen_zero(macro)) {
84
84
        ast_log(LOG_WARNING, "Invalid macro name specified\n");
85
85
        return 0;
86
86
  }
96
96
  oldpriority = chan->priority;
97
97
  strncpy(oldexten, chan->exten, sizeof(oldexten) - 1);
98
98
  strncpy(oldcontext, chan->context, sizeof(oldcontext) - 1);
99
 
  if (!strlen(chan->macrocontext)) {
 
99
  if (ast_strlen_zero(chan->macrocontext)) {
100
100
        strncpy(chan->macrocontext, chan->context, sizeof(chan->macrocontext) - 1);
101
101
        strncpy(chan->macroexten, chan->exten, sizeof(chan->macroexten) - 1);
102
102
        chan->macropriority = chan->priority;
122
122
  pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", NULL);
123
123
 
124
124
  /* Setup environment for new run */
125
 
  strcpy(chan->exten, "s");
126
 
  strncpy(chan->context, fullmacro, sizeof(chan->context));
 
125
  chan->exten[0] = 's';
 
126
  chan->exten[1] = '\0';
 
127
  strncpy(chan->context, fullmacro, sizeof(chan->context) - 1);
127
128
  chan->priority = 1;
128
129
 
129
130
  while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) {
139
140
  while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
140
141
        if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid))) {
141
142
                /* Something bad happened, or a hangup has been requested. */
142
 
                if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) {
 
143
                if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
 
144
                    (res == '*') || (res == '#')) {
143
145
                        /* Just return result as to the previous application as if it had been dialed */
144
146
                        ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
145
147
                        break;
193
195
  pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
194
196
  if (save_macro_priority) free(save_macro_priority);
195
197
  if (setmacrocontext) {
196
 
        strcpy(chan->macrocontext, "");
197
 
        strcpy(chan->macroexten, "");
 
198
        chan->macrocontext[0] = '\0';
 
199
        chan->macroexten[0] = '\0';
198
200
        chan->macropriority = 0;
199
201
  }
200
202