app_senddtmf.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Asterisk -- A telephony toolkit for Linux.
  3. *
  4. * App to send DTMF digits
  5. *
  6. * Copyright (C) 1999, Mark Spencer
  7. *
  8. * Mark Spencer <markster@linux-support.net>
  9. *
  10. * This program is free software, distributed under the terms of
  11. * the GNU General Public License
  12. */
  13. #include <asterisk/lock.h>
  14. #include <asterisk/file.h>
  15. #include <asterisk/logger.h>
  16. #include <asterisk/channel.h>
  17. #include <asterisk/pbx.h>
  18. #include <asterisk/module.h>
  19. #include <asterisk/translate.h>
  20. #include <asterisk/options.h>
  21. #include <asterisk/utils.h>
  22. #include <asterisk/app.h>
  23. #include <string.h>
  24. #include <stdlib.h>
  25. static char *tdesc = "Send DTMF digits Application";
  26. static char *app = "SendDTMF";
  27. static char *synopsis = "Sends arbitrary DTMF digits";
  28. static char *descrip =
  29. " SendDTMF(digits): Sends DTMF digits on a channel. \n"
  30. " Accepted digits: 0-9, *#abcd\n"
  31. " Returns 0 on success or -1 on a hangup.\n";
  32. STANDARD_LOCAL_USER;
  33. LOCAL_USER_DECL;
  34. static int senddtmf_exec(struct ast_channel *chan, void *data)
  35. {
  36. int res = 0;
  37. struct localuser *u;
  38. char *digits = data;
  39. if (!digits || ast_strlen_zero(digits)) {
  40. ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
  41. return -1;
  42. }
  43. LOCAL_USER_ADD(u);
  44. res = ast_dtmf_stream(chan,NULL,digits,250);
  45. LOCAL_USER_REMOVE(u);
  46. return res;
  47. }
  48. int unload_module(void)
  49. {
  50. STANDARD_HANGUP_LOCALUSERS;
  51. return ast_unregister_application(app);
  52. }
  53. int load_module(void)
  54. {
  55. return ast_register_application(app, senddtmf_exec, synopsis, descrip);
  56. }
  57. char *description(void)
  58. {
  59. return tdesc;
  60. }
  61. int usecount(void)
  62. {
  63. int res;
  64. STANDARD_USECOUNT(res);
  65. return res;
  66. }
  67. char *key()
  68. {
  69. return ASTERISK_GPL_KEY;
  70. }