Asterisk - The Open Source Telephony Project  18.5.0
include/asterisk/app.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <[email protected]>
7  * See http://www.asterisk.org for more information about
8  * the Asterisk project. Please do not directly contact
9  * any of the maintainers of this project for assistance;
10  * the project provides a web site, mailing lists and IRC
11  * channels for your use.
12  *
13  * This program is free software, distributed under the terms of
14  * the GNU General Public License Version 2. See the LICENSE file
15  * at the top of the source tree.
16  */
17 
18 /*! \file
19  * \brief Application convenience functions, designed to give consistent
20  * look and feel to Asterisk apps.
21  */
22 
23 #ifndef _ASTERISK_APP_H
24 #define _ASTERISK_APP_H
25 
26 #include "asterisk/stringfields.h"
27 #include "asterisk/strings.h"
28 #include "asterisk/threadstorage.h"
29 #include "asterisk/file.h"
30 #include "asterisk/linkedlists.h"
31 #include "asterisk/utils.h"
32 #include "asterisk/stasis.h"
33 
34 struct ast_flags64;
35 
36 #if defined(__cplusplus) || defined(c_plusplus)
37 extern "C" {
38 #endif
39 
40 AST_THREADSTORAGE_EXTERNAL(ast_str_thread_global_buf);
41 
42 /* IVR stuff */
43 
44 /*! \brief Callback function for IVR
45  \return returns 0 on completion, -1 on hangup or digit if interrupted
46  */
47 typedef int (ast_ivr_callback)(struct ast_channel *chan, char *option, void *cbdata);
48 
49 typedef enum {
50  AST_ACTION_UPONE, /*!< adata is unused */
51  AST_ACTION_EXIT, /*!< adata is the return value for ast_ivr_menu_run if channel was not hungup */
52  AST_ACTION_CALLBACK, /*!< adata is an ast_ivr_callback */
53  AST_ACTION_PLAYBACK, /*!< adata is file to play */
54  AST_ACTION_BACKGROUND, /*!< adata is file to play */
55  AST_ACTION_PLAYLIST, /*!< adata is list of files, separated by ; to play */
56  AST_ACTION_MENU, /*!< adata is a pointer to an ast_ivr_menu */
57  AST_ACTION_REPEAT, /*!< adata is max # of repeats, cast to a pointer */
58  AST_ACTION_RESTART, /*!< adata is like repeat, but resets repeats to 0 */
59  AST_ACTION_TRANSFER, /*!< adata is a string with exten\verbatim[@context]\endverbatim */
60  AST_ACTION_WAITOPTION, /*!< adata is a timeout, or 0 for defaults */
61  AST_ACTION_NOOP, /*!< adata is unused */
62  AST_ACTION_BACKLIST, /*!< adata is list of files separated by ; allows interruption */
64 
65 /*!
66  Special "options" are:
67  \arg "s" - "start here (one time greeting)"
68  \arg "g" - "greeting/instructions"
69  \arg "t" - "timeout"
70  \arg "h" - "hangup"
71  \arg "i" - "invalid selection"
72 
73 */
75  char *option;
76  ast_ivr_action action;
77  void *adata;
78 };
79 
80 struct ast_ivr_menu {
81  char *title; /*!< Title of menu */
82  unsigned int flags; /*!< Flags */
83  struct ast_ivr_option *options; /*!< All options */
84 };
85 
86 /*!
87  * \brief Structure used for ast_copy_recording_to_vm in order to cleanly supply
88  * data needed for making the recording from the recorded file.
89  */
94  AST_STRING_FIELD(folder);
95  AST_STRING_FIELD(recording_file);
96  AST_STRING_FIELD(recording_ext);
97 
98  AST_STRING_FIELD(call_context);
99  AST_STRING_FIELD(call_macrocontext);
100  AST_STRING_FIELD(call_extension);
101  AST_STRING_FIELD(call_callerchan);
102  AST_STRING_FIELD(call_callerid);
103  );
105 };
106 
107 #define AST_IVR_FLAG_AUTORESTART (1 << 0)
108 
109 #define AST_IVR_DECLARE_MENU(holder, title, flags, foo...) \
110  static struct ast_ivr_option __options_##holder[] = foo;\
111  static struct ast_ivr_menu holder = { title, flags, __options_##holder }
112 
118 };
119 
120 /*! \brief Runs an IVR menu
121  \return returns 0 on successful completion, -1 on hangup, or -2 on user error in menu */
122 int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata);
123 
124 /*! \brief Plays a stream and gets DTMF data from a channel
125  * \param c Which channel one is interacting with
126  * \param prompt File to pass to ast_streamfile (the one that you wish to play).
127  * It is also valid for this to be multiple files concatenated by "&".
128  * For example, "file1&file2&file3".
129  * \param s The location where the DTMF data will be stored
130  * \param maxlen Max Length of the data
131  * \param timeout Timeout length waiting for data(in milliseconds). Set to 0 for standard timeout(six seconds), or -1 for no time out.
132  *
133  * This function was designed for application programmers for situations where they need
134  * to play a message and then get some DTMF data in response to the message. If a digit
135  * is pressed during playback, it will immediately break out of the message and continue
136  * execution of your code.
137  */
138 int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout);
139 
140 /*! \brief Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other full functions */
141 int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd);
142 
143 /*!
144  * \brief Run a macro on a channel, placing an optional second channel into autoservice.
145  * \since 11.0
146  *
147  * \details
148  * This is a shorthand method that makes it very easy to run a
149  * macro on any given channel. It is perfectly reasonable to
150  * supply a NULL autoservice_chan here in case there is no
151  * channel to place into autoservice.
152  *
153  * \note Absolutely _NO_ channel locks should be held before calling this function.
154  *
155  * \param autoservice_chan A channel to place into autoservice while the macro is run
156  * \param macro_chan Channel to execute macro on.
157  * \param macro_args Macro application argument string.
158  *
159  * \retval 0 success
160  * \retval -1 on error
161  */
162 int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args);
163 
164 /*!
165  * \since 1.8
166  * \brief Run a macro on a channel, placing an optional second channel into autoservice.
167  *
168  * \details
169  * This is a shorthand method that makes it very easy to run a
170  * macro on any given channel. It is perfectly reasonable to
171  * supply a NULL autoservice_chan here in case there is no
172  * channel to place into autoservice.
173  *
174  * \note Absolutely _NO_ channel locks should be held before calling this function.
175  *
176  * \param autoservice_chan A channel to place into autoservice while the macro is run
177  * \param macro_chan Channel to execute macro on.
178  * \param macro_name The name of the macro to run.
179  * \param macro_args The arguments to pass to the macro.
180  *
181  * \retval 0 success
182  * \retval -1 on error
183  */
184 int ast_app_run_macro(struct ast_channel *autoservice_chan,
185  struct ast_channel *macro_chan, const char *macro_name, const char *macro_args);
186 
187 /*!
188  * \brief Stack applications callback functions.
189  */
191  /*!
192  * Module reference pointer so the module will stick around
193  * while a callback is active.
194  */
195  void *module;
196 
197  /*!
198  * \brief Callback for the routine to run a subroutine on a channel.
199  *
200  * \note Absolutely _NO_ channel locks should be held before calling this function.
201  *
202  * \param chan Channel to execute subroutine on.
203  * \param args Gosub application argument string.
204  * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
205  *
206  * \retval 0 success
207  * \retval -1 on error
208  */
209  int (*run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup);
210 
211  /*!
212  * \brief Add missing context/exten to Gosub application argument string.
213  *
214  * \param chan Channel to obtain context/exten.
215  * \param args Gosub application argument string.
216  *
217  * \details
218  * Fills in the optional context and exten from the given channel.
219  *
220  * \retval New-args Gosub argument string on success. Must be freed.
221  * \retval NULL on error.
222  */
223  const char *(*expand_sub_args)(struct ast_channel *chan, const char *args);
224 
225  /* Add new API calls to the end here. */
226 };
227 
228 /*!
229  * \since 11
230  * \brief Set stack application function callbacks
231  * \param funcs Stack applications callback functions.
232  */
233 void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs);
234 
235 /*!
236  * \brief Add missing context/exten to subroutine argument string.
237  *
238  * \param chan Channel to obtain context/exten.
239  * \param args Gosub application argument string.
240  *
241  * \details
242  * Fills in the optional context and exten from the given channel.
243  *
244  * \retval New-args Gosub argument string on success. Must be freed.
245  * \retval NULL on error.
246  */
247 const char *ast_app_expand_sub_args(struct ast_channel *chan, const char *args);
248 
249 /*!
250  * \since 11
251  * \brief Run a subroutine on a channel, placing an optional second channel into autoservice.
252  *
253  * \details
254  * This is a shorthand method that makes it very easy to run a
255  * subroutine on any given channel. It is perfectly reasonable
256  * to supply a NULL autoservice_chan here in case there is no
257  * channel to place into autoservice.
258  *
259  * \note Absolutely _NO_ channel locks should be held before calling this function.
260  *
261  * \param autoservice_chan A channel to place into autoservice while the subroutine is run
262  * \param sub_chan Channel to execute subroutine on.
263  * \param sub_args Gosub application argument string.
264  * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
265  *
266  * \retval 0 success
267  * \retval -1 on error
268  */
269 int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup);
270 
271 /*!
272  * \since 11
273  * \brief Run a subroutine on a channel, placing an optional second channel into autoservice.
274  *
275  * \details
276  * This is a shorthand method that makes it very easy to run a
277  * subroutine on any given channel. It is perfectly reasonable
278  * to supply a NULL autoservice_chan here in case there is no
279  * channel to place into autoservice.
280  *
281  * \note Absolutely _NO_ channel locks should be held before calling this function.
282  *
283  * \param autoservice_chan A channel to place into autoservice while the subroutine is run
284  * \param sub_chan Channel to execute subroutine on.
285  * \param sub_location The location of the subroutine to run.
286  * \param sub_args The arguments to pass to the subroutine.
287  * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
288  *
289  * \retval 0 success
290  * \retval -1 on error
291  */
292 int ast_app_run_sub(struct ast_channel *autoservice_chan,
293  struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup);
294 
298 };
299 
302  AST_STRING_FIELD(msg_id);
303  AST_STRING_FIELD(callerid);
304  AST_STRING_FIELD(callerchan);
306  AST_STRING_FIELD(origdate);
307  AST_STRING_FIELD(origtime);
308  AST_STRING_FIELD(duration);
309  AST_STRING_FIELD(folder_name);
311  );
312  unsigned int msg_number;
313 
315 };
316 
319  int folders;
320  /* Things are not quite as they seem here. This points to an allocated array of lists. */
322 };
323 
324 /*!
325  * \brief Voicemail playback callback function definition
326  *
327  * \param chan Channel to play the file back on.
328  * \param playfile Location of file on disk
329  * \param duration of file in seconds. This will be zero if msg is very short or
330  * has an unknown duration.
331  */
332 typedef void (ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration);
333 
334 /*!
335  * \brief Determines if the given folder has messages.
336  *
337  * \param mailboxes Comma or & delimited list of mailboxes (user@context).
338  * If no context is found, uses 'default' for the context.
339  * \param folder The folder to look in. Default is INBOX if not provided.
340  *
341  * \retval 1 if the folder has one or more messages.
342  * \retval 0 otherwise.
343  */
344 typedef int (ast_has_voicemail_fn)(const char *mailboxes, const char *folder);
345 
346 /*!
347  * \brief Gets the number of messages that exist for the mailbox list.
348  *
349  * \param mailboxes Comma or space delimited list of mailboxes (user@context).
350  * If no context is found, uses 'default' for the context.
351  * \param newmsgs Where to put the count of new messages. (Can be NULL)
352  * \param oldmsgs Where to put the count of old messages. (Can be NULL)
353  *
354  * \details
355  * Simultaneously determines the count of new + urgent and old
356  * messages. The total messages would then be the sum of these.
357  *
358  * \retval 0 on success
359  * \retval -1 on failure
360  */
361 typedef int (ast_inboxcount_fn)(const char *mailboxes, int *newmsgs, int *oldmsgs);
362 
363 /*!
364  * \brief Gets the number of messages that exist for the mailbox list.
365  *
366  * \param mailboxes Comma or space delimited list of mailboxes (user@context).
367  * If no context is found, uses 'default' for the context.
368  * \param urgentmsgs Where to put the count of urgent messages. (Can be NULL)
369  * \param newmsgs Where to put the count of new messages. (Can be NULL)
370  * \param oldmsgs Where to put the count of old messages. (Can be NULL)
371  *
372  * \details
373  * Simultaneously determines the count of new, old, and urgent
374  * messages. The total messages would then be the sum of these
375  * three.
376  *
377  * \retval 0 on success
378  * \retval -1 on failure
379  */
380 typedef int (ast_inboxcount2_fn)(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs);
381 
382 /*!
383  * \brief Gets the number of messages that exist in a mailbox folder.
384  *
385  * \param mailbox_id The mailbox name.
386  * \param folder The folder to look in. Default is INBOX if not provided.
387  *
388  * \note If requesting INBOX then the returned count is INBOX + Urgent.
389  *
390  * \return The number of messages in the mailbox folder (zero or more).
391  */
392 typedef int (ast_messagecount_fn)(const char *mailbox_id, const char *folder);
393 
394 /*!
395  * \brief Play a recorded user name for the mailbox to the specified channel.
396  *
397  * \param chan Where to play the recorded name file.
398  * \param mailbox_id The mailbox name.
399  *
400  * \retval 0 Name played without interruption
401  * \retval dtmf ASCII value of the DTMF which interrupted playback.
402  * \retval -1 Unable to locate mailbox or hangup occurred.
403  */
404 typedef int (ast_sayname_fn)(struct ast_channel *chan, const char *mailbox_id);
405 
406 /*!
407  * \brief Creates a voicemail based on a specified file to a mailbox.
408  *
409  * \param vm_rec_data A record containing filename and voicemail txt info.
410  *
411  * \retval 0 on success
412  * \retval -1 on failure
413  */
414 typedef int (ast_copy_recording_to_vm_fn)(struct ast_vm_recording_data *vm_rec_data);
415 
416 /*!
417  * \brief Convert the mailbox folder id to a folder name.
418  *
419  * \param id Mailbox folder id to convert.
420  *
421  * \deprecated Nothing calls it and nothing ever should.
422  *
423  * \return The folder name associated with the id.
424  */
425 typedef const char *(ast_vm_index_to_foldername_fn)(int id);
426 
427 /*!
428  * \brief Create a snapshot of a mailbox which contains information about every msg.
429  *
430  * \param user The user part of user@context.
431  * \param context The context part of user@context. Must be explicit.
432  * \param folder When not NULL only msgs from the specified folder will be included.
433  * \param descending list the msgs in descending order rather than ascending order.
434  * \param sort_val What to sort in the snapshot.
435  * \param combine_INBOX_and_OLD When this argument is set, The OLD folder will be represented
436  * in the INBOX folder of the snapshot. This allows the snapshot to represent the
437  * OLD and INBOX messages in sorted order merged together.
438  *
439  * \note Only used by voicemail unit tests.
440  *
441  * \retval snapshot on success
442  * \retval NULL on failure
443  */
445  const char *context, const char *folder, int descending,
446  enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD);
447 
448 /*!
449  * \brief destroy a snapshot
450  *
451  * \param mailbox_snapshot The snapshot to destroy.
452  *
453  * \note Only used by voicemail unit tests.
454  *
455  * \retval NULL
456  */
458 
459 /*!
460  * \brief Move messages from one folder to another
461  *
462  * \param mailbox The mailbox to which the folders belong
463  * \param context The voicemail context for the mailbox
464  * \param num_msgs The number of messages to move
465  * \param oldfolder The folder from where messages should be moved
466  * \param old_msg_ids The message IDs of the messages to move
467  * \param newfolder The folder to which messages should be moved
468  * new folder. This array must be num_msgs sized.
469  *
470  * \note Only used by voicemail unit tests.
471  *
472  * \retval -1 Failure
473  * \retval 0 Success
474  */
475 typedef int (ast_vm_msg_move_fn)(const char *mailbox, const char *context, size_t num_msgs,
476  const char *oldfolder, const char *old_msg_ids[], const char *newfolder);
477 
478 /*!
479  * \brief Remove/delete messages from a mailbox folder.
480  *
481  * \param mailbox The mailbox from which to delete messages
482  * \param context The voicemail context for the mailbox
483  * \param num_msgs The number of messages to delete
484  * \param folder The folder from which to remove messages
485  * \param msgs The message IDs of the messages to delete
486  *
487  * \note Only used by voicemail unit tests.
488  *
489  * \retval -1 Failure
490  * \retval 0 Success
491  */
492 typedef int (ast_vm_msg_remove_fn)(const char *mailbox, const char *context, size_t num_msgs,
493  const char *folder, const char *msgs[]);
494 
495 /*!
496  * \brief forward a message from one mailbox to another.
497  *
498  * \brief from_mailbox The original mailbox the message is being forwarded from
499  * \brief from_context The voicemail context of the from_mailbox
500  * \brief from_folder The folder from which the message is being forwarded
501  * \brief to_mailbox The mailbox to forward the message to
502  * \brief to_context The voicemail context of the to_mailbox
503  * \brief to_folder The folder to which the message is being forwarded
504  * \brief num_msgs The number of messages being forwarded
505  * \brief msg_ids The message IDs of the messages in from_mailbox to forward
506  * \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
507  * Otherwise, the messages will remain in the from_mailbox.
508  *
509  * \note Only used by voicemail unit tests.
510  *
511  * \retval -1 Failure
512  * \retval 0 Success
513  */
514 typedef int (ast_vm_msg_forward_fn)(const char *from_mailbox, const char *from_context,
515  const char *from_folder, const char *to_mailbox, const char *to_context,
516  const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old);
517 
518 /*!
519  * \brief Play a voicemail msg back on a channel.
520  *
521  * \param chan
522  * \param mailbox msg is in.
523  * \param context of mailbox.
524  * \param folder voicemail folder to look in.
525  * \param msg_num message number in the voicemailbox to playback to the channel.
526  * \param cb
527  *
528  * \note Only used by voicemail unit tests.
529  *
530  * \retval 0 success
531  * \retval -1 failure
532  */
533 typedef int (ast_vm_msg_play_fn)(struct ast_channel *chan, const char *mailbox,
534  const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb);
535 
536 #define VM_MODULE_VERSION 2
537 
538 /*! \brief Voicemail function table definition. */
540  /*!
541  * \brief The version of this function table.
542  *
543  * \note If the ABI for this table changes, the module version
544  * (\ref VM_MODULE_VERSION) should be incremented.
545  */
546  unsigned int module_version;
547  /*! \brief The name of the module that provides the voicemail functionality */
548  const char *module_name;
549  /*! \brief The module for the voicemail provider */
551 
564 };
565 
566 /*!
567  * \brief Determine if a voicemail provider is registered.
568  * \since 12.0.0
569  *
570  * \retval 0 if no provider registered.
571  * \retval 1 if a provider is registered.
572  */
573 int ast_vm_is_registered(void);
574 
575 /*!
576  * \brief Set voicemail function callbacks
577  *
578  * \param vm_table Voicemail function table to install.
579  * \param module Pointer to the module implementing the interface
580  *
581  * \retval 0 on success.
582  * \retval -1 on error.
583  * \retval AST_MODULE_LOAD_DECLINE if there's already another provider registered.
584  */
585 int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module);
586 
587 /*! \brief See \ref __ast_vm_register() */
588 #define ast_vm_register(vm_table) __ast_vm_register(vm_table, AST_MODULE_SELF)
589 
590 /*!
591  * \brief Unregister the specified voicemail provider
592  *
593  * \param The module name of the provider to unregister
594  *
595  * \return Nothing
596  */
597 void ast_vm_unregister(const char *module_name);
598 
599 #ifdef TEST_FRAMEWORK
600 /*!
601  * \brief Swap out existing voicemail functions with a temporary set of functions for use with unit tests
602  *
603  * \param vm_table function table to use for testing
604  *
605  * \note ast_vm_test_swap_table_out should be called to restore the original set before testing concludes
606  */
608 
609 /*!
610  * \brief Used after ast_vm_test_swap_table_in to restore the original set of voicemail functions
611  */
612 void ast_vm_test_swap_table_out(void);
613 #endif
614 
615 #define VM_GREETER_MODULE_VERSION 1
616 
617 /*! \brief Voicemail greeter function table definition. */
619  /*!
620  * \brief The version of this function table.
621  *
622  * \note If the ABI for this table changes, the module version
623  * (\ref VM_GREETER_MODULE_VERSION) should be incremented.
624  */
625  unsigned int module_version;
626  /*! \brief The name of the module that provides the voicemail greeter functionality */
627  const char *module_name;
628  /*! \brief The module for the voicemail greeter provider */
630 
632 };
633 
634 /*!
635  * \brief Determine if a voicemail greeter provider is registered.
636  * \since 13.0.0
637  *
638  * \retval 0 if no provider registered.
639  * \retval 1 if a provider is registered.
640  */
642 
643 /*!
644  * \brief Set voicemail greeter function callbacks
645  * \since 13.0.0
646  *
647  * \param vm_table Voicemail greeter function table to install.
648  * \param module Pointer to the module implementing the interface
649  *
650  * \retval 0 on success.
651  * \retval -1 on error.
652  * \retval AST_MODULE_LOAD_DECLINE if there's already another greeter registered.
653  */
654 int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module);
655 
656 /*! \brief See \ref __ast_vm_greeter_register() */
657 #define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, AST_MODULE_SELF)
658 
659 /*!
660  * \brief Unregister the specified voicemail greeter provider
661  * \since 13.0.0
662  *
663  * \param The module name of the provider to unregister
664  *
665  * \return Nothing
666  */
667 void ast_vm_greeter_unregister(const char *module_name);
668 
669 #ifdef TEST_FRAMEWORK
670 typedef int (ast_vm_test_create_user_fn)(const char *context, const char *user);
671 typedef int (ast_vm_test_destroy_user_fn)(const char *context, const char *user);
672 
673 void ast_install_vm_test_functions(ast_vm_test_create_user_fn *vm_test_create_user_func,
674  ast_vm_test_destroy_user_fn *vm_test_destroy_user_func);
675 
677 #endif
678 
679 /*!
680  * \brief
681  * param[in] vm_rec_data Contains data needed to make the recording.
682  * retval 0 voicemail successfully created from recording.
683  * retval -1 Failure
684  */
685 int ast_app_copy_recording_to_vm(struct ast_vm_recording_data *vm_rec_data);
686 
687 /*!
688  * \brief Determine if a given mailbox has any voicemail
689  * If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the
690  * number of messages in the "Urgent" folder.
691  * \retval 1 Mailbox has voicemail
692  * \retval 0 No new voicemail in specified mailbox
693  * \retval -1 Failure
694  * \since 1.0
695  */
696 int ast_app_has_voicemail(const char *mailboxes, const char *folder);
697 
698 /*!
699  * \brief Determine number of new/old messages in a mailbox
700  * \since 1.0
701  * \param[in] mailboxes Mailbox specification in the format
702  * /code
703  * mbox[\@context][&mbox2[\@context2]][...]
704  * /code
705  * \param[out] newmsgs Number of messages in the "INBOX" folder. Includes number of messages in the "Urgent" folder, if any.
706  * \param[out] oldmsgs Number of messages in the "Old" folder.
707  * \retval 0 Success
708  * \retval -1 Failure
709  */
710 int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs);
711 
712 /*!
713  * \brief Determine number of urgent/new/old messages in a mailbox
714  * \param[in] mailboxes the mailbox context to use
715  * \param[out] urgentmsgs the urgent message count
716  * \param[out] newmsgs the new message count
717  * \param[out] oldmsgs the old message count
718  * \return Returns 0 for success, negative upon error
719  * \since 1.6.1
720  */
721 int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs);
722 
723 /*!
724  * \brief Play a recorded user name for the mailbox to the specified channel.
725  *
726  * \param chan Where to play the recorded name file.
727  * \param mailbox_id The mailbox name.
728  *
729  * \retval 0 Name played without interruption
730  * \retval dtmf ASCII value of the DTMF which interrupted playback.
731  * \retval -1 Unable to locate mailbox or hangup occurred.
732  */
733 int ast_app_sayname(struct ast_channel *chan, const char *mailbox_id);
734 
735 /*!
736  * \brief Get the number of messages in a given mailbox folder
737  *
738  * \param[in] mailbox_id Mailbox name
739  * \param[in] folder The folder to look in. Default is INBOX if not provided.
740  *
741  * \note If requesting INBOX then the returned count is INBOX + Urgent.
742  *
743  * \return The number of messages in the mailbox folder (zero or more).
744  */
745 int ast_app_messagecount(const char *mailbox_id, const char *folder);
746 
747 /*!
748  * \brief Return name of folder, given an id
749  * \param[in] id Folder id
750  * \return Name of folder
751  */
752 const char *ast_vm_index_to_foldername(int id);
753 
754 /*!
755  * \brief Create a snapshot of a mailbox which contains information about every msg.
756  *
757  * \param mailbox, the mailbox to look for
758  * \param context, the context to look for the mailbox in
759  * \param folder, OPTIONAL. When not NULL only msgs from the specified folder will be included.
760  * \param descending, list the msgs in descending order rather than ascending order.
761  * \param combine_INBOX_and_OLD, When this argument is set, The OLD folder will be represented
762  * in the INBOX folder of the snapshot. This allows the snapshot to represent the
763  * OLD and INBOX messages in sorted order merged together.
764  *
765  * \retval snapshot on success
766  * \retval NULL on failure
767  */
768 struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
769  const char *context,
770  const char *folder,
771  int descending,
772  enum ast_vm_snapshot_sort_val sort_val,
773  int combine_INBOX_and_OLD);
774 
775 /*!
776  * \brief destroy a snapshot
777  *
778  * \param mailbox_snapshot The snapshot to destroy.
779  * \retval NULL
780  */
782 
783 /*!
784  * \brief Move messages from one folder to another
785  *
786  * \param mailbox The mailbox to which the folders belong
787  * \param context The voicemail context for the mailbox
788  * \param num_msgs The number of messages to move
789  * \param oldfolder The folder from where messages should be moved
790  * \param old_msg_ids The message IDs of the messages to move
791  * \param newfolder The folder to which messages should be moved
792  * new folder. This array must be num_msgs sized.
793  *
794  * \retval -1 Failure
795  * \retval 0 Success
796  */
797 int ast_vm_msg_move(const char *mailbox,
798  const char *context,
799  size_t num_msgs,
800  const char *oldfolder,
801  const char *old_msg_ids[],
802  const char *newfolder);
803 
804 /*!
805  * \brief Remove/delete messages from a mailbox folder.
806  *
807  * \param mailbox The mailbox from which to delete messages
808  * \param context The voicemail context for the mailbox
809  * \param num_msgs The number of messages to delete
810  * \param folder The folder from which to remove messages
811  * \param msgs The message IDs of the messages to delete
812  *
813  * \retval -1 Failure
814  * \retval 0 Success
815  */
816 int ast_vm_msg_remove(const char *mailbox,
817  const char *context,
818  size_t num_msgs,
819  const char *folder,
820  const char *msgs[]);
821 
822 /*!
823  * \brief forward a message from one mailbox to another.
824  *
825  * \brief from_mailbox The original mailbox the message is being forwarded from
826  * \brief from_context The voicemail context of the from_mailbox
827  * \brief from_folder The folder from which the message is being forwarded
828  * \brief to_mailbox The mailbox to forward the message to
829  * \brief to_context The voicemail context of the to_mailbox
830  * \brief to_folder The folder to which the message is being forwarded
831  * \brief num_msgs The number of messages being forwarded
832  * \brief msg_ids The message IDs of the messages in from_mailbox to forward
833  * \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
834  * Otherwise, the messages will remain in the from_mailbox.
835  *
836  * \retval -1 Failure
837  * \retval 0 Success
838  */
839 int ast_vm_msg_forward(const char *from_mailbox,
840  const char *from_context,
841  const char *from_folder,
842  const char *to_mailbox,
843  const char *to_context,
844  const char *to_folder,
845  size_t num_msgs,
846  const char *msg_ids[],
847  int delete_old);
848 
849 /*!
850  * \brief Play a voicemail msg back on a channel.
851  *
852  * \param chan
853  * \param mailbox msg is in.
854  * \param context of mailbox.
855  * \param folder voicemail folder to look in.
856  * \param msg_num message number in the voicemailbox to playback to the channel.
857  * \param cb
858  *
859  * \retval 0 success
860  * \retval -1 failure
861  */
862 int ast_vm_msg_play(struct ast_channel *chan,
863  const char *mailbox,
864  const char *context,
865  const char *folder,
866  const char *msg_num,
867  ast_vm_msg_play_cb *cb);
868 
869 #ifdef TEST_FRAMEWORK
870 int ast_vm_test_destroy_user(const char *context, const char *mailbox);
871 int ast_vm_test_create_user(const char *context, const char *mailbox);
872 #endif
873 
874 /*!
875  * \brief Safely spawn an external program while closing file descriptors
876  *
877  * \note This replaces the \b execvp call in all Asterisk modules
878  *
879  * \param dualfork Non-zero to simulate running the program in the
880  * background by forking twice. The option provides similar
881  * functionality to the '&' in the OS shell command "cmd &". The
882  * option allows Asterisk to run a reaper loop to watch the first fork
883  * which immediately exits after spaning the second fork. The actual
884  * program is run in the second fork.
885  * \param file execvp(file, argv) file parameter
886  * \param argv execvp(file, argv) argv parameter
887  */
888 int ast_safe_execvp(int dualfork, const char *file, char *const argv[]);
889 
890 /*!
891  * \brief Safely spawn an OS shell command while closing file descriptors
892  *
893  * \note This replaces the \b system call in all Asterisk modules
894  *
895  * \param s - OS shell command string to execute.
896  *
897  * \warning Command injection can happen using this call if the passed
898  * in string is created using untrusted data from an external source.
899  * It is best not to use untrusted data. However, the caller could
900  * filter out dangerous characters to avoid command injection.
901  */
902 int ast_safe_system(const char *s);
903 
904 /*!
905  * \brief Replace the SIGCHLD handler
906  *
907  * Normally, Asterisk has a SIGCHLD handler that is cleaning up all zombie
908  * processes from forking elsewhere in Asterisk. However, if you want to
909  * wait*() on the process to retrieve information about it's exit status,
910  * then this signal handler needs to be temporarily replaced.
911  *
912  * Code that executes this function *must* call ast_unreplace_sigchld()
913  * after it is finished doing the wait*().
914  */
915 void ast_replace_sigchld(void);
916 
917 /*!
918  * \brief Restore the SIGCHLD handler
919  *
920  * This function is called after a call to ast_replace_sigchld. It restores
921  * the SIGCHLD handler that cleans up any zombie processes.
922  */
923 void ast_unreplace_sigchld(void);
924 
925 /*!
926  * \brief Send a string of MF digits to a channel
927  *
928  * \param chan The channel that will receive the MF frames
929  * \param peer (optional) Peer channel that will be autoserviced while the
930  * primary channel is receiving MF
931  * \param digits This is a string of characters representing the MF digits
932  * to be sent to the channel. Valid characters are
933  * "0123456789*#abcdABCD". Note: You can pass arguments 'f' or
934  * 'F', if you want to Flash the channel (if supported by the
935  * channel), or 'w' or 'W' to add a wink (if supported by the
936  * channel).
937  * \param between This is the number of milliseconds to wait in between each
938  * MF digit. If zero milliseconds is specified, then the
939  * default value of 50 will be used.
940  * \param duration This is the duration that each numeric MF digit should have.
941  * Default value is 55.
942  * \param durationkp This is the duration that each KP digit should have. Default
943  * is 120.
944  * \param durationst This is the duration that each ST, STP, ST2P, or ST3P digit
945  * should have. Default is 65.
946  * \param is_external 1 if called by a thread that is not the channel's media
947  * handler thread, 0 if called by the channel's media handler
948  * thread.
949  *
950  * \retval 0 on success.
951  * \retval -1 on failure or a channel hung up.
952  */
953 int ast_mf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration,
954  unsigned int durationkp, unsigned int durationst, int is_external);
955 
956 /*!
957  * \brief Send a string of DTMF digits to a channel
958  *
959  * \param chan The channel that will receive the DTMF frames
960  * \param peer (optional) Peer channel that will be autoserviced while the
961  * primary channel is receiving DTMF
962  * \param digits This is a string of characters representing the DTMF digits
963  * to be sent to the channel. Valid characters are
964  * "0123456789*#abcdABCD". Note: You can pass arguments 'f' or
965  * 'F', if you want to Flash the channel (if supported by the
966  * channel), or 'w' to add a 500 millisecond pause to the DTMF
967  * sequence.
968  * \param between This is the number of milliseconds to wait in between each
969  * DTMF digit. If zero milliseconds is specified, then the
970  * default value of 100 will be used.
971  * \param duration This is the duration that each DTMF digit should have.
972  *
973  * \pre This must only be called by the channel's media handler thread.
974  *
975  * \retval 0 on success.
976  * \retval -1 on failure or a channel hung up.
977  */
978 int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration);
979 
980 /*!
981  * \brief Send a string of DTMF digits to a channel from an external thread.
982  *
983  * \param chan The channel that will receive the DTMF frames
984  * \param digits This is a string of characters representing the DTMF digits
985  * to be sent to the channel. Valid characters are
986  * "0123456789*#abcdABCD". Note: You can pass arguments 'f' or
987  * 'F', if you want to Flash the channel (if supported by the
988  * channel), or 'w' to add a 500 millisecond pause to the DTMF
989  * sequence.
990  * \param between This is the number of milliseconds to wait in between each
991  * DTMF digit. If zero milliseconds is specified, then the
992  * default value of 100 will be used.
993  * \param duration This is the duration that each DTMF digit should have.
994  *
995  * \pre This must only be called by threads that are not the channel's
996  * media handler thread.
997  *
998  * \return Nothing
999  */
1000 void ast_dtmf_stream_external(struct ast_channel *chan, const char *digits, int between, unsigned int duration);
1001 
1002 /*! \brief Stream a filename (or file descriptor) as a generator. */
1003 int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride);
1004 
1005 /*!
1006  * \brief Stream a file with fast forward, pause, reverse, restart.
1007  * \param chan Channel
1008  * \param file File to play.
1009  * \param fwd, rev, stop, pause, restart DTMF keys for media control
1010  * \param skipms Number of milliseconds to skip for fwd/rev.
1011  * \param offsetms Number of milliseconds to skip when starting the media.
1012  *
1013  * Before calling this function, set this to be the number
1014  * of ms to start from the beginning of the file. When the function
1015  * returns, it will be the number of ms from the beginning where the
1016  * playback stopped. Pass NULL if you don't care.
1017  *
1018  * \retval 0 on success
1019  * \retval Non-zero on failure
1020  */
1021 int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms);
1022 
1023 /*!
1024  * \brief Version of ast_control_streamfile() which allows the language of the
1025  * media file to be specified.
1026  *
1027  * \retval 0 on success
1028  * \retval Non-zero on failure
1029  */
1030 int ast_control_streamfile_lang(struct ast_channel *chan, const char *file,
1031  const char *fwd, const char *rev, const char *stop, const char *suspend,
1032  const char *restart, int skipms, const char *lang, long *offsetms);
1033 
1034 /*!
1035  * \brief Controls playback of a tone
1036  *
1037  * \retval 0 on success
1038  * \retval Non-zero on failure
1039  */
1040 int ast_control_tone(struct ast_channel *chan, const char *tone);
1041 
1042 /*!
1043  * \brief Stream a file with fast forward, pause, reverse, restart.
1044  * \param chan
1045  * \param file filename
1046  * \param fwd, rev, stop, pause, restart, skipms, offsetms
1047  * \param cb waitstream callback to invoke when fastforward or rewind occurrs.
1048  *
1049  * Before calling this function, set this to be the number
1050  * of ms to start from the beginning of the file. When the function
1051  * returns, it will be the number of ms from the beginning where the
1052  * playback stopped. Pass NULL if you don't care.
1053  */
1054 int ast_control_streamfile_w_cb(struct ast_channel *chan,
1055  const char *file,
1056  const char *fwd,
1057  const char *rev,
1058  const char *stop,
1059  const char *pause,
1060  const char *restart,
1061  int skipms,
1062  long *offsetms,
1064 
1065 /*! \brief Play a stream and wait for a digit, returning the digit that was pressed */
1066 int ast_play_and_wait(struct ast_channel *chan, const char *fn);
1067 
1068 /*!
1069  * Possible actions to take if a recording already exists
1070  * \since 12
1071  */
1073  /*! Return an Error State for IF_Exists */
1075  /*! Fail the recording. */
1077  /*! Overwrite the existing recording. */
1079  /*! Append to the existing recording. */
1081 };
1082 
1083 /*!
1084  * \brief Record a file based on input from a channel
1085  * This function will play "auth-thankyou" upon successful recording if
1086  * skip_confirmation_sound is false.
1087  *
1088  * \param chan the channel being recorded
1089  * \param playfile Filename of sound to play before recording begins. A beep is also played when playfile completes, before the recording begins.
1090  * \param recordfile Filename to save the recording
1091  * \param maxtime_sec Longest possible message length in seconds
1092  * \param fmt string containing all formats to be recorded delimited by '|'
1093  * \param duration pointer to integer for storing length of the recording
1094  * \param beep If true, play a beep before recording begins (and doesn't play \a playfile)
1095  * \param sound_duration pointer to integer for storing length of the recording minus all silence
1096  * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
1097  * \param maxsilence_ms Length of time in milliseconds which will trigger a timeout from silence, -1 for default
1098  * \param path Optional filesystem path to unlock
1099  * \param acceptdtmf Character of DTMF to end and accept the recording
1100  * \param canceldtmf Character of DTMF to end and cancel the recording
1101  * \param skip_confirmation_sound If true, don't play auth-thankyou at end. Nice for custom recording prompts in apps.
1102  * \param if_exists Action to take if recording already exists.
1103  *
1104  * \retval -1 failure or hangup
1105  * \retval 'S' Recording ended from silence timeout
1106  * \retval 't' Recording ended from the message exceeding the maximum duration
1107  * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
1108  */
1109 int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists);
1110 
1111 /*!
1112  * \brief Record a file based on input from a channel. Use default accept and cancel DTMF.
1113  * This function will play "auth-thankyou" upon successful recording.
1114  *
1115  * \param chan the channel being recorded
1116  * \param playfile Filename of sound to play before recording begins
1117  * \param recordfile Filename to save the recording
1118  * \param maxtime_sec Longest possible message length in seconds
1119  * \param fmt string containing all formats to be recorded delimited by '|'
1120  * \param duration pointer to integer for storing length of the recording
1121  * \param sound_duration pointer to integer for storing length of the recording minus all silence
1122  * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
1123  * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default
1124  * \param path Optional filesystem path to unlock
1125  *
1126  * \retval -1 failure or hangup
1127  * \retval 'S' Recording ended from silence timeout
1128  * \retval 't' Recording ended from the message exceeding the maximum duration
1129  * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
1130  */
1131 int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path);
1132 
1133 /*!
1134  * \brief Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a little differently from normal recordings
1135  * This function will not play a success message due to post-recording control in the application this was added for.
1136  *
1137  * \param chan the channel being recorded
1138  * \param playfile Filename of sound to play before recording begins
1139  * \param recordfile Filename to save the recording
1140  * \param maxtime_sec Longest possible message length in seconds
1141  * \param fmt string containing all formats to be recorded delimited by '|'
1142  * \param duration pointer to integer for storing length of the recording
1143  * \param sound_duration pointer to integer for storing length of the recording minus all silence
1144  * \param beep whether to play a beep to prompt the recording
1145  * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
1146  * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default.
1147  *
1148  * \retval -1 failure or hangup
1149  * \retval 'S' Recording ended from silence timeout
1150  * \retval 't' Recording either exceeded maximum duration or the call was ended via DTMF
1151  */
1152 int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms);
1153 
1159  /*! indicates a user terminated empty string rather than an empty string resulting
1160  * from a timeout or other factors */
1162 };
1163 
1169 };
1170 
1171 /*! \brief Type of locking to use in ast_lock_path / ast_unlock_path */
1175 };
1176 
1177 /*!
1178  * \brief Set the type of locks used by ast_lock_path()
1179  * \param type the locking type to use
1180  */
1182 
1183 /*!
1184  * \brief Lock a filesystem path.
1185  * \param path the path to be locked
1186  * \return one of \ref AST_LOCK_RESULT values
1187  */
1188 enum AST_LOCK_RESULT ast_lock_path(const char *path);
1189 
1190 /*! \brief Unlock a path */
1191 int ast_unlock_path(const char *path);
1192 
1193 /*! \brief Read a file into asterisk*/
1194 char *ast_read_textfile(const char *file);
1195 
1196 struct ast_group_info;
1197 
1198 /*! \brief Split a group string into group and category, returning a default category if none is provided. */
1199 int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max);
1200 
1201 /*! \brief Set the group for a channel, splitting the provided data into group and category, if specified. */
1202 int ast_app_group_set_channel(struct ast_channel *chan, const char *data);
1203 
1204 /*! \brief Get the current channel count of the specified group and category. */
1205 int ast_app_group_get_count(const char *group, const char *category);
1206 
1207 /*! \brief Get the current channel count of all groups that match the specified pattern and category. */
1208 int ast_app_group_match_get_count(const char *groupmatch, const char *category);
1209 
1210 /*! \brief Discard all group counting for a channel */
1211 int ast_app_group_discard(struct ast_channel *chan);
1212 
1213 /*! \brief Update all group counting for a channel to a new one */
1214 int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan);
1215 
1216 /*! \brief Write Lock the group count list */
1217 int ast_app_group_list_wrlock(void);
1218 
1219 /*! \brief Read Lock the group count list */
1220 int ast_app_group_list_rdlock(void);
1221 
1222 /*! \brief Get the head of the group count list */
1224 
1225 /*! \brief Unlock the group count list */
1226 int ast_app_group_list_unlock(void);
1227 
1228 /*!
1229  \brief Define an application argument
1230  \param name The name of the argument
1231 */
1232 #define AST_APP_ARG(name) char *name
1233 
1234 /*!
1235  \brief Declare a structure to hold an application's arguments.
1236  \param name The name of the structure
1237  \param arglist The list of arguments, defined using AST_APP_ARG
1238 
1239  This macro declares a structure intended to be used in a call
1240  to ast_app_separate_args(). The structure includes all the
1241  arguments specified, plus an argv array that overlays them and an
1242  argc argument counter. The arguments must be declared using AST_APP_ARG,
1243  and they will all be character pointers (strings).
1244 
1245  \note The structure is <b>not</b> initialized, as the call to
1246  ast_app_separate_args() will perform that function before parsing
1247  the arguments.
1248  */
1249 #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(argtype_##name, arglist) name = { 0, }
1250 
1251 /*!
1252  \brief Define a structure type to hold an application's arguments.
1253  \param type The name of the structure type
1254  \param arglist The list of arguments, defined using AST_APP_ARG
1255 
1256  This macro defines a structure type intended to be used in a call
1257  to ast_app_separate_args(). The structure includes all the
1258  arguments specified, plus an argv array that overlays them and an
1259  argc argument counter. The arguments must be declared using AST_APP_ARG,
1260  and they will all be character pointers (strings).
1261 
1262  \note This defines a structure type, but does not declare an instance
1263  of the structure. That must be done separately.
1264  */
1265 
1266 #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \
1267  struct __subtype_##type { arglist }; \
1268  struct type { \
1269  unsigned int argc; \
1270  union { \
1271  char *argv[sizeof(struct __subtype_##type) / sizeof(char*)]; \
1272  struct { arglist }; \
1273  }; \
1274  }
1275 
1276 /*!
1277  \brief Performs the 'standard' argument separation process for an application.
1278  \param args An argument structure defined using AST_DECLARE_APP_ARGS
1279  \param parse A modifiable buffer containing the input to be parsed
1280 
1281  This function will separate the input string using the standard argument
1282  separator character ',' and fill in the provided structure, including
1283  the argc argument counter field.
1284  */
1285 #define AST_STANDARD_APP_ARGS(args, parse) \
1286  args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1287 #define AST_STANDARD_RAW_ARGS(args, parse) \
1288  args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1289 
1290 /*!
1291  \brief Performs the 'nonstandard' argument separation process for an application.
1292  \param args An argument structure defined using AST_DECLARE_APP_ARGS
1293  \param parse A modifiable buffer containing the input to be parsed
1294  \param sep A nonstandard separator character
1295 
1296  This function will separate the input string using the nonstandard argument
1297  separator character and fill in the provided structure, including
1298  the argc argument counter field.
1299  */
1300 #define AST_NONSTANDARD_APP_ARGS(args, parse, sep) \
1301  args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1302 #define AST_NONSTANDARD_RAW_ARGS(args, parse, sep) \
1303  args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
1304 
1305 /*!
1306  \brief Separate a string into arguments in an array
1307  \param buf The string to be parsed (this must be a writable copy, as it will be modified)
1308  \param delim The character to be used to delimit arguments
1309  \param remove_chars Remove backslashes and quote characters, while parsing
1310  \param array An array of 'char *' to be filled in with pointers to the found arguments
1311  \param arraylen The number of elements in the array (i.e. the number of arguments you will accept)
1312 
1313  Note: if there are more arguments in the string than the array will hold, the last element of
1314  the array will contain the remaining arguments, not separated.
1315 
1316  The array will be completely zeroed by this function before it populates any entries.
1317 
1318  \return The number of arguments found, or zero if the function arguments are not valid.
1319 */
1320 unsigned int __ast_app_separate_args(char *buf, char delim, int remove_chars, char **array, int arraylen);
1321 #define ast_app_separate_args(a,b,c,d) __ast_app_separate_args(a,b,1,c,d)
1322 
1323 /*!
1324  \brief A structure to hold the description of an application 'option'.
1325 
1326  Application 'options' are single-character flags that can be supplied
1327  to the application to affect its behavior; they can also optionally
1328  accept arguments enclosed in parenthesis.
1329 
1330  These structures are used by the ast_app_parse_options function, uses
1331  this data to fill in a flags structure (to indicate which options were
1332  supplied) and array of argument pointers (for those options that had
1333  arguments supplied).
1334  */
1336  /*! \brief The flag bit that represents this option. */
1337  uint64_t flag;
1338  /*! \brief The index of the entry in the arguments array
1339  that should be used for this option's argument. */
1340  unsigned int arg_index;
1341 };
1342 
1343 #define BEGIN_OPTIONS {
1344 #define END_OPTIONS }
1345 
1346 /*!
1347  \brief Declares an array of options for an application.
1348  \param holder The name of the array to be created
1349  \param options The actual options to be placed into the array
1350  \sa ast_app_parse_options
1351 
1352  This macro declares a 'static const' array of \c struct \c ast_option
1353  elements to hold the list of available options for an application.
1354  Each option must be declared using either the AST_APP_OPTION()
1355  or AST_APP_OPTION_ARG() macros.
1356 
1357  Example usage:
1358  \code
1359  enum my_app_option_flags {
1360  OPT_JUMP = (1 << 0),
1361  OPT_BLAH = (1 << 1),
1362  OPT_BLORT = (1 << 2),
1363  };
1364 
1365  enum my_app_option_args {
1366  OPT_ARG_BLAH = 0,
1367  OPT_ARG_BLORT,
1368  !! this entry tells how many possible arguments there are,
1369  and must be the last entry in the list
1370  OPT_ARG_ARRAY_SIZE,
1371  };
1372 
1373  AST_APP_OPTIONS(my_app_options, {
1374  AST_APP_OPTION('j', OPT_JUMP),
1375  AST_APP_OPTION_ARG('b', OPT_BLAH, OPT_ARG_BLAH),
1376  AST_APP_OPTION_BLORT('B', OPT_BLORT, OPT_ARG_BLORT),
1377  });
1378 
1379  static int my_app_exec(struct ast_channel *chan, void *data)
1380  {
1381  char *options;
1382  struct ast_flags opts = { 0, };
1383  char *opt_args[OPT_ARG_ARRAY_SIZE];
1384 
1385  ... do any argument parsing here ...
1386 
1387  if (ast_app_parse_options(my_app_options, &opts, opt_args, options)) {
1388  return -1;
1389  }
1390  }
1391  \endcode
1392  */
1393 #define AST_APP_OPTIONS(holder, options...) \
1394  static const struct ast_app_option holder[128] = options
1395 
1396 /*!
1397  \brief Declares an application option that does not accept an argument.
1398  \param option The single character representing the option
1399  \param flagno The flag index to be set if this option is present
1400  \sa AST_APP_OPTIONS, ast_app_parse_options
1401  */
1402 #define AST_APP_OPTION(option, flagno) \
1403  [option] = { .flag = flagno }
1404 
1405 /*!
1406  \brief Declares an application option that accepts an argument.
1407  \param option The single character representing the option
1408  \param flagno The flag index to be set if this option is present
1409  \param argno The index into the argument array where the argument should
1410  be placed
1411  \sa AST_APP_OPTIONS, ast_app_parse_options
1412  */
1413 #define AST_APP_OPTION_ARG(option, flagno, argno) \
1414  [option] = { .flag = flagno, .arg_index = argno + 1 }
1415 
1416 /*!
1417  \brief Parses a string containing application options and sets flags/arguments.
1418  \param options The array of possible options declared with AST_APP_OPTIONS
1419  \param flags The flag structure to have option flags set
1420  \param args The array of argument pointers to hold arguments found
1421  \param optstr The string containing the options to be parsed
1422  \return zero for success, non-zero if an error occurs
1423  \sa AST_APP_OPTIONS
1424  */
1425 int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr);
1426 
1427  /*!
1428  \brief Parses a string containing application options and sets flags/arguments.
1429  \param options The array of possible options declared with AST_APP_OPTIONS
1430  \param flags The 64-bit flag structure to have option flags set
1431  \param args The array of argument pointers to hold arguments found
1432  \param optstr The string containing the options to be parsed
1433  \return zero for success, non-zero if an error occurs
1434  \sa AST_APP_OPTIONS
1435  */
1436 int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr);
1437 
1438 /*! \brief Given a list of options array, return an option string based on passed flags
1439  \param options The array of possible options declared with AST_APP_OPTIONS
1440  \param flags The flags of the options that you wish to populate the buffer with
1441  \param buf The buffer to fill with the string of options
1442  \param len The maximum length of buf
1443 */
1444 void ast_app_options2str64(const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len);
1445 
1446 /*! \brief Present a dialtone and collect a certain length extension.
1447  \return Returns 1 on valid extension entered, -1 on hangup, or 0 on invalid extension.
1448 \note Note that if 'collect' holds digits already, new digits will be appended, so be sure it's initialized properly */
1449 int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout);
1450 
1451 /*! \brief Allow to record message and have a review option */
1452 int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path);
1453 
1454 /*!
1455  * \brief Decode an encoded control or extended ASCII character
1456  * \param[in] stream String to decode
1457  * \param[out] result Decoded character
1458  * \param[out] consumed Number of characters used in stream to encode the character
1459  * \retval -1 Stream is of zero length
1460  * \retval 0 Success
1461  */
1462 int ast_get_encoded_char(const char *stream, char *result, size_t *consumed);
1463 
1464 /*!
1465  * \brief Decode a stream of encoded control or extended ASCII characters
1466  * \param[in] stream Encoded string
1467  * \param[out] result Decoded string
1468  * \param[in] result_len Maximum size of the result buffer
1469  * \return A pointer to the result string
1470  */
1471 char *ast_get_encoded_str(const char *stream, char *result, size_t result_len);
1472 
1473 /*! \brief Decode a stream of encoded control or extended ASCII characters */
1474 int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream);
1475 
1476 /*!
1477  * \brief Common routine for child processes, to close all fds prior to exec(2)
1478  * \param[in] n starting file descriptor number for closing all higher file descriptors
1479  * \since 1.6.1
1480  */
1481 void ast_close_fds_above_n(int n);
1482 
1483 /*!
1484  * \brief Common routine to safely fork without a chance of a signal handler firing badly in the child
1485  * \param[in] stop_reaper flag to determine if sigchld handler is replaced or not
1486  * \since 1.6.1
1487  */
1488 int ast_safe_fork(int stop_reaper);
1489 
1490 /*!
1491  * \brief Common routine to cleanup after fork'ed process is complete (if reaping was stopped)
1492  * \since 1.6.1
1493  */
1494 void ast_safe_fork_cleanup(void);
1495 
1496 /*!
1497  * \brief Common routine to parse time lengths, with optional time unit specifier
1498  * \param[in] timestr String to parse
1499  * \param[in] defunit Default unit type
1500  * \param[out] result Resulting value, specified in milliseconds
1501  * \retval 0 Success
1502  * \retval -1 Failure
1503  * \since 1.8
1504  */
1505 int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit);
1506 
1507 /*!
1508  * \brief Get the \ref stasis topic for queue messages
1509  * \retval The topic structure for queue messages
1510  * \retval NULL if it has not been allocated
1511  * \since 12
1512  */
1513 struct stasis_topic *ast_queue_topic_all(void);
1514 
1515 /*!
1516  * \brief Get the \ref stasis topic for queue messages for a particular queue name
1517  * \param queuename The name for which to get the topic
1518  * \retval The topic structure for queue messages for a given name
1519  * \retval NULL if it failed to be found or allocated
1520  * \since 12
1521  */
1522 struct stasis_topic *ast_queue_topic(const char *queuename);
1523 /*! @} */
1524 
1525 /*!
1526  * \brief Initialize the application core
1527  * \retval 0 Success
1528  * \retval -1 Failure
1529  * \since 12
1530  */
1531 int app_init(void);
1532 
1533 #if defined(__cplusplus) || defined(c_plusplus)
1534 }
1535 #endif
1536 
1537 #endif /* _ASTERISK_APP_H */
static char user[512]
void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs)
Set stack application function callbacks.
Definition: main/app.c:346
unsigned int module_version
The version of this function table.
int ast_vm_is_registered(void)
Determine if a voicemail provider is registered.
Definition: main/app.c:430
int ast_vm_greeter_is_registered(void)
Determine if a voicemail greeter provider is registered.
Definition: main/app.c:541
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
Definition: main/app.c:981
static const char type[]
Definition: chan_ooh323.c:109
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
channel group info
Definition: channel.h:2938
ast_ivr_action action
struct ast_module * module
The module for the voicemail provider.
static const struct ast_vm_functions vm_table
int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module)
Set voicemail function callbacks.
Definition: main/app.c:441
unsigned int flags
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
Definition: main/app.c:2452
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
Definition: main/app.c:3002
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
Definition: extconf.c:815
String manipulation functions.
int() ast_vm_msg_move_fn(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
Move messages from one folder to another.
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
Definition: main/app.c:2189
const char * ast_app_expand_sub_args(struct ast_channel *chan, const char *args)
Add missing context/exten to subroutine argument string.
Definition: main/app.c:351
int ast_app_sayname(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
Definition: main/app.c:710
int ast_control_streamfile_lang(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, const char *lang, long *offsetms)
Version of ast_control_streamfile() which allows the language of the media file to be specified...
Definition: main/app.c:1327
int() ast_sayname_fn(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:320
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
ast_inboxcount_fn * inboxcount
void ast_install_vm_test_functions(ast_vm_test_create_user_fn *vm_test_create_user_func, ast_vm_test_destroy_user_fn *vm_test_destroy_user_func)
Definition: main/app.c:599
unsigned int __ast_app_separate_args(char *buf, char delim, int remove_chars, char **array, int arraylen)
Separate a string into arguments in an array.
Definition: main/app.c:2199
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
void ast_uninstall_vm_test_functions(void)
Definition: main/app.c:606
Voicemail greeter function table definition.
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
ast_vm_mailbox_snapshot_destroy_fn * mailbox_snapshot_destroy
static int timeout
Definition: cdr_mysql.c:86
int() ast_vm_msg_remove_fn(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
Remove/delete messages from a mailbox folder.
struct stasis_topic * ast_queue_topic_all(void)
Get the Stasis Message Bus API topic for queue messages.
Definition: main/app.c:3184
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
Definition: main/app.c:3042
ast_record_if_exists
int ast_control_tone(struct ast_channel *chan, const char *tone)
Controls playback of a tone.
Definition: main/app.c:1399
unsigned int stop
Definition: app_meetme.c:1096
void ast_app_options2str64(const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len)
Given a list of options array, return an option string based on passed flags.
Definition: main/app.c:2916
void ast_vm_unregister(const char *module_name)
Unregister the specified voicemail provider.
Definition: main/app.c:473
int ast_vm_test_destroy_user(const char *context, const char *mailbox)
Definition: main/app.c:821
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:337
int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms)
Record a file based on input frm a channel. Recording is performed in &#39;prepend&#39; mode which works a li...
Definition: main/app.c:2002
static struct test_val c
int() ast_vm_msg_play_fn(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)
Play a voicemail msg back on a channel.
const char * str
Definition: app_jack.c:147
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
const char * args
int ast_unlock_path(const char *path)
Unlock a path.
Definition: main/app.c:2473
int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms)
Stream a file with fast forward, pause, reverse, restart.
Definition: main/app.c:1319
Definitions to aid in the use of thread local storage.
Structure used to handle a large number of boolean flags == used only in app_dial?
Definition: utils.h:204
int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream)
Decode a stream of encoded control or extended ASCII characters.
Definition: main/app.c:3015
int() ast_vm_msg_forward_fn(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
forward a message from one mailbox to another.
void() ast_vm_msg_play_cb(struct ast_channel *chan, const char *playfile, int duration)
Voicemail playback callback function definition.
char * ast_read_textfile(const char *file)
Read a file into asterisk.
Definition: main/app.c:2792
def from_mailbox(key, val, section, pjsip, nmapped)
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
Definition: main/app.c:2143
int() ast_messagecount_fn(const char *mailbox_id, const char *folder)
Gets the number of messages that exist in a mailbox folder.
int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride)
Stream a filename (or file descriptor) as a generator.
Definition: main/app.c:1089
ast_getdata_result
Utility functions.
AST_THREADSTORAGE_EXTERNAL(ast_str_thread_global_buf)
int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path)
Allow to record message and have a review option.
Definition: main/app.c:2489
enum AST_LOCK_RESULT ast_lock_path(const char *path)
Lock a filesystem path.
Definition: main/app.c:2457
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
Definition: main/app.c:692
ast_has_voicemail_fn * has_voicemail
int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd)
Full version with audiofd and controlfd. NOTE: returns &#39;2&#39; on ctrlfd available, not &#39;1&#39; like other fu...
Definition: main/app.c:250
int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
Runs an IVR menu.
Definition: main/app.c:2785
int ast_vm_msg_move(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
Move messages from one folder to another.
Definition: main/app.c:756
A structure to hold the description of an application &#39;option&#39;.
ast_vm_mailbox_snapshot_create_fn * mailbox_snapshot_create
int() ast_inboxcount_fn(const char *mailboxes, int *newmsgs, int *oldmsgs)
Gets the number of messages that exist for the mailbox list.
void ast_safe_fork_cleanup(void)
Common routine to cleanup after fork&#39;ed process is complete (if reaping was stopped) ...
Definition: main/app.c:3108
static int silencethreshold
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:299
int ast_play_and_wait(struct ast_channel *chan, const char *fn)
Play a stream and wait for a digit, returning the digit that was pressed.
Definition: main/app.c:1470
int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
Record a file based on input from a channel This function will play "auth-thankyou" upon successful r...
Definition: main/app.c:1992
A set of macros to manage forward-linked lists.
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
Definition: main/app.c:2927
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:273
const char *() ast_vm_index_to_foldername_fn(int id)
Convert the mailbox folder id to a folder name.
ast_copy_recording_to_vm_fn * copy_recording_to_vm
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:2906
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
Definition: extconf.c:801
int ast_vm_msg_play(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)
Play a voicemail msg back on a channel.
Definition: main/app.c:799
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
Definition: main/app.c:748
int() ast_inboxcount2_fn(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Gets the number of messages that exist for the mailbox list.
int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:2911
int ast_vm_msg_remove(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
Remove/delete messages from a mailbox folder.
Definition: main/app.c:770
struct ast_module * module
The module for the voicemail greeter provider.
void ast_vm_greeter_unregister(const char *module_name)
Unregister the specified voicemail greeter provider.
Definition: main/app.c:584
struct ast_vm_mailbox_snapshot *() ast_vm_mailbox_snapshot_destroy_fn(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
int() ast_has_voicemail_fn(const char *mailboxes, const char *folder)
Determines if the given folder has messages.
static int skipms
uint64_t flag
The flag bit that represents this option.
int() ast_ivr_callback(struct ast_channel *chan, char *option, void *cbdata)
Callback function for IVR.
int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module)
Set voicemail greeter function callbacks.
Definition: main/app.c:552
ast_vm_msg_move_fn * msg_move
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
Definition: extconf.c:829
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_create(const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
Create a snapshot of a mailbox which contains information about every msg.
Definition: main/app.c:734
void() ast_waitstream_fr_cb(struct ast_channel *chan, long ms, enum ast_waitstream_fr_cb_values val)
callback used during dtmf controlled file playback to indicate location of playback in a file after r...
Definition: file.h:65
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
const char * module_name
The name of the module that provides the voicemail greeter functionality.
int() ast_vm_test_destroy_user_fn(const char *context, const char *user)
const char * ast_vm_index_to_foldername(int id)
Return name of folder, given an id.
Definition: main/app.c:726
Stack applications callback functions.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_mf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send a string of MF digits to a channel.
Definition: main/app.c:967
int ast_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child...
Definition: main/app.c:3047
int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path)
Record a file based on input from a channel. Use default accept and cancel DTMF. This function will p...
Definition: main/app.c:1997
int() ast_vm_test_create_user_fn(const char *context, const char *user)
ast_vm_msg_forward_fn * msg_forward
void ast_vm_test_swap_table_out(void)
Used after ast_vm_test_swap_table_in to restore the original set of voicemail functions.
Definition: main/app.c:515
int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:401
ast_vm_msg_play_fn * msg_play
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:409
long int flag
Definition: f2c.h:83
int ast_app_group_list_unlock(void)
Unlock the group count list.
Definition: main/app.c:2194
int() ast_copy_recording_to_vm_fn(struct ast_vm_recording_data *vm_rec_data)
Creates a voicemail based on a specified file to a mailbox.
int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max)
Split a group string into group and category, returning a default category if none is provided...
Definition: main/app.c:2009
int ast_vm_msg_forward(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
forward a message from one mailbox to another.
Definition: main/app.c:782
static void suspend(struct cc_core_instance *core_instance)
Definition: ccss.c:3193
struct ast_ivr_option * options
int ast_app_group_match_get_count(const char *groupmatch, const char *category)
Get the current channel count of all groups that match the specified pattern and category.
Definition: main/app.c:2103
char * category
Definition: channel.h:2940
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
Definition: main/app.c:197
unsigned int arg_index
The index of the entry in the arguments array that should be used for this option&#39;s argument...
structure to hold users read from users.conf
Structure used to handle boolean flags.
Definition: utils.h:199
ast_ivr_action
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder.
Definition: main/app.c:655
ast_vm_snapshot_sort_val
int ast_app_messagecount(const char *mailbox_id, const char *folder)
Get the number of messages in a given mailbox folder.
Definition: main/app.c:718
const char * module_name
The name of the module that provides the voicemail functionality.
Structure used for ast_copy_recording_to_vm in order to cleanly supply data needed for making the rec...
int ast_app_group_list_rdlock(void)
Read Lock the group count list.
Definition: main/app.c:2184
struct ast_vm_mailbox_snapshot *() ast_vm_mailbox_snapshot_create_fn(const char *user, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
Create a snapshot of a mailbox which contains information about every msg.
ast_inboxcount2_fn * inboxcount2
int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout)
Present a dialtone and collect a certain length extension.
Definition: main/app.c:139
ast_vm_msg_remove_fn * msg_remove
static PGresult * result
Definition: cel_pgsql.c:88
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:370
unsigned int module_version
The version of this function table.
int ast_control_streamfile_w_cb(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms, ast_waitstream_fr_cb cb)
Stream a file with fast forward, pause, reverse, restart.
Definition: main/app.c:1305
ast_messagecount_fn * messagecount
int ast_vm_test_create_user(const char *context, const char *mailbox)
Definition: main/app.c:813
static struct test_options options
static struct ast_str * prompt
Definition: asterisk.c:2725
int ast_app_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
Definition: main/app.c:2162
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit)
Common routine to parse time lengths, with optional time unit specifier.
Definition: main/app.c:3113
struct stasis_topic * ast_queue_topic(const char *queuename)
Get the Stasis Message Bus API topic for queue messages for a particular queue name.
Definition: main/app.c:3189
void ast_vm_test_swap_table_in(const struct ast_vm_functions *vm_table)
Swap out existing voicemail functions with a temporary set of functions for use with unit tests...
Definition: main/app.c:489
Voicemail function table definition.
AST_LOCK_TYPE
Type of locking to use in ast_lock_path / ast_unlock_path.
int ast_safe_execvp(int dualfork, const char *file, char *const argv[])
Safely spawn an external program while closing file descriptors.
Definition: asterisk.c:1180
int ast_app_copy_recording_to_vm(struct ast_vm_recording_data *vm_rec_data)
param[in] vm_rec_data Contains data needed to make the recording. retval 0 voicemail successfully cre...
Definition: main/app.c:669
int ast_app_group_set_channel(struct ast_channel *chan, const char *data)
Set the group for a channel, splitting the provided data into group and category, if specified...
Definition: main/app.c:2036
void ast_dtmf_stream_external(struct ast_channel *chan, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel from an external thread.
Definition: main/app.c:996
int ast_app_group_list_wrlock(void)
Write Lock the group count list.
Definition: main/app.c:2179
int app_init(void)
Initialize the application core.
Definition: main/app.c:3205
int ast_app_group_get_count(const char *group, const char *category)
Get the current channel count of the specified group and category.
Definition: main/app.c:2083
ast_vm_index_to_foldername_fn * index_to_foldername
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
Definition: main/app.c:677