chiark / gitweb /
Working on debianisation and packaging.
[chiark-utils.git] / backup / writebuffer.c
index 02254dca7a2ed5ee4661d5c4f7dcc5b7bc3fa6f7..aaff8d7859d48a30899fa93d21a3cf3158591597 100644 (file)
@@ -1,7 +1,15 @@
 /*
  * writebuffer.c
  *
- * Copyright (C) 1997,1998 Ian Jackson <ian@chiark.greenend.org.uk>
+ * A program for writing output to devices which don't like constant
+ * stopping and starting, such as tape drives.  writebuffer is:
+ *  Copyright (C) 1997-1998,2000-2001 Ian Jackson <ian@chiark.greenend.org.uk>
+ *
+ * writebuffer is part of chiark backup, a system for backing up GNU/Linux
+ * and other UN*X-compatible machines, as used on chiark.greenend.org.uk.
+ * chiark backup is:
+ *  Copyright (C) 1997-1998,2000-2001 Ian Jackson <ian@chiark.greenend.org.uk>
+ *  Copyright (C) 1999 Peter Maydell <pmaydell@chiark.greenend.org.uk>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as
 #include <errno.h>
 #include <unistd.h>
 
-#define BUFFER 16*1024*1024
+#ifndef RWBUFFER_SIZE_MB
+#define RWBUFFER_SIZE_MB 16
+#endif
+
+#define BUFFER (RWBUFFER_SIZE_MB*1024*1024)
 #define WAITFILL ((BUFFER*3)/4)
 
 static inline int min(int a, int b) { return a<=b ? a : b; }
@@ -41,16 +53,16 @@ static void nonblock(int fd) {
 int main(int argc, const char *const *argv) {
   static unsigned char buf[BUFFER];
   
-  if (argv[1]) {
-    fputs("readbuffer: no arguments allowed\n", stderr);
-    exit(-1);
-  }
-
   unsigned char *wp, *rp;
   int used,r,writing,seeneof;
   fd_set readfds;
   fd_set writefds;
 
+  if (argv[1]) {
+    fputs("readbuffer: no arguments allowed\n", stderr);
+    exit(-1);
+  }
+
   used=0; wp=rp=buf; writing=0; seeneof=0;
   nonblock(0); nonblock(1);
   while (!seeneof || used) {