2 * parse_num.c - Parse the number of blocks
4 * Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu>
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
16 unsigned long parse_num_blocks(const char *arg, int log_block_size)
19 unsigned long long num;
21 num = strtoull(arg, &p, 0);
26 switch (*p) { /* Using fall-through logic */
34 num >>= log_block_size;
37 num >>= (1+log_block_size);
51 main(int argc, char **argv)
54 int log_block_size = 0;
57 fprintf(stderr, "Usage: %s arg\n", argv[0]);
61 num = parse_num_blocks(argv[1], log_block_size);
63 printf("Parsed number: %lu\n", num);