[PATCH] Cleanups/dead code removal
[splice.git] / ktee-net.c
old mode 100755 (executable)
new mode 100644 (file)
index e2ebde0..3ae2529
@@ -7,11 +7,9 @@
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
-#include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <errno.h>
 #include <limits.h>
@@ -34,7 +32,7 @@ static int do_splice(int infd, int outfd, unsigned int len, char *msg)
 
 static int usage(char *name)
 {
-       fprintf(stderr, "%s: hostname:port\n", name);
+       fprintf(stderr, "... | %s: hostname:port\n", name);
        return 1;
 }
 
@@ -42,18 +40,13 @@ int main(int argc, char *argv[])
 {
        struct sockaddr_in addr;
        char *p, *hname;
-       struct stat sb;
        int fd;
 
        if (argc < 2)
                return usage(argv[0]);
 
-       if (fstat(STDIN_FILENO, &sb) < 0)
-               return error("stat");
-       if (!S_ISFIFO(sb.st_mode)) {
-               fprintf(stderr, "stdin must be a pipe\n");
-               return 1;
-       }
+       if (check_input_pipe())
+               return usage(argv[0]);
 
        hname = strdup(argv[1]);
        p = strstr(hname, ":");
@@ -78,8 +71,6 @@ int main(int argc, char *argv[])
        if (fd < 0)
                return error("socket");
 
-       fprintf(stderr, "connecting to %s, port %x\n", hname, addr.sin_port);
-
        if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0)
                return error("connect");