[Asterisk-cvs] asterisk/apps app_parkandannounce.c,1.5,1.6

jeremy at lists.digium.com jeremy at lists.digium.com
Wed May 5 23:11:26 CDT 2004


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv6463

Modified Files:
	app_parkandannounce.c 
Log Message:
fix formatting, from bkw


Index: app_parkandannounce.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_parkandannounce.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- app_parkandannounce.c	25 Apr 2004 19:44:03 -0000	1.5
+++ app_parkandannounce.c	6 May 2004 03:20:05 -0000	1.6
@@ -55,175 +55,171 @@
 
 static int parkandannounce_exec(struct ast_channel *chan, void *data)
 {
-  int res=0;
-  char *return_context;
-  int l, lot, timeout = 0, dres;
-  char *working, *context, *exten, *priority, *dial, *dialtech, *dialstr;
-  char *template, *tpl_working, *tpl_current;
-  char *tmp[100];
-  int looptemp=0,i=0;
-  char *s,*orig_s;
+	int res=0;
+	char *return_context;
+	int l, lot, timeout = 0, dres;
+	char *working, *context, *exten, *priority, *dial, *dialtech, *dialstr;
+	char *template, *tpl_working, *tpl_current;
+	char *tmp[100];
+	int looptemp=0,i=0;
+	char *s,*orig_s;
 
-  struct ast_channel *dchan;
-  int outstate;
+	struct ast_channel *dchan;
+	int outstate;
 
-  struct localuser *u;
-  if (!data || (data && !strlen(data))) {
-    ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
-    return -1;
-  }
+	struct localuser *u;
+	if(!data || (data && !strlen(data))) {
+		ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
+		return -1;
+	}
   
-  l=strlen(data)+2;
-  orig_s=malloc(l);
-  if (!orig_s) {
-    ast_log(LOG_WARNING, "Out of memory\n");
-    return -1;
-  }
-  s=orig_s;
-  strncpy(s,data,l);
+	l=strlen(data)+2;
+	orig_s=malloc(l);
+	if(!orig_s) {
+		ast_log(LOG_WARNING, "Out of memory\n");
+		return -1;
+	}
+	s=orig_s;
+	strncpy(s,data,l);
 
-  template=strsep(&s,"|");
-  if (! template) {
-    ast_log(LOG_WARNING, "PARK: An announce template must be defined\n");
-    free(orig_s);
-    return -1;
-  }
+	template=strsep(&s,"|");
+	if(! template) {
+		ast_log(LOG_WARNING, "PARK: An announce template must be defined\n");
+		free(orig_s);
+		return -1;
+	}
   
-  if (s) {
-    timeout = atoi(strsep(&s, "|"));
-    timeout *= 1000;
-  }
-  dial=strsep(&s, "|");
-  if (! dial) {
-    ast_log(LOG_WARNING, "PARK: A dial resouce must be specified i.e: Console/dsp or Zap/g1/5551212\n");
-    free(orig_s);
-    return -1;
-  }
-  else {
-    dialtech=strsep(&dial, "/");
-    dialstr=dial;
-    ast_verbose( VERBOSE_PREFIX_3 "Dial Tech,String: (%s,%s)\n", dialtech,dialstr);
-  }
+	if(s) {
+		timeout = atoi(strsep(&s, "|"));
+		timeout *= 1000;
+	}
+	dial=strsep(&s, "|");
+	if(!dial) {
+		ast_log(LOG_WARNING, "PARK: A dial resouce must be specified i.e: Console/dsp or Zap/g1/5551212\n");
+		free(orig_s);
+		return -1;
+	} else {
+		dialtech=strsep(&dial, "/");
+		dialstr=dial;
+		ast_verbose( VERBOSE_PREFIX_3 "Dial Tech,String: (%s,%s)\n", dialtech,dialstr);
+	}
 
-  return_context = s;
+	return_context = s;
   
-  if (return_context != NULL) {
-    /* set the return context. Code borrowed from the Goto builtin */
+	if(return_context != NULL) {
+		/* set the return context. Code borrowed from the Goto builtin */
     
-    working = return_context;
-    context = strsep(&working, "|");
-    exten = strsep(&working, "|");
-    if (!exten) {
-      /* Only a priority in this one */
-      priority = context;
-      exten = NULL;
-      context = NULL;
-    } else {
-      priority = strsep(&working, "|");
-      if (!priority) {
-	/* Only an extension and priority in this one */
-	priority = exten;
-	exten = context;
-	context = NULL;
-      }
-    }
-    if (atoi(priority) < 0) {
-      ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority);
-      free(orig_s);
-      return -1;
-    }
-    /* At this point we have a priority and maybe an extension and a context */
-    chan->priority = atoi(priority);
-    if (exten && strcasecmp(exten, "BYEXTENSION"))
-      strncpy(chan->exten, exten, sizeof(chan->exten)-1);
-    if (context)
-      strncpy(chan->context, context, sizeof(chan->context)-1);
-  }
-  else {  /* increment the priority by default*/
-    chan->priority++;
-  }
+		working = return_context;
+		context = strsep(&working, "|");
+		exten = strsep(&working, "|");
+		if(!exten) {
+			/* Only a priority in this one */
+			priority = context;
+			exten = NULL;
+			context = NULL;
+		} else {
+			priority = strsep(&working, "|");
+			if(!priority) {
+				/* Only an extension and priority in this one */
+				priority = exten;
+				exten = context;
+				context = NULL;
+		}
+	}
+	if(atoi(priority) < 0) {
+		ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority);
+		free(orig_s);
+		return -1;
+	}
+	/* At this point we have a priority and maybe an extension and a context */
+	chan->priority = atoi(priority);
+	if(exten && strcasecmp(exten, "BYEXTENSION"))
+		strncpy(chan->exten, exten, sizeof(chan->exten)-1);
+	if(context)
+		strncpy(chan->context, context, sizeof(chan->context)-1);
+	} else {  /* increment the priority by default*/
+		chan->priority++;
+	}
 
 
-  if (option_verbose > 2) {
-    ast_verbose( VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n", chan->context,chan->exten, chan->priority, chan->callerid);
-    if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
-      ast_verbose( VERBOSE_PREFIX_3 "Warning: Return Context Invalid, call will return to default|s\n");
-    }
-  }
+	if(option_verbose > 2) {
+		ast_verbose( VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n", chan->context,chan->exten, chan->priority, chan->callerid);
+		if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
+			ast_verbose( VERBOSE_PREFIX_3 "Warning: Return Context Invalid, call will return to default|s\n");
+		}
+	}
   
