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