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