-  LOCAL_USER_ADD(u);
+	LOCAL_USER_ADD(u);
 
-  /* we are using masq_park here to protect * from touching the channel once we park it.  If the channel comes out of timeout
-     before we are done announcing and the channel is messed with, Kablooeee.  So we use Masq to prevent this.  */
+	/* we are using masq_park here to protect * from touching the channel once we park it.  If the channel comes out of timeout
+	before we are done announcing and the channel is messed with, Kablooeee.  So we use Masq to prevent this.  */
 
-  ast_masq_park_call(chan, NULL, timeout, &lot);
+	ast_masq_park_call(chan, NULL, timeout, &lot);
 
-  res=-1; 
+	res=-1; 
 
-  ast_verbose( VERBOSE_PREFIX_3 "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, return_context);
+	ast_verbose( VERBOSE_PREFIX_3 "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, return_context);
 
-  /* Now place the call to the extention */
+	/* Now place the call to the extention */
 
-  dchan = ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->callerid);
+	dchan = ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->callerid);
 
-  if (dchan) {
-    if (dchan->_state == AST_STATE_UP) {
-      if (option_verbose > 3)
-	ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", dchan->name);
-    } else {
-      if (option_verbose > 3)
-	ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", dchan->name);
-        ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name);
-      ast_hangup(dchan);
-      free(orig_s);
-      LOCAL_USER_REMOVE(u);
-      return -1;
-    }
-  }
-  else {
-    ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
-    free(orig_s);
-    LOCAL_USER_REMOVE(u);
-    return -1; 
-  }
+	if(dchan) {
+		if(dchan->_state == AST_STATE_UP) {
+			if(option_verbose > 3)
+				ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", dchan->name);
+		} else {
+			if(option_verbose > 3)
+				ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", dchan->name);
+        			ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name);
+			ast_hangup(dchan);
+			free(orig_s);
+			LOCAL_USER_REMOVE(u);
+			return -1;
+		}
+	} else {
+		ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
+		free(orig_s);
+		LOCAL_USER_REMOVE(u);
+		return -1; 
+	}
 
