2 * parse_num.c - Parse the number of blocks
4 * Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu>
6 * This file can be redistributed under the terms of the GNU Library General
14 unsigned long parse_num_blocks(const char *arg, int log_block_size)
17 unsigned long long num;
19 num = strtoull(arg, &p, 0);
24 switch (*p) { /* Using fall-through logic */
32 num >>= log_block_size;
49 main(int argc, char **argv)
52 int log_block_size = 0;
55 fprintf(stderr, "Usage: %s arg\n", argv[0]);
59 num = parse_num_blocks(argv[1], log_block_size);
61 printf("Parsed number: %lu\n", num);