aewl

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gridsel.c	Tue Jul 11 13:21:57 2006 +0200
     1.3 @@ -0,0 +1,47 @@
     1.4 +/*
     1.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     1.6 + * See LICENSE file for license details.
     1.7 + */
     1.8 +
     1.9 +#include <stdlib.h>
    1.10 +#include <stdio.h>
    1.11 +#include <string.h>
    1.12 +
    1.13 +#include <util.h>
    1.14 +
    1.15 +static char version[] = "gridsel - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
    1.16 +
    1.17 +static void
    1.18 +usage()
    1.19 +{
    1.20 +	fprintf(stderr, "%s\n", "usage: gridsel [-v]\n");
    1.21 +	exit(1);
    1.22 +}
    1.23 +
    1.24 +int
    1.25 +main(int argc, char **argv)
    1.26 +{
    1.27 +	unsigned char *data;
    1.28 +	unsigned long i, offset, len, remain;
    1.29 +
    1.30 +	/* command line args */
    1.31 +	if(argc > 1) {
    1.32 +		if(!strncmp(argv[1], "-v", 3)) {
    1.33 +			fprintf(stdout, "%s", version);
    1.34 +			exit(0);
    1.35 +		} else
    1.36 +			usage();
    1.37 +	}
    1.38 +	len = offset = remain = 0;
    1.39 +	do {
    1.40 +		data = getselection(offset, &len, &remain);
    1.41 +		for(i = 0; i < len; i++)
    1.42 +			putchar(data[i]);
    1.43 +		offset += len;
    1.44 +		free(data);
    1.45 +	}
    1.46 +	while(remain);
    1.47 +	if(offset)
    1.48 +		putchar('\n');
    1.49 +	return 0;
    1.50 +}