summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2012-03-14 23:22:05 +0000
committerAlex Merry <dev@randomguy3.me.uk>2012-03-14 23:22:05 +0000
commitbd8b9c41271712c08f24411ca447f9d17365818b (patch)
tree9ac3708af67771d5106939f414e87730340c9444
parent1755ec6d1e0d09d74de815a94dfeac8b7f4d88f4 (diff)
Add bustle-pcap.1pcap-man-page
Adds a --version argument to bustle-pcap (and slightly modifies the --help output) so that help2man can be used to generate a man page.
-rw-r--r--.gitignore1
-rw-r--r--Makefile8
-rw-r--r--c-sources/bustle-pcap.c19
3 files changed, 24 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index ee9ca3d..a428ade 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ Setup
*.hi
*.o
tags
+bustle-pcap.1
cabal-dev/
diff --git a/Makefile b/Makefile
index 6fe133b..1d83ef8 100644
--- a/Makefile
+++ b/Makefile
@@ -4,16 +4,20 @@ GIO_FLAGS := $(shell pkg-config --cflags --libs glib-2.0 gio-2.0 gio-unix-2.0)
PCAP_FLAGS := $(shell pcap-config --cflags pcap-config --libs)
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
+MAN1DIR = $(PREFIX)/share/man/man1
BINARIES = \
dist/build/bustle-pcap \
$(NULL)
-all: $(BINARIES)
+all: $(BINARIES) bustle-pcap.1
BUSTLE_PCAP_SOURCES = c-sources/pcap-monitor.c c-sources/bustle-pcap.c
BUSTLE_PCAP_HEADERS = c-sources/pcap-monitor.h
+bustle-pcap.1: c-sources/bustle-pcap.c
+ -help2man --output=$@ --no-info --name='Generate D-Bus logs for bustle' ./dist/build/bustle-pcap
+
dist/build/bustle-pcap: $(BUSTLE_PCAP_SOURCES) $(BUSTLE_PCAP_HEADERS)
@mkdir -p dist/build
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(BUSTLE_PCAP_SOURCES) \
@@ -22,6 +26,8 @@ dist/build/bustle-pcap: $(BUSTLE_PCAP_SOURCES) $(BUSTLE_PCAP_HEADERS)
install: all
mkdir -p $(BINDIR)
cp $(BINARIES) $(BINDIR)
+ -mkdir -p $(MAN1DIR)
+ -cp bustle-pcap.1 $(MAN1DIR)
uninstall:
rm -f $(notdir $(BINARIES))
diff --git a/c-sources/bustle-pcap.c b/c-sources/bustle-pcap.c
index 5d32cf5..b65d1ad 100644
--- a/c-sources/bustle-pcap.c
+++ b/c-sources/bustle-pcap.c
@@ -27,6 +27,7 @@
static gboolean verbose = FALSE;
static gboolean quiet = FALSE;
+static gboolean version = FALSE;
#if GLIB_CHECK_VERSION (2, 30, 0)
static void
@@ -85,8 +86,11 @@ static GOptionEntry entries[] = {
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet,
"Don't print out instructions", NULL
},
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &version,
+ "Print version information and exit", NULL
+ },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
- "blah blah", NULL
+ "The filename to log to", NULL
},
{ NULL }
};
@@ -103,8 +107,9 @@ parse_arguments (
GError *error = NULL;
gboolean ret;
- context = g_option_context_new ("FILENAME - logs D-Bus traffic to FILENAME");
+ context = g_option_context_new ("FILENAME");
g_option_context_add_main_entries (context, entries, NULL);
+ g_option_context_set_summary (context, "Logs D-Bus traffic to FILENAME in a format suitable for bustle");
ret = g_option_context_parse (context, argc, argv, &error);
usage = g_option_context_get_help (context, TRUE, NULL);
@@ -116,7 +121,15 @@ parse_arguments (
exit (2);
}
- if (session_specified && system_specified)
+ if (version)
+ {
+ fprintf (stdout, "bustle-pcap 0.4.0\n\n");
+ fprintf (stdout, "Copyright 2011 Will Thompson <will.thompson@collabora.co.uk>\n");
+ fprintf (stdout, "This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
+ fprintf (stdout, "Written by Will Thompson <will.thompson@collabora.co.uk>\n");
+ exit (0);
+ }
+ else if (session_specified && system_specified)
{
fprintf (stderr, "You may only specify one of --session and --system\n");
fprintf (stderr, "%s", usage);