]> git.rkrishnan.org Git - dttsp.git/blobdiff - jDttSP/mkchan.c
Major update
[dttsp.git] / jDttSP / mkchan.c
diff --git a/jDttSP/mkchan.c b/jDttSP/mkchan.c
deleted file mode 100644 (file)
index 2855980..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* mkchan.c */
-/* create a file big enough to accommodate
-   a header + a ringbuffer of a given size */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <stdlib.h>
-#include <values.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include <libgen.h>
-
-#include <datatypes.h>
-#include <banal.h>
-#include <ringb.h>
-
-char *rng_name = 0,
-     *buf_asks = 0;
-FILE *rng_file = 0;
-size_t rng_size = 0,
-       buf_size = 0,
-       blk_size = 0,
-       tot_size = 0;
-
-BOOLEAN verbose = FALSE;
-
-void
-execute(void) {
-  int i;
-  rng_size = sizeof(ringb_t);
-  if ((buf_size = atoi(buf_asks)) <= 0) {
-    fprintf(stderr, "buffer size %s?\n", buf_asks);
-    exit(1);
-  }
-  if (!(rng_file = fopen(rng_name, "w"))) {
-    perror(rng_name);
-    exit(1);
-  }
-  blk_size = nblock2(buf_size);
-  tot_size = rng_size + blk_size;
-  for (i = 0; i < tot_size; i++) putc(0, rng_file);
-  fclose(rng_file);
-  if (verbose)
-    fprintf(stderr,
-           "created chan file %s (%d + [%d -> %d] = %d)\n",
-           rng_name, rng_size, buf_size, blk_size, tot_size);
-}
-
-void
-closeup(void) { exit(0); }
-
-static void
-usage(void) {
-  fprintf(stderr, "usage:\n");
-  fprintf(stderr, "mkchan [-v] name size\n");
-  exit(1);
-}
-
-static void
-setup(int argc, char **argv) {
-  int i;
-
-  for (i = 1; i < argc; i++)
-    if (argv[i][0] == '-')
-      switch (argv[i][1]) {
-      case 'v': verbose = TRUE; break;
-      default: usage();
-      }
-    else break;
-  if (i < (argc - 2)) usage();
-  rng_name = argv[i++];
-  buf_asks = argv[i++];
-}
-
-int
-main(int argc, char **argv) { setup(argc, argv), execute(), closeup(); }