]> git.scottworley.com Git - overonion/blobdiff - reverse_lib.c
Test reverse
[overonion] / reverse_lib.c
index a800db84dce4cdf1e7a30e5ca909562c171a8042..e69922b181d3adc76153c311889d74822bd85ac7 100644 (file)
@@ -22,7 +22,7 @@ static void write_all(int fd, const void *buf, size_t count) {
   }
 }
 
-void reverse_file(const char* input_filename) {
+void reverse_file(const char* input_filename, int output_fd) {
   int fd = open(input_filename, O_RDONLY);
   if (fd == -1) {
     err(EX_NOINPUT, "Could not open specified file");
@@ -46,12 +46,12 @@ void reverse_file(const char* input_filename) {
   for (off_t p = stats.st_size - 1; p >= 0; p--) {
     buf[buf_offset++] = m[p];
     if (buf_offset >= BUFFER_SIZE) {
-      write_all(1, buf, buf_offset);
+      write_all(output_fd, buf, buf_offset);
       buf_offset = 0;
     }
   }
   if (buf_offset) {
-    write_all(1, buf, buf_offset);
+    write_all(output_fd, buf, buf_offset);
   }
 
   if (munmap(m, map_size) == -1) {