-  ast_stopstream(dchan);
+	ast_stopstream(dchan);
 
-  /* now we have the call placed and are ready to play stuff to it */
+	/* now we have the call placed and are ready to play stuff to it */
 
-  ast_verbose(VERBOSE_PREFIX_4 "Announce Template:%s\n", template);
+	ast_verbose(VERBOSE_PREFIX_4 "Announce Template:%s\n", template);
 
-  tpl_working = template;
-  tpl_current=strsep(&tpl_working, ":");
+	tpl_working = template;
+	tpl_current=strsep(&tpl_working, ":");
 
-  while ( tpl_current && looptemp < sizeof(tmp)) {
-    tmp[looptemp]=tpl_current;
-    looptemp++;
-    tpl_current=strsep(&tpl_working,":");
-  }
+	while(tpl_current && looptemp < sizeof(tmp)) {
+		tmp[looptemp]=tpl_current;
+		looptemp++;
+		tpl_current=strsep(&tpl_working,":");
+	}
 
-  for(i=0; i<looptemp; i++) {
-    ast_verbose(VERBOSE_PREFIX_4 "Announce:%s\n", tmp[i]);
-    if (!strcmp(tmp[i], "PARKED")) {
-      ast_say_digits(dchan, lot, "", dchan->language);
-    }
-    else {
-      dres = ast_streamfile(dchan, tmp[i], dchan->language);
-      if (!dres)
-	dres = ast_waitstream(dchan, "");
-      else {
-	ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", tmp[i], dchan->name);
-	dres = 0;
-      }
-    }
-  }
+	for(i=0; i<looptemp; i++) {
+		ast_verbose(VERBOSE_PREFIX_4 "Announce:%s\n", tmp[i]);
+		if(!strcmp(tmp[i], "PARKED")) {
+			ast_say_digits(dchan, lot, "", dchan->language);
+		} else {
+			dres = ast_streamfile(dchan, tmp[i], dchan->language);
+			if(!dres) {
+				dres = ast_waitstream(dchan, "");
+			} else {
+				ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", tmp[i], dchan->name);
+				dres = 0;
+			}
+		}
+	}
 
-  ast_stopstream(dchan);  
-  ast_hangup(dchan);
+	ast_stopstream(dchan);  
+	ast_hangup(dchan);
 
-  LOCAL_USER_REMOVE(u);
-  free(orig_s);
-  return res;
+	LOCAL_USER_REMOVE(u);
+	free(orig_s);
+	return res;
 }
 
 
@@ -236,8 +232,8 @@
 
 int load_module(void)
 {
-  /*	return ast_register_application(app, park_exec); */
-  return ast_register_application(app, parkandannounce_exec, synopsis, descrip);
+	/* return ast_register_application(app, park_exec); */
+	return ast_register_application(app, parkandannounce_exec, synopsis, descrip);
 }
 
 char *description(void)




More information about the svn-commits mailing list