From bcfcceee50dbab6fd6eaeec01d38c2eb63299025 Mon Sep 17 00:00:00 2001
From: ram <ram>
Date: Fri, 24 Jan 1992 09:04:45 +0000
Subject: [PATCH] Initial revision

---
 tools/chop.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 tools/chop.c

diff --git a/tools/chop.c b/tools/chop.c
new file mode 100644
index 000000000..2962f2de3
--- /dev/null
+++ b/tools/chop.c
@@ -0,0 +1,48 @@
+#include <stdio.h>
+
+#define BUFFERSIZE (1<<21)
+
+char buffer[BUFFERSIZE];
+
+void chop(infile)
+char *infile;
+{
+    FILE *in, *out;
+    char outfile[1024];
+    int count, bytes;
+
+    count = 0;
+
+    in = fopen(infile, "r");
+    if (in == NULL) {
+	perror(infile);
+	return;
+    }
+
+    while ((bytes = fread(buffer, 1, BUFFERSIZE, in)) != 0) {
+	sprintf(outfile, "%s.%d", infile, count++);
+	out = fopen(outfile, "w+");
+	if (out == NULL) {
+	    perror(outfile);
+	    fclose(in);
+	    return;
+	}
+	fwrite(buffer, 1, bytes, out);
+	fclose(out);
+    }
+
+    fclose(in);
+}
+
+main(argc, argv)
+int argc;
+char *argv[];
+{
+    if (argc < 2) {
+	fprintf(stderr, "usage: chop file...\n");
+	exit(1);
+    }
+
+    while (*++argv != NULL)
+	chop(*argv);
+}
-- 
GitLab