14 #define AUDIO_FILENO (STDERR_FILENO + 1) 31 if (!fgets(buf,
sizeof(buf), stdin)) {
36 buf[strlen(buf) - 1] =
'\0';
40 val = strchr(buf,
':');
42 fprintf(stderr,
"Invalid environment: '%s'\n", buf);
49 fprintf(stderr,
"Environment: '%s' is '%s'\n", buf, val);
64 static char astresp[256];
68 FD_SET(STDIN_FILENO, &fds);
73 fprintf(stderr,
"Error in select: %s\n", strerror(
errno));
76 if (FD_ISSET(STDIN_FILENO, &fds)) {
77 if (!fgets(astresp,
sizeof(astresp), stdin)) {
81 fprintf(stderr,
"Got hungup on apparently\n");
84 astresp[strlen(astresp) - 1] =
'\0';
85 fprintf(stderr,
"Ooh, got a response from Asterisk: '%s'\n", astresp);
93 fprintf(stderr,
"Got %d/%d bytes of audio\n", res, bytes);
97 if (bytes > 16000 * 3) {
98 return "Sample Message";
109 fprintf(stdout,
"%s\n", command);
116 res =
run_command(
"STREAM FILE demo-enterkeywords 0123456789*#");
118 fprintf(stderr,
"Failed to execute command\n");
121 fprintf(stderr,
"1. Result is '%s'\n", res);
122 res =
run_command(
"STREAM FILE demo-nomatch 0123456789*#");
124 fprintf(stderr,
"Failed to execute command\n");
127 fprintf(stderr,
"2. Result is '%s'\n", res);
128 res =
run_command(
"SAY NUMBER 23452345 0123456789*#");
130 fprintf(stderr,
"Failed to execute command\n");
133 fprintf(stderr,
"3. Result is '%s'\n", res);
136 fprintf(stderr,
"Failed to execute command\n");
139 fprintf(stderr,
"4. Result is '%s'\n", res);
140 res =
run_command(
"STREAM FILE auth-thankyou \"\"");
142 fprintf(stderr,
"Failed to execute command\n");
145 fprintf(stderr,
"5. Result is '%s'\n", res);
149 int main(
int argc,
char *argv[])
158 fprintf(stderr,
"Failed to read environment: %s\n", strerror(
errno));
161 tmp = getenv(
"agi_enhanced");
163 if (sscanf(tmp,
"%30d.%30d", &ver, &subver) != 2)
167 fprintf(stderr,
"No enhanced AGI services available. Use EAGI, not AGI\n");
Asterisk main include file. File version handling, generic pbx functions.
static int read_environment(void)
static char * run_command(char *command)
static char * wait_result(void)
static int run_script(void)
int setenv(const char *name, const char *value, int overwrite)
int main(int argc, char *argv[])