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