mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 16:50:14 +00:00
Minor formatting fixes for pbx_wilcalu
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3358 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
* Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
@@ -34,20 +34,20 @@
|
||||
#include "../astconf.h"
|
||||
|
||||
|
||||
// Globals
|
||||
/* Globals */
|
||||
const char dialfile[255];
|
||||
static char *tdesc = "Wil Cal U (Auto Dialer)";
|
||||
static pthread_t autodialer_thread;
|
||||
static char buf[257];
|
||||
static char lastbuf[257];//contains last partial buffer
|
||||
static char lastbuf[257]; /* contains last partial buffer */
|
||||
static char sendbuf[257];
|
||||
STANDARD_LOCAL_USER;
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
//prototype
|
||||
/* prototype */
|
||||
static void *dialstring(void *string);
|
||||
|
||||
// types
|
||||
/* types */
|
||||
struct alarm_data {
|
||||
time_t alarm_time;
|
||||
int snooze_len;
|
||||
@@ -61,6 +61,7 @@ static void *autodial(void *ignore)
|
||||
int fd=open(dialfile,O_RDONLY|O_NONBLOCK);
|
||||
int flags = fcntl(fd, F_GETFL);
|
||||
struct pollfd fds[1];
|
||||
|
||||
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Entered Wil-Calu fd=%d\n",fd);
|
||||
@@ -123,20 +124,24 @@ static void *autodial(void *ignore)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *snooze_alarm(void *pass){
|
||||
|
||||
static void *snooze_alarm(void *pass)
|
||||
{
|
||||
pthread_t dialstring_thread;
|
||||
struct alarm_data *data = (struct alarm_data *) pass;
|
||||
|
||||
sleep(data->snooze_len);
|
||||
pthread_create(&dialstring_thread, NULL, dialstring, data->dialstr);
|
||||
// dialstring will free data->dialstr
|
||||
/* dialstring will free data->dialstr */
|
||||
free(pass);
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
static void set_snooze_alarm(char *dialstr,int snooze_len){
|
||||
|
||||
static void set_snooze_alarm(char *dialstr, int snooze_len)
|
||||
{
|
||||
pthread_t snooze_alarm_thread;
|
||||
struct alarm_data *pass;
|
||||
|
||||
ast_log(LOG_DEBUG, "Answered: Snooze Requested\n");
|
||||
if (NULL==(pass=malloc(sizeof(struct alarm_data)))){
|
||||
perror("snooze_alarm: data");
|
||||
@@ -151,16 +156,17 @@ static void set_snooze_alarm(char *dialstr,int snooze_len){
|
||||
pthread_create(&snooze_alarm_thread,NULL,snooze_alarm,pass);
|
||||
}
|
||||
|
||||
static void *dialstring(void *string){
|
||||
static void *dialstring(void *string)
|
||||
{
|
||||
struct ast_channel *channel;
|
||||
char *bufptr,*destptr;
|
||||
// ms affects number of rings
|
||||
int ms=10000;
|
||||
int ms=10000; /* ms affects number of rings */
|
||||
int cnt=0,first;
|
||||
char tech[256];
|
||||
char tele[256];
|
||||
char filename[256];
|
||||
int answered=0;
|
||||
|
||||
for(first=0, bufptr=(char *)string, destptr=tech; *bufptr&&cnt<256; cnt++){
|
||||
if(*bufptr=='/' && !first) {
|
||||
*destptr=0;
|
||||
@@ -188,8 +194,7 @@ static void *dialstring(void *string){
|
||||
channel=ast_request(tech,AST_FORMAT_SLINEAR,tele);
|
||||
if(channel!=NULL){
|
||||
ast_call(channel,tele,10000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Autodial:Sorry unable to obtain channel\n");
|
||||
free(string);
|
||||
pthread_exit(NULL);
|
||||
@@ -198,6 +203,7 @@ static void *dialstring(void *string){
|
||||
ast_log(LOG_DEBUG, "Autodial:Line is Up\n");
|
||||
while(ms>0){
|
||||
struct ast_frame *f;
|
||||
|
||||
ms=ast_waitfor(channel,ms);
|
||||
f=ast_read(channel);
|
||||
if(!f){
|
||||
@@ -209,8 +215,9 @@ static void *dialstring(void *string){
|
||||
ast_log(LOG_DEBUG, "Autodial:Phone Answered\n");
|
||||
if (channel->_state==AST_STATE_UP) {
|
||||
char res;
|
||||
|
||||
ast_streamfile(channel,filename,0);
|
||||
// Press Five for snooze
|
||||
/* Press Five for snooze */
|
||||
res=ast_waitstream(channel, "37");
|
||||
if(res=='3'){
|
||||
answered=1;
|
||||
@@ -240,6 +247,7 @@ static void *dialstring(void *string){
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
@@ -250,6 +258,7 @@ int unload_module(void)
|
||||
int load_module(void)
|
||||
{
|
||||
int val;
|
||||
|
||||
snprintf((char *)dialfile, sizeof(dialfile)-1,"%s/%s", (char *)ast_config_AST_RUN_DIR,"autodial.ctl");
|
||||
if((val=mkfifo(dialfile, 0700))) {
|
||||
if(errno!=EEXIST){
|
||||
|
||||
Reference in New Issue
Block a user