summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2020-05-25 21:29:26 +0200
committerDominique Martinet <asmadeus@codewreck.org>2020-05-25 21:29:26 +0200
commit8813b7e014b9ac9395a5b39b156f26a91d4e8ec2 (patch)
treea303fc584796fc9f13cfaf025df4e38be7e4ff35
parent01fbd49f30c6dd370396cf0cc03a9891bf7b7f8a (diff)
fdgrab: add --verbose
-rw-r--r--fdgrab.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fdgrab.c b/fdgrab.c
index aa97965..4569c6c 100644
--- a/fdgrab.c
+++ b/fdgrab.c
@@ -15,6 +15,7 @@ static struct argp_option options[] = {
"@ at start of string will be replaced by a null for abstract socket "
"(defaults to @fdgrab)",
0 },
+ { "verbose", 'v', 0, 0, "Verbose output.", 1 },
/* help & usage:
* default help is -? which I don't like, so redefine them
* (ARGP_NO_HELP set below). usage is added because usage
@@ -27,6 +28,7 @@ static struct argp_option options[] = {
};
struct arguments {
+ int verbose;
char sun_path[108]; /* XXX find a proper way to look this up? */
};
@@ -44,6 +46,10 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
}
return 0;
+ case 'v':
+ arguments->verbose++;
+ return 0;
+
case 'h':
argp_state_help(state, stderr, ARGP_HELP_STD_HELP);
__builtin_unreachable();
@@ -125,6 +131,8 @@ int main(int argc, char *argv[]) {
(void)close(fd);
return rc;
}
+ if (arguments.verbose)
+ printf("Got %s on fd %d\n", pattern+1, fd);
/* earlier -2 should guarantee this */
assert(len + 2 < sizeof(pattern));