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