1 /* vi: set sw=4 ts=4: */
3 * parse_num.c - Parse the number of blocks
5 * Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu>
7 * This file can be redistributed under the terms of the GNU Library General
15 unsigned long parse_num_blocks(const char *arg
, int log_block_size
)
18 unsigned long long num
;
20 num
= strtoull(arg
, &p
, 0);
25 switch (*p
) { /* Using fall-through logic */
33 num
>>= log_block_size
;
50 main(int argc
, char **argv
)
53 int log_block_size
= 0;
56 fprintf(stderr
, "Usage: %s arg\n", argv
[0]);
60 num
= parse_num_blocks(argv
[1], log_block_size
);
62 printf("Parsed number: %lu\n", num
);