Commit be9edec7 authored by Alessandro Rubini's avatar Alessandro Rubini

tools: offer a trivial common file to be included

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 663ebb23
/* Simple code that is repeated over several tools */
static inline void tools_getopt_d_i(int argc, char **argv,
int *dev, int *index)
{
char *rest;
int opt;
while ((opt = getopt(argc, argv, "d:i:")) != -1) {
switch (opt) {
case 'i':
*index = strtol(optarg, &rest, 0);
if (rest && *rest) {
fprintf(stderr, "%s: Not a number \"%s\"\n",
argv[0], optarg);
exit(1);
}
break;
case 'd':
*dev = strtol(optarg, &rest, 0);
if (rest && *rest) {
fprintf(stderr, "%s: Not a number \"%s\"\n",
argv[0], optarg);
exit(1);
}
break;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment