/[opencvs]/eyes/flip_flop.c
ViewVC logotype

Contents of /eyes/flip_flop.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Wed Mar 9 09:39:56 2011 UTC (7 years, 4 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
eyes - the best fucking mosaic out there
1 /*
2 Borrowed from the cvs player stuff
3 flipflop - a program to split out a file into 2 separate jobs.
4 One is standard error, and one is standard output
5 This takes one argument - the number of flipflops to do
6 This can be from 1 to 9, default (or zero) is 2
7
8 This goes to stdout, stderr, the file 3, 4,5,6,7,8,9
9
10
11 */
12
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <unistd.h>
19 #include <fcntl.h>
20 #include <sys/mman.h>
21 #include <string.h>
22
23 char buf[1000000];
24 int main (int argc, char *argv[]) {
25 int degree=2;
26 int i;
27 for (i=1;i<argc;i++) {
28 int x=atoi(argv[i]);
29 if (!x) x=2;
30 if ((x>9)||(x<1)) {
31 fprintf(stderr,"flip flop: illegal degree of flipping. 1-9 is the range\n");
32 exit(-1);
33 }
34 degree=x;
35 }
36
37 FILE *des[10];
38 des[0]=stdout;
39 des[1]=stderr;
40 char abuf[65536];
41 char bbuf[65536];
42 int x;
43 x=setvbuf(stdout,abuf,_IOFBF,65536);
44 if (x) {fprintf(stderr,"could not buffer stdio\n");exit(-1);}
45 x=setvbuf(stderr,bbuf,_IOFBF,65536);
46 if (x) {fprintf(stderr,"could not buffer sterr\n");exit(-1);}
47 for (i=2;i<degree;i++) {
48 char fname[20];
49 int y=i+1;
50 des[i]=fdopen(y,"w");
51 /* fprintf(stderr,"got %d\n",y);*/
52 }
53
54 i=0;
55 while (gets(buf)) {
56 fprintf(des[i],"%s\n",buf);
57 i= (i+1) % degree;
58 }
59 exit(0);
60 }

  ViewVC Help
Powered by ViewVC 1.1.5