splice-fromnet/out: more flags
authorJens Axboe <jens.axboe@oracle.com>
Tue, 12 Jun 2007 22:10:23 +0000 (15:10 -0700)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 12 Jun 2007 22:10:23 +0000 (15:10 -0700)
splice-fromnet.c
splice-out.c

index 5f281b81465a6f6b25ab2a178b365be93faab7f0..7493e5b0308a871e7cc5df24819afa99edb7ee7a 100644 (file)
 #include "splice.h"
 
 static unsigned int splice_size = SPLICE_SIZE;
+static unsigned int splice_flags;
 static int wait_for_poll;
 
 static int usage(char *name)
 {
-       fprintf(stderr, "%s: [-s splice size] [-w wait for poll] port\n", name);
+       fprintf(stderr, "%s: [-s splice size] [-w wait for poll] [-n non-blocking] port\n", name);
        return 1;
 }
 
@@ -88,7 +89,7 @@ static int parse_options(int argc, char *argv[])
 {
        int c, index = 1;
 
-       while ((c = getopt(argc, argv, "s:w:")) != -1) {
+       while ((c = getopt(argc, argv, "s:w:n")) != -1) {
                switch (c) {
                case 's':
                        splice_size = atoi(optarg);
@@ -98,6 +99,10 @@ static int parse_options(int argc, char *argv[])
                        wait_for_poll = atoi(optarg);
                        index++;
                        break;
+               case 'n':
+                       splice_flags |= SPLICE_F_NONBLOCK;
+                       index++;
+                       break;
                default:
                        return -1;
                }
index 88223e81911ae9fb2cfa3965341d66628e8c20b9..2a2a4f58412cf727b23548fa4b9a9dd61b744e4d 100644 (file)
@@ -9,10 +9,11 @@
 #include "splice.h"
 
 static int splice_flags;
+static unsigned int splice_size = SPLICE_SIZE;
 
 static int usage(char *name)
 {
-       fprintf(stderr, "... | %s: [-m] out_file\n", name);
+       fprintf(stderr, "... | %s: [-m] [-s splice size] out_file\n", name);
        return 1;
 }
 
@@ -20,12 +21,16 @@ static int parse_options(int argc, char *argv[])
 {
        int c, index = 1;
 
-       while ((c = getopt(argc, argv, "m")) != -1) {
+       while ((c = getopt(argc, argv, "ms:")) != -1) {
                switch (c) {
                case 'm':
                        splice_flags = SPLICE_F_MOVE;
                        index++;
                        break;
+               case 's':
+                       splice_size = atoi(optarg);
+                       index++;
+                       break;
                default:
                        return -1;
                }
@@ -50,7 +55,7 @@ int main(int argc, char *argv[])
                return error("open");
 
        do {
-               int ret = ssplice(STDIN_FILENO, NULL, fd, NULL, SPLICE_SIZE, splice_flags);
+               int ret = ssplice(STDIN_FILENO, NULL, fd, NULL, splice_size, splice_flags);
 
                if (ret < 0)
                        return error("splice");