Blame tests/miniseq.c

Packit 56e23f
/**
Packit 56e23f
 * Seccomp Library test support program
Packit 56e23f
 *
Packit 56e23f
 * Copyright (c) 2015 Mathias Krause <minipli@googlemail.com>
Packit 56e23f
 */
Packit 56e23f
Packit 56e23f
/*
Packit 56e23f
 * This library is free software; you can redistribute it and/or modify it
Packit 56e23f
 * under the terms of version 2.1 of the GNU Lesser General Public License as
Packit 56e23f
 * published by the Free Software Foundation.
Packit 56e23f
 *
Packit 56e23f
 * This library is distributed in the hope that it will be useful, but WITHOUT
Packit 56e23f
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
Packit 56e23f
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
Packit 56e23f
 * for more details.
Packit 56e23f
 *
Packit 56e23f
 * You should have received a copy of the GNU Lesser General Public License
Packit 56e23f
 * along with this library; if not, see <http://www.gnu.org/licenses>.
Packit 56e23f
 */
Packit 56e23f
Packit 56e23f
#include <inttypes.h>
Packit 56e23f
#include <stdlib.h>
Packit 56e23f
#include <stdint.h>
Packit 56e23f
#include <stdio.h>
Packit 56e23f
#include <errno.h>
Packit 56e23f
Packit 56e23f
static int get_number(char *str, uint64_t *res)
Packit 56e23f
{
Packit 56e23f
	char *end = str;
Packit 56e23f
Packit 56e23f
	errno = 0;
Packit 56e23f
	*res = strtoull(str, &end, 0);
Packit 56e23f
	if (errno || *end != '\0') {
Packit 56e23f
		fprintf(stderr, "error: failed to convert '%s'\n", str);
Packit 56e23f
		return -1;
Packit 56e23f
	}
Packit 56e23f
Packit 56e23f
	return 0;
Packit 56e23f
}
Packit 56e23f
Packit 56e23f
int main(int argc, char *argv[])
Packit 56e23f
{
Packit 56e23f
	uint64_t first, last, cur;
Packit 56e23f
Packit 56e23f
	if (argc != 3) {
Packit 56e23f
		fprintf(stderr, "usage: %s FIRST LAST\n", argv[0]);
Packit 56e23f
		return 1;
Packit 56e23f
	}
Packit 56e23f
Packit 56e23f
	if (get_number(argv[1], &first) || get_number(argv[2], &last))
Packit 56e23f
		return 1;
Packit 56e23f
Packit 56e23f
	for (cur = first; cur != last; cur++)
Packit 56e23f
		printf("%" PRId64 "\n", cur);
Packit 56e23f
	printf("%" PRId64 "\n", cur);
Packit 56e23f
Packit 56e23f
	return 0;
Packit 56e23f
}