JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
added gridsel to gridwm
[dwm.git] / gridsel.c
1 /*
2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3  * See LICENSE file for license details.
4  */
5
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <string.h>
9
10 #include <util.h>
11
12 static char version[] = "gridsel - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
13
14 static void
15 usage()
16 {
17         fprintf(stderr, "%s\n", "usage: gridsel [-v]\n");
18         exit(1);
19 }
20
21 int
22 main(int argc, char **argv)
23 {
24         unsigned char *data;
25         unsigned long i, offset, len, remain;
26
27         /* command line args */
28         if(argc > 1) {
29                 if(!strncmp(argv[1], "-v", 3)) {
30                         fprintf(stdout, "%s", version);
31                         exit(0);
32                 } else
33                         usage();
34         }
35         len = offset = remain = 0;
36         do {
37                 data = getselection(offset, &len, &remain);
38                 for(i = 0; i < len; i++)
39                         putchar(data[i]);
40                 offset += len;
41                 free(data);
42         }
43         while(remain);
44         if(offset)
45                 putchar('\n');
46         return 0;
47 }