Title update
[asterisk/asterisk.git] / agi / eagi-test.c
index ed725fc..7f24d1f 100644 (file)
@@ -5,17 +5,12 @@
  * with no warranty of any kind
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/select.h>
+/*** MODULEINFO
+       <support_level>extended</support_level>
+ ***/
 
 #include "asterisk.h"
 
-#include "asterisk/compat.h"
-
 #define AUDIO_FILENO (STDERR_FILENO + 1)
 
 /*! \file
@@ -33,7 +28,9 @@ static int read_environment(void)
        char *val;
        /* Read environment */
        for(;;) {
-               fgets(buf, sizeof(buf), stdin);
+               if (!fgets(buf, sizeof(buf), stdin)) {
+                       return -1;
+               }
                if (feof(stdin))
                        return -1;
                buf[strlen(buf) - 1] = '\0';
@@ -77,7 +74,9 @@ static char *wait_result(void)
                        return NULL;
                }
                if (FD_ISSET(STDIN_FILENO, &fds)) {
-                       fgets(astresp, sizeof(astresp), stdin);
+                       if (!fgets(astresp, sizeof(astresp), stdin)) {
+                               return NULL;
+                       }
                        if (feof(stdin)) {
                                fprintf(stderr, "Got hungup on apparently\n");
                                return NULL;
@@ -161,7 +160,7 @@ int main(int argc, char *argv[])
        }
        tmp = getenv("agi_enhanced");
        if (tmp) {
-               if (sscanf(tmp, "%d.%d", &ver, &subver) != 2)
+               if (sscanf(tmp, "%30d.%30d", &ver, &subver) != 2)
                        ver = 0;
        }
        if (ver < 1) {