Version 0.1.9 from FTP
[asterisk/asterisk.git] / app.c
1 /*
2  * Asterisk -- A telephony toolkit for Linux.
3  *
4  * Channel Management
5  * 
6  * Copyright (C) 1999, Mark Spencer
7  *
8  * Mark Spencer <markster@linux-support.net>
9  *
10  * This program is free software, distributed under the terms of
11  * the GNU General Public License
12  */
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <pthread.h>
17 #include <string.h>
18 #include <sys/time.h>
19 #include <signal.h>
20 #include <errno.h>
21 #include <unistd.h>
22 #include <asterisk/channel.h>
23 #include <asterisk/file.h>
24 #include <asterisk/app.h>
25
26 /* set timeout to 0 for "standard" timeouts. Set timeout to -1 for 
27    "ludicrous time" (essentially never times out) */
28 int ast_app_getdata(struct ast_channel *c, char *prompt, char *s, int maxlen, int timeout)
29 {
30         int res,to,fto;
31         if (prompt) {
32                 res = ast_streamfile(c, prompt, c->language);
33                 if (res < 0)
34                         return res;
35         }
36         fto = 6000;
37         to = 2000;
38         if (timeout > 0) fto = to = timeout;
39         if (timeout < 0) fto = to = 1000000000;
40         res = ast_readstring(c, s, maxlen, to, fto, "#");
41         return res;
42 }
43