| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#include "asterisk.h" |
| 30 |
|
| 31 |
#include "asterisk/pbx.h" |
| 32 |
#include "asterisk/file.h" |
| 33 |
#include "asterisk/channel.h" |
| 34 |
#include "asterisk/say.h" |
| 35 |
#include "asterisk/lock.h" |
| 36 |
#include "asterisk/localtime.h" |
| 37 |
#include "asterisk/utils.h" |
| 38 |
#include "asterisk/app.h" |
| 39 |
#include "asterisk/test.h" |
| 40 |
#include "asterisk/module.h" |
| 41 |
#include "asterisk/conversions.h" |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 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 |
static int sayfile_exec(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| 99 |
{ |
| 100 |
char *value, *type, *files; |
| 101 |
const char *lang; |
| 102 |
struct ast_str *filenames = NULL; |
| 103 |
AST_DECLARE_APP_ARGS(args, |
| 104 |
AST_APP_ARG(value); |
| 105 |
AST_APP_ARG(type); |
| 106 |
); |
| 107 |
|
| 108 |
if (ast_strlen_zero(data)) { |
| 109 |
ast_log(LOG_WARNING, "SAYFILES requires an argument\n"); |
| 110 |
return 0; |
| 111 |
} |
| 112 |
|
| 113 |
AST_STANDARD_APP_ARGS(args, data); |
| 114 |
|
| 115 |
value = args.value; |
| 116 |
type = (ast_strlen_zero(args.type) ? "alpha" : args.type); |
| 117 |
lang = (chan ? ast_channel_language(chan) : "en"); |
| 118 |
|
| 119 |
if (!strcmp(type, "alpha")) { |
| 120 |
filenames = ast_get_character_str(value, lang, AST_SAY_CASE_NONE); |
| 121 |
} else if (!strcmp(type, "phonetic")) { |
| 122 |
filenames = ast_get_phonetic_str(value, lang); |
| 123 |
} else if (!strcmp(type, "digits")) { |
| 124 |
filenames = ast_get_digit_str(value, lang); |
| 125 |
} else if (!strcmp(type, "number")) { |
| 126 |
int num; |
| 127 |
if (ast_str_to_int(value, &num)) { |
| 128 |
ast_log(LOG_WARNING, "Invalid numeric argument: %s\n", value); |
| 129 |
} else { |
| 130 |
filenames = ast_get_number_str(num, lang); |
| 131 |
} |
| 132 |
} else if (!strcmp(type, "ordinal")) { |
| 133 |
int num; |
| 134 |
if (ast_str_to_int(value, &num)) { |
| 135 |
ast_log(LOG_WARNING, "Invalid numeric argument: %s\n", value); |
| 136 |
} else { |
| 137 |
filenames = ast_get_ordinal_str(num, lang); |
| 138 |
} |
| 139 |
} else if (!strcmp(type, "money")) { |
| 140 |
filenames = ast_get_money_str(value, lang); |
| 141 |
} else { |
| 142 |
ast_log(LOG_WARNING, "Invalid say type specified: %s\n", type); |
| 143 |
} |
| 144 |
|
| 145 |
if (!filenames) { |
| 146 |
return -1; |
| 147 |
} |
| 148 |
|
| 149 |
files = ast_str_buffer(filenames); |
| 150 |
snprintf(buf, len, "%s", files); |
| 151 |
ast_free(filenames); |
| 152 |
|
| 153 |
return 0; |
| 154 |
} |
| 155 |
|
| 156 |
static struct ast_custom_function sayfiles = { |
| 157 |
.name = "SAYFILES", |
| 158 |
.read = sayfile_exec, |
| 159 |
}; |
| 160 |
|
| 161 |
#ifdef TEST_FRAMEWORK |
| 162 |
AST_TEST_DEFINE(test_SAYFILES_function) |
| 163 |
{ |
| 164 |
enum ast_test_result_state res = AST_TEST_PASS; |
| 165 |
struct ast_str *expr, *result; |
| 166 |
|
| 167 |
switch (cmd) { |
| 168 |
case TEST_INIT: |
| 169 |
info->name = "test_SAYFILES_function"; |
| 170 |
info->category = "/funcs/func_sayfiles/"; |
| 171 |
info->summary = "Test SAYFILES function substitution"; |
| 172 |
info->description = |
| 173 |
"Executes a series of variable substitutions using the SAYFILES function and ensures that the expected results are received."; |
| 174 |
return AST_TEST_NOT_RUN; |
| 175 |
case TEST_EXECUTE: |
| 176 |
break; |
| 177 |
} |
| 178 |
|
| 179 |
ast_test_status_update(test, "Testing SAYFILES() substitution ...\n"); |
| 180 |
|
| 181 |
if (!(expr = ast_str_create(16))) { |
| 182 |
return AST_TEST_FAIL; |
| 183 |
} |
| 184 |
if (!(result = ast_str_create(16))) { |
| 185 |
ast_free(expr); |
| 186 |
return AST_TEST_FAIL; |
| 187 |
} |
| 188 |
|
| 189 |
ast_str_set(&expr, 0, "${SAYFILES(hi Th3re,alpha)}"); |
| 190 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 191 |
if (strcmp(ast_str_buffer(result), "letters/h&letters/i&letters/space&letters/t&letters/h&digits/3&letters/r&letters/e") != 0) { |
| 192 |
ast_test_status_update(test, "SAYFILES(hi Th3re,alpha) test failed ('%s')\n", |
| 193 |
ast_str_buffer(result)); |
| 194 |
res = AST_TEST_FAIL; |
| 195 |
} |
| 196 |
|
| 197 |
ast_str_set(&expr, 0, "${SAYFILES(phreak,phonetic)}"); |
| 198 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 199 |
if (strcmp(ast_str_buffer(result), "phonetic/p_p&phonetic/h_p&phonetic/r_p&phonetic/e_p&phonetic/a_p&phonetic/k_p") != 0) { |
| 200 |
ast_test_status_update(test, "SAYFILES(phreak,phonetic) test failed ('%s')\n", |
| 201 |
ast_str_buffer(result)); |
| 202 |
res = AST_TEST_FAIL; |
| 203 |
} |
| 204 |
|
| 205 |
ast_str_set(&expr, 0, "${SAYFILES(35,digits)}"); |
| 206 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 207 |
if (strcmp(ast_str_buffer(result), "digits/3&digits/5") != 0) { |
| 208 |
ast_test_status_update(test, "SAYFILES(35,digits) test failed ('%s')\n", |
| 209 |
ast_str_buffer(result)); |
| 210 |
res = AST_TEST_FAIL; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
ast_str_set(&expr, 0, "${SAYFILES(+18005551212,digits)}"); |
| 215 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 216 |
if (strcmp(ast_str_buffer(result), "digits/1&digits/8&digits/0&digits/0&digits/5&digits/5&digits/5&digits/1&digits/2&digits/1&digits/2") != 0) { |
| 217 |
ast_test_status_update(test, "SAYFILES(+18005551212,digits) test failed ('%s')\n", |
| 218 |
ast_str_buffer(result)); |
| 219 |
res = AST_TEST_FAIL; |
| 220 |
} |
| 221 |
|
| 222 |
ast_str_set(&expr, 0, "${SAYFILES(35,number)}"); |
| 223 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 224 |
if (strcmp(ast_str_buffer(result), "digits/30&digits/5") != 0) { |
| 225 |
ast_test_status_update(test, "SAYFILES(35,number) test failed ('%s')\n", |
| 226 |
ast_str_buffer(result)); |
| 227 |
res = AST_TEST_FAIL; |
| 228 |
} |
| 229 |
|
| 230 |
ast_str_set(&expr, 0, "${SAYFILES(747,number)}"); |
| 231 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 232 |
if (strcmp(ast_str_buffer(result), "digits/7&digits/hundred&digits/40&digits/7") != 0) { |
| 233 |
ast_test_status_update(test, "SAYFILES(747,number) test failed ('%s')\n", |
| 234 |
ast_str_buffer(result)); |
| 235 |
res = AST_TEST_FAIL; |
| 236 |
} |
| 237 |
|
| 238 |
ast_str_set(&expr, 0, "${SAYFILES(1042,number)}"); |
| 239 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 240 |
if (strcmp(ast_str_buffer(result), "digits/1&digits/thousand&digits/40&digits/2") != 0) { |
| 241 |
ast_test_status_update(test, "SAYFILES(1042,number) test failed ('%s')\n", |
| 242 |
ast_str_buffer(result)); |
| 243 |
res = AST_TEST_FAIL; |
| 244 |
} |
| 245 |
|
| 246 |
ast_str_set(&expr, 0, "${SAYFILES(0,number)}"); |
| 247 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 248 |
if (strcmp(ast_str_buffer(result), "digits/0") != 0) { |
| 249 |
ast_test_status_update(test, "SAYFILES(0,digits) test failed ('%s')\n", |
| 250 |
ast_str_buffer(result)); |
| 251 |
res = AST_TEST_FAIL; |
| 252 |
} |
| 253 |
|
| 254 |
ast_str_set(&expr, 0, "${SAYFILES(2001000001,number)}"); |
| 255 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 256 |
if (strcmp(ast_str_buffer(result), "digits/2&digits/billion&digits/1&digits/million&digits/1") != 0) { |
| 257 |
ast_test_status_update(test, "SAYFILES(2001000001,number) test failed ('%s')\n", |
| 258 |
ast_str_buffer(result)); |
| 259 |
res = AST_TEST_FAIL; |
| 260 |
} |
| 261 |
|
| 262 |
ast_str_set(&expr, 0, "${SAYFILES(7,ordinal)}"); |
| 263 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 264 |
if (strcmp(ast_str_buffer(result), "digits/h-7") != 0) { |
| 265 |
ast_test_status_update(test, "SAYFILES(7,ordinal) test failed ('%s')\n", |
| 266 |
ast_str_buffer(result)); |
| 267 |
res = AST_TEST_FAIL; |
| 268 |
} |
| 269 |
|
| 270 |
ast_str_set(&expr, 0, "${SAYFILES(35,ordinal)}"); |
| 271 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 272 |
if (strcmp(ast_str_buffer(result), "digits/30&digits/h-5") != 0) { |
| 273 |
ast_test_status_update(test, "SAYFILES(35,ordinal) test failed ('%s')\n", |
| 274 |
ast_str_buffer(result)); |
| 275 |
res = AST_TEST_FAIL; |
| 276 |
} |
| 277 |
|
| 278 |
ast_str_set(&expr, 0, "${SAYFILES(1042,ordinal)}"); |
| 279 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 280 |
if (strcmp(ast_str_buffer(result), "digits/1&digits/thousand&digits/40&digits/h-2") != 0) { |
| 281 |
ast_test_status_update(test, "SAYFILES(1042,ordinal) test failed ('%s')\n", |
| 282 |
ast_str_buffer(result)); |
| 283 |
res = AST_TEST_FAIL; |
| 284 |
} |
| 285 |
|
| 286 |
ast_str_set(&expr, 0, "${SAYFILES(11042,ordinal)}"); |
| 287 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 288 |
if (strcmp(ast_str_buffer(result), "digits/11&digits/thousand&digits/40&digits/h-2") != 0) { |
| 289 |
ast_test_status_update(test, "SAYFILES(11042,ordinal) test failed ('%s')\n", |
| 290 |
ast_str_buffer(result)); |
| 291 |
res = AST_TEST_FAIL; |
| 292 |
} |
| 293 |
|
| 294 |
ast_str_set(&expr, 0, "${SAYFILES(40000,ordinal)}"); |
| 295 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 296 |
if (strcmp(ast_str_buffer(result), "digits/40&digits/h-thousand") != 0) { |
| 297 |
ast_test_status_update(test, "SAYFILES(40000,ordinal) test failed ('%s')\n", |
| 298 |
ast_str_buffer(result)); |
| 299 |
res = AST_TEST_FAIL; |
| 300 |
} |
| 301 |
|
| 302 |
ast_str_set(&expr, 0, "${SAYFILES(43638,ordinal)}"); |
| 303 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 304 |
if (strcmp(ast_str_buffer(result), "digits/40&digits/3&digits/thousand&digits/6&digits/hundred&digits/30&digits/h-8") != 0) { |
| 305 |
ast_test_status_update(test, "SAYFILES(43638,ordinal) test failed ('%s')\n", |
| 306 |
ast_str_buffer(result)); |
| 307 |
res = AST_TEST_FAIL; |
| 308 |
} |
| 309 |
|
| 310 |
ast_str_set(&expr, 0, "${SAYFILES(1000000,ordinal)}"); |
| 311 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 312 |
if (strcmp(ast_str_buffer(result), "digits/1&digits/h-million") != 0) { |
| 313 |
ast_test_status_update(test, "SAYFILES(1000000,ordinal) test failed ('%s')\n", |
| 314 |
ast_str_buffer(result)); |
| 315 |
res = AST_TEST_FAIL; |
| 316 |
} |
| 317 |
|
| 318 |
ast_str_set(&expr, 0, "${SAYFILES(1000001,ordinal)}"); |
| 319 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 320 |
if (strcmp(ast_str_buffer(result), "digits/1&digits/million&digits/h-1") != 0) { |
| 321 |
ast_test_status_update(test, "SAYFILES(1000001,ordinal) test failed ('%s')\n", |
| 322 |
ast_str_buffer(result)); |
| 323 |
res = AST_TEST_FAIL; |
| 324 |
} |
| 325 |
|
| 326 |
ast_str_set(&expr, 0, "${SAYFILES(2001000001,ordinal)}"); |
| 327 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 328 |
if (strcmp(ast_str_buffer(result), "digits/2&digits/billion&digits/1&digits/million&digits/h-1") != 0) { |
| 329 |
ast_test_status_update(test, "SAYFILES(2001000001,ordinal) test failed ('%s')\n", |
| 330 |
ast_str_buffer(result)); |
| 331 |
res = AST_TEST_FAIL; |
| 332 |
} |
| 333 |
|
| 334 |
ast_str_set(&expr, 0, "${SAYFILES(0,money)}"); |
| 335 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 336 |
if (strcmp(ast_str_buffer(result), "digits/0¢s") != 0) { |
| 337 |
ast_test_status_update(test, "SAYFILES(0,money) test failed ('%s')\n", |
| 338 |
ast_str_buffer(result)); |
| 339 |
res = AST_TEST_FAIL; |
| 340 |
} |
| 341 |
|
| 342 |
ast_str_set(&expr, 0, "${SAYFILES(0.01,money)}"); |
| 343 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 344 |
if (strcmp(ast_str_buffer(result), "digits/1¢") != 0) { |
| 345 |
ast_test_status_update(test, "SAYFILES(0.01,money) test failed ('%s')\n", |
| 346 |
ast_str_buffer(result)); |
| 347 |
res = AST_TEST_FAIL; |
| 348 |
} |
| 349 |
|
| 350 |
ast_str_set(&expr, 0, "${SAYFILES(0.42,money)}"); |
| 351 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 352 |
if (strcmp(ast_str_buffer(result), "digits/40&digits/2¢s") != 0) { |
| 353 |
ast_test_status_update(test, "SAYFILES(0.42,money) test failed ('%s')\n", |
| 354 |
ast_str_buffer(result)); |
| 355 |
res = AST_TEST_FAIL; |
| 356 |
} |
| 357 |
|
| 358 |
ast_str_set(&expr, 0, "${SAYFILES(.42,money)}"); |
| 359 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 360 |
if (strcmp(ast_str_buffer(result), "digits/40&digits/2¢s") != 0) { |
| 361 |
ast_test_status_update(test, "SAYFILES(.42,money) test failed ('%s')\n", |
| 362 |
ast_str_buffer(result)); |
| 363 |
res = AST_TEST_FAIL; |
| 364 |
} |
| 365 |
|
| 366 |
ast_str_set(&expr, 0, "${SAYFILES(1.00,money)}"); |
| 367 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 368 |
if (strcmp(ast_str_buffer(result), "digits/1&letters/dollar") != 0) { |
| 369 |
ast_test_status_update(test, "SAYFILES(1.00,money) test failed ('%s')\n", |
| 370 |
ast_str_buffer(result)); |
| 371 |
res = AST_TEST_FAIL; |
| 372 |
} |
| 373 |
|
| 374 |
ast_str_set(&expr, 0, "${SAYFILES(1.42,money)}"); |
| 375 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 376 |
if (strcmp(ast_str_buffer(result), "digits/1&letters/dollar_&and&digits/40&digits/2¢s") != 0) { |
| 377 |
ast_test_status_update(test, "SAYFILES(1.42,money) test failed ('%s')\n", |
| 378 |
ast_str_buffer(result)); |
| 379 |
res = AST_TEST_FAIL; |
| 380 |
} |
| 381 |
|
| 382 |
ast_str_set(&expr, 0, "${SAYFILES(2.00,money)}"); |
| 383 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 384 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars") != 0) { |
| 385 |
ast_test_status_update(test, "SAYFILES(2.00,money) test failed ('%s')\n", |
| 386 |
ast_str_buffer(result)); |
| 387 |
res = AST_TEST_FAIL; |
| 388 |
} |
| 389 |
|
| 390 |
ast_str_set(&expr, 0, "${SAYFILES(2,money)}"); |
| 391 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 392 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars") != 0) { |
| 393 |
ast_test_status_update(test, "SAYFILES(2,money) test failed ('%s')\n", |
| 394 |
ast_str_buffer(result)); |
| 395 |
res = AST_TEST_FAIL; |
| 396 |
} |
| 397 |
|
| 398 |
ast_str_set(&expr, 0, "${SAYFILES(2.42,money)}"); |
| 399 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 400 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars&and&digits/40&digits/2¢s") != 0) { |
| 401 |
ast_test_status_update(test, "SAYFILES(2.42,money) test failed ('%s')\n", |
| 402 |
ast_str_buffer(result)); |
| 403 |
res = AST_TEST_FAIL; |
| 404 |
} |
| 405 |
|
| 406 |
ast_str_set(&expr, 0, "${SAYFILES(2.05,money)}"); |
| 407 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 408 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars&and&digits/5¢s") != 0) { |
| 409 |
ast_test_status_update(test, "SAYFILES(2.05,money) test failed ('%s')\n", |
| 410 |
ast_str_buffer(result)); |
| 411 |
res = AST_TEST_FAIL; |
| 412 |
} |
| 413 |
|
| 414 |
ast_str_set(&expr, 0, "${SAYFILES(2.051,money)}"); |
| 415 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 416 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars&and&digits/5¢s") != 0) { |
| 417 |
ast_test_status_update(test, "SAYFILES(2.051,money) test failed ('%s')\n", |
| 418 |
ast_str_buffer(result)); |
| 419 |
res = AST_TEST_FAIL; |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
ast_str_set(&expr, 0, "${SAYFILES(blah,money)}"); |
| 424 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 425 |
if (strcmp(ast_str_buffer(result), "digits/0¢s") != 0) { |
| 426 |
ast_test_status_update(test, "SAYFILES(blah,money) test failed ('%s')\n", |
| 427 |
ast_str_buffer(result)); |
| 428 |
res = AST_TEST_FAIL; |
| 429 |
} |
| 430 |
|
| 431 |
ast_str_set(&expr, 0, "${SAYFILES(2blah.05,money)}"); |
| 432 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 433 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars") != 0) { |
| 434 |
ast_test_status_update(test, "SAYFILES(2blah.05,money) test failed ('%s')\n", |
| 435 |
ast_str_buffer(result)); |
| 436 |
res = AST_TEST_FAIL; |
| 437 |
} |
| 438 |
|
| 439 |
ast_str_set(&expr, 0, "${SAYFILES(2.-05,money)}"); |
| 440 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 441 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars") != 0) { |
| 442 |
ast_test_status_update(test, "SAYFILES(2.-05,money) test failed ('%s')\n", |
| 443 |
ast_str_buffer(result)); |
| 444 |
res = AST_TEST_FAIL; |
| 445 |
} |
| 446 |
|
| 447 |
ast_str_set(&expr, 0, "${SAYFILES(2. 05,money)}"); |
| 448 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 449 |
if (strcmp(ast_str_buffer(result), "digits/2&dollars") != 0) { |
| 450 |
ast_test_status_update(test, "SAYFILES(2. 05,money) test failed ('%s')\n", |
| 451 |
ast_str_buffer(result)); |
| 452 |
res = AST_TEST_FAIL; |
| 453 |
} |
| 454 |
|
| 455 |
ast_str_set(&expr, 0, "${SAYFILES(. 05,money)}"); |
| 456 |
ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr)); |
| 457 |
if (strcmp(ast_str_buffer(result), "digits/0¢s") != 0) { |
| 458 |
ast_test_status_update(test, "SAYFILES(. 05,money) test failed ('%s')\n", |
| 459 |
ast_str_buffer(result)); |
| 460 |
res = AST_TEST_FAIL; |
| 461 |
} |
| 462 |
|
| 463 |
ast_free(expr); |
| 464 |
ast_free(result); |
| 465 |
|
| 466 |
return res; |
| 467 |
} |
| 468 |
#endif |
| 469 |
|
| 470 |
static int unload_module(void) |
| 471 |
{ |
| 472 |
AST_TEST_UNREGISTER(test_SAYFILES_function); |
| 473 |
return ast_custom_function_unregister(&sayfiles); |
| 474 |
} |
| 475 |
|
| 476 |
static int load_module(void) |
| 477 |
{ |
| 478 |
AST_TEST_REGISTER(test_SAYFILES_function); |
| 479 |
return ast_custom_function_register(&sayfiles); |
| 480 |
} |
| 481 |
|
| 482 |
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Say application files"); |