Newer
Older
/*
* Asterisk -- A telephony toolkit for Linux.
*
* Say numbers and dates (maybe words one day too)
*
*
* Mark Spencer <markster@linux-support.net>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
*/
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <time.h>
#include <asterisk/file.h>
#include <asterisk/channel.h>
#include <asterisk/logger.h>
#include <asterisk/say.h>
#include <asterisk/lock.h>
#include <asterisk/localtime.h>
#include "asterisk.h"
Mark Spencer
committed
/* Forward declaration */
static int wait_file(struct ast_channel *chan, char *ints, char *file, char *lang);
int ast_say_digit_str(struct ast_channel *chan, char *fn2, char *ints, char *lang)
char fn[256] = "";
int num = 0;
int res = 0;
while(fn2[num] && !res) {
switch (fn2[num]) {
case ('*'):
snprintf(fn, sizeof(fn), "digits/star");
break;
case ('#'):
snprintf(fn, sizeof(fn), "digits/pound");
break;
default:
if((fn2[num] >= '0') && (fn2[num] <= '9')){ /* Must be in {0-9} */
snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
}
if(!ast_strlen_zero(fn)){ /* if length == 0, then skip this digit as it is invalid */
res = ast_streamfile(chan, fn, lang);
res = ast_waitstream(chan, ints);
ast_stopstream(chan);
}
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
int ast_say_character_str(struct ast_channel *chan, char *fn2, char *ints, char *lang)
{
/* XXX Merge with full version? XXX */
char fn[256] = "";
char ltr;
int num = 0;
int res = 0;
while(fn2[num] && !res) {
fn[0] = '\0';
switch (fn2[num]) {
case ('*'):
snprintf(fn, sizeof(fn), "digits/star");
break;
case ('#'):
snprintf(fn, sizeof(fn), "digits/pound");
break;
case ('0'):
case ('1'):
case ('2'):
case ('3'):
case ('4'):
case ('5'):
case ('6'):
case ('7'):
case ('8'):
case ('9'):
snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
break;
case ('!'):
strncpy(fn, "letters/exclaimation-point", sizeof(fn));
break;
case ('@'):
strncpy(fn, "letters/at", sizeof(fn));
break;
case ('$'):
strncpy(fn, "letters/dollar", sizeof(fn));
break;
case ('-'):
strncpy(fn, "letters/dash", sizeof(fn));
break;
case ('.'):
strncpy(fn, "letters/dot", sizeof(fn));
break;
case ('='):
strncpy(fn, "letters/equals", sizeof(fn));
break;
case ('+'):
strncpy(fn, "letters/plus", sizeof(fn));
break;
case ('/'):
strncpy(fn, "letters/slash", sizeof(fn));
break;
case (' '):
strncpy(fn, "letters/space", sizeof(fn));
break;
default:
ltr = fn2[num];
if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */
snprintf(fn, sizeof(fn), "letters/%c", ltr);
}
if(!ast_strlen_zero(fn)) { /* if length == 0, then skip this digit as it is invalid */
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
} ast_stopstream(chan);
num++;
}
return res;
}
int ast_say_phonetic_str(struct ast_channel *chan, char *fn2, char *ints, char *lang)
{
/* XXX Merge with full version? XXX */
char fn[256] = "";
char ltr;
int num = 0;
int res = 0;
int temp;
int play;
char hex[3];
/* while(fn2[num] && !res) { */
while(fn2[num]) {
play=1;
switch (fn2[num]) {
case ('*'):
snprintf(fn, sizeof(fn), "digits/star");
break;
case ('#'):
snprintf(fn, sizeof(fn), "digits/pound");
break;
case ('0'):
case ('1'):
case ('2'):
case ('3'):
case ('4'):
case ('5'):
case ('6'):
case ('7'):
case ('8'):
snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
break;
case ('!'):
strncpy(fn, "exclaimation-point", sizeof(fn));
break;
case ('@'):
strncpy(fn, "at", sizeof(fn));
break;
case ('$'):
strncpy(fn, "dollar", sizeof(fn));
break;
case ('-'):
strncpy(fn, "dash", sizeof(fn));
break;
case ('.'):
strncpy(fn, "dot", sizeof(fn));
break;
case ('='):
strncpy(fn, "equals", sizeof(fn));
break;
case ('+'):
strncpy(fn, "plus", sizeof(fn));
break;
case ('/'):
strncpy(fn, "slash", sizeof(fn));
break;
case (' '):
strncpy(fn, "space", sizeof(fn));
break;
case ('%'):
play=0;
/* check if we have 2 chars after the % */
{
hex[0]=fn2[num+1];
hex[1]=fn2[num+2];
hex[2]='\0';
Loading
Loading full blame...