2 /* create a file big enough to accommodate
3 a header + a ringbuffer of a given size */
21 #include <datatypes.h>
33 BOOLEAN verbose = FALSE;
38 rng_size = sizeof(ringb_t);
39 if ((buf_size = atoi(buf_asks)) <= 0) {
40 fprintf(stderr, "buffer size %s?\n", buf_asks);
43 if (!(rng_file = fopen(rng_name, "w"))) {
47 blk_size = nblock2(buf_size);
48 tot_size = rng_size + blk_size;
49 for (i = 0; i < tot_size; i++) putc(0, rng_file);
53 "created chan file %s (%d + [%d -> %d] = %d)\n",
54 rng_name, rng_size, buf_size, blk_size, tot_size);
58 closeup(void) { exit(0); }
62 fprintf(stderr, "usage:\n");
63 fprintf(stderr, "mkchan [-v] name size\n");
68 setup(int argc, char **argv) {
71 for (i = 1; i < argc; i++)
72 if (argv[i][0] == '-')
74 case 'v': verbose = TRUE; break;
78 if (i < (argc - 2)) usage();
84 main(int argc, char **argv) { setup(argc, argv), execute(), closeup(); }