Пример #1
0
main(int argc, char **argv) {
    char *programName;
    int err = 0;

    programName = argv[0];
    cleSetDefaults(clargs);
    err = cleExtractArgs(clargs, &argc, argv, 0);

    if (argc > 1) {spec = argv[1];}

    if(err || spec == NULL) {
	cleUsage(clargs, programName);
	exit(-1);
    }

    Range r(spec, min_val, max_val+1);
    if (debug) {
	r.PrintRanges(spec,stdout);
	// Is it full?
	fprintf(stdout, "first=%d last=%d full=%d contains(0)=%d\n",
		r.first(), r.last(), r.full(), r.contains(0));
    }

    if (indx != RNG_VAL_BAD) {
	int sby=5;
	fprintf(stderr, "list[%d] = %d\n", indx, r.index(indx));
	Range::iterator it = r.begin();
	int i;
	for (i = 0; i < indx; ++i) {
	    ++it;
	}
	int v1 = *it;
	it.step_by(sby);
	fprintf(stderr, "list[%d+%d] = %d..%d\n", indx, sby, v1, *it);
    }
    
    if (!quiet) {
	int first = 1;
	for (Range::iterator it = r.begin(); 
	     !it.at_end(); it++) {
	    // Handle any inter-term separator
	    if (first) {first=0;} else {
		if (commas) {
		    fprintf(stdout, ",");
		} else if (horizontal) {
		    fprintf(stdout, " ");
		}
		if (!horizontal) {
		    fprintf(stdout, "\n");
		}
	    }
	    // Print the actual term
	    fprintf(stdout, "%d", *it);
	}
	// Always a final return
	fprintf(stdout, "\n");
    }
}
Пример #2
0
Файл: cle.c Проект: dpwe/dpwelib
int cleHandleArgs(CLE_ENTRY *entries, int argc, char *argv[])
{  /* parse a set of command line arguments according to a structure */
    int err = cleExtractArgs(entries, &argc, argv, 1);
    return err;
}