Code

test GNU_SOURCE and include features.h if present to clear warning about asprintf...
[nagiosplug.git] / plugins / check_real.c
index ef3581b9508a361d63255c017caa363eec88b3c7..1744b329a81ba11d90e6b9a3a39cfd6a18163758 100644 (file)
@@ -63,7 +63,7 @@ void print_usage (void);
 int server_port = PORT;
 char *server_address = "";
 char *host_name = "";
-char *server_url = "/";
+char *server_url = NULL;
 char *server_expect = EXPECT;
 int warning_time = 0;
 int check_warning_time = FALSE;
@@ -97,15 +97,15 @@ main (int argc, char **argv)
        /* Part I - Server Check */
 
        /* send the OPTIONS request */
-       sprintf (buffer, "OPTIONS rtsp://%s:%d RTSP/1.0\n", host_name, server_port);
+       sprintf (buffer, "OPTIONS rtsp://%s:%d RTSP/1.0\r\n", host_name, server_port);
        result = send (sd, buffer, strlen (buffer), 0);
 
        /* send the header sync */
-       sprintf (buffer, "CSeq: 1\n");
+       sprintf (buffer, "CSeq: 1\r\n");
        result = send (sd, buffer, strlen (buffer), 0);
 
        /* send a newline so the server knows we're done with the request */
-       sprintf (buffer, "\n");
+       sprintf (buffer, "\r\n");
        result = send (sd, buffer, strlen (buffer), 0);
 
        /* watch for the REAL connection string */
@@ -162,7 +162,7 @@ main (int argc, char **argv)
        }
 
        /* Part II - Check stream exists and is ok */
-       if (result == STATE_OK) {
+       if ((result == STATE_OK )&& (server_url != NULL) ) {
 
                /* Part I - Server Check */
 
@@ -274,7 +274,6 @@ process_arguments (int argc, char **argv)
 {
        int c;
 
-#ifdef HAVE_GETOPT_H
        int option_index = 0;
        static struct option long_options[] = {
                {"hostname", required_argument, 0, 'H'},
@@ -290,7 +289,6 @@ process_arguments (int argc, char **argv)
                {"help", no_argument, 0, 'h'},
                {0, 0, 0, 0}
        };
-#endif
 
        if (argc < 2)
                return ERROR;
@@ -305,13 +303,8 @@ process_arguments (int argc, char **argv)
        }
 
        while (1) {
-#ifdef HAVE_GETOPT_H
-               c =
-                       getopt_long (argc, argv, "+hVI:H:e:u:p:w:c:t:", long_options,
+               c = getopt_long (argc, argv, "+hVI:H:e:u:p:w:c:t:", long_options,
                                                                         &option_index);
-#else
-               c = getopt (argc, argv, "+?hVI:H:e:u:p:w:c:t");
-#endif
 
                if (c == -1 || c == EOF)
                        break;