diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-01-13 10:08:17 +0000 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-01-13 10:08:59 +0000 |
commit | bd5957f6bb522dae3e7fd591fab8859b72bab149 (patch) | |
tree | 77d861755e16652274c2f2a440fc79a3ac04f5d4 | |
parent | a2eb070375be30d7621cf7194e2dad9c43de2824 (diff) |
Rename BustlePcap to BustlePcapMonitor
This is a clearer name, matches the Haskell binding better, and means we
don't include two different headers called pcap.h.
-rw-r--r-- | Bustle/Monitor.hs | 18 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | bustle.cabal | 5 | ||||
-rw-r--r-- | c-sources/bustle-pcap.c | 8 | ||||
-rw-r--r-- | c-sources/pcap-monitor.c (renamed from c-sources/pcap.c) | 80 | ||||
-rw-r--r-- | c-sources/pcap-monitor.h | 66 | ||||
-rw-r--r-- | c-sources/pcap.h | 66 |
7 files changed, 124 insertions, 123 deletions
diff --git a/Bustle/Monitor.hs b/Bustle/Monitor.hs index a4558af..294f905 100644 --- a/Bustle/Monitor.hs +++ b/Bustle/Monitor.hs @@ -38,14 +38,14 @@ instance GObjectClass Monitor where unsafeCastGObject = Monitor . castForeignPtr . unGObject -- Dirty ugly foreign imports -foreign import ccall "bustle_pcap_new" - bustle_pcap_new :: CInt +foreign import ccall "bustle_pcap_monitor_new" + bustle_pcap_monitor_new :: CInt -> CString -> CInt -> Ptr (Ptr ()) -> IO (Ptr Monitor) -foreign import ccall "bustle_pcap_stop" - bustle_pcap_stop :: Ptr Monitor +foreign import ccall "bustle_pcap_monitor_stop" + bustle_pcap_monitor_stop :: Ptr Monitor -> IO () -- Bindings for said imports @@ -69,15 +69,15 @@ monitorNew busType filename debugOutput = wrapNewGObject mkMonitor $ propagateGError $ \gerrorPtr -> withCString filename $ \c_filename -> - bustle_pcap_new (fromIntegral $ fromEnum busType) - c_filename - (fromIntegral $ fromEnum debugOutput) - gerrorPtr + bustle_pcap_monitor_new (fromIntegral $ fromEnum busType) + c_filename + (fromIntegral $ fromEnum debugOutput) + gerrorPtr monitorStop :: Monitor -> IO () monitorStop monitor = do - withForeignPtr (unMonitor monitor) bustle_pcap_stop + withForeignPtr (unMonitor monitor) bustle_pcap_monitor_stop monitorMessageLogged :: Signal Monitor (IO ()) monitorMessageLogged = @@ -16,8 +16,8 @@ dist/build/bustle-dbus-monitor: c-sources/bustle-dbus-monitor.c @mkdir -p dist/build $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $< $(DBUS_FLAGS) -BUSTLE_PCAP_SOURCES = c-sources/pcap.c c-sources/bustle-pcap.c -BUSTLE_PCAP_HEADERS = c-sources/pcap.h +BUSTLE_PCAP_SOURCES = c-sources/pcap-monitor.c c-sources/bustle-pcap.c +BUSTLE_PCAP_HEADERS = c-sources/pcap-monitor.h dist/build/bustle-pcap: $(BUSTLE_PCAP_SOURCES) $(BUSTLE_PCAP_HEADERS) @mkdir -p dist/build diff --git a/bustle.cabal b/bustle.cabal index 1954319..cda1656 100644 --- a/bustle.cabal +++ b/bustle.cabal @@ -16,6 +16,7 @@ Data-files: data/bustle.png, Build-type: Simple Extra-source-files: c-sources/bustle-dbus-monitor.c, c-sources/bustle-pcap.c, + c-sources/pcap-monitor.h, Makefile, README, NEWS, @@ -68,7 +69,7 @@ Executable bustle -Wall -fno-warn-unused-imports -fno-warn-unused-do-bind - C-sources: c-sources/pcap.c + C-sources: c-sources/pcap-monitor.c pkgconfig-depends: glib-2.0 if flag(PostCabalizedGtk2HS) @@ -123,7 +124,7 @@ Executable test-monitor main-is: tests/Monitor.hs other-modules: Bustle.Monitor Ghc-options: -threaded - C-sources: c-sources/pcap.c + C-sources: c-sources/pcap-monitor.c pkgconfig-depends: glib-2.0 Build-Depends: base >= 4 && < 5 , gtk > 0.11 diff --git a/c-sources/bustle-pcap.c b/c-sources/bustle-pcap.c index 785a2e4..67f6e53 100644 --- a/c-sources/bustle-pcap.c +++ b/c-sources/bustle-pcap.c @@ -23,7 +23,7 @@ #include <glib/gprintf.h> #include <gio/gunixinputstream.h> -#include "pcap.h" +#include "pcap-monitor.h" static gboolean verbose = FALSE; static gboolean quiet = FALSE; @@ -152,12 +152,12 @@ main ( GBusType bus_type; gchar *filename; GError *error = NULL; - BustlePcap *pcap; + BustlePcapMonitor *pcap; g_type_init (); parse_arguments (&argc, &argv, &bus_type, &filename); - pcap = bustle_pcap_new (bus_type, filename, verbose, &error); + pcap = bustle_pcap_monitor_new (bus_type, filename, verbose, &error); if (pcap == NULL) { fprintf (stderr, "%s", error->message); @@ -173,7 +173,7 @@ main ( g_main_loop_run (loop); g_main_loop_unref (loop); - bustle_pcap_stop (pcap); + bustle_pcap_monitor_stop (pcap); g_object_unref (pcap); return 0; diff --git a/c-sources/pcap.c b/c-sources/pcap-monitor.c index 98920fa..54b9e1e 100644 --- a/c-sources/pcap.c +++ b/c-sources/pcap-monitor.c @@ -1,6 +1,6 @@ /* - * pcap.c - blah blah - * Copyright ©2011 Collabora Ltd. + * pcap-monitor.c - monitors a bus and dumps messages to a pcap file + * Copyright ©2011–2012 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "pcap.h" +#include "pcap-monitor.h" #include <string.h> #include <pcap/pcap.h> @@ -38,7 +38,7 @@ typedef struct { GAsyncQueue *message_queue; } ThreadData; -struct _BustlePcapPrivate { +struct _BustlePcapMonitorPrivate { GBusType bus_type; GDBusConnection *connection; GDBusCapabilityFlags caps; @@ -73,28 +73,28 @@ static void initable_iface_init ( gpointer g_class, gpointer unused); -G_DEFINE_TYPE_WITH_CODE (BustlePcap, bustle_pcap, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (BustlePcapMonitor, bustle_pcap_monitor, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init); ) static void -bustle_pcap_init (BustlePcap *self) +bustle_pcap_monitor_init (BustlePcapMonitor *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BUSTLE_TYPE_PCAP, - BustlePcapPrivate); + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BUSTLE_TYPE_PCAP_MONITOR, + BustlePcapMonitorPrivate); self->priv->bus_type = G_BUS_TYPE_SESSION; self->priv->td.message_queue = g_async_queue_new (); } static void -bustle_pcap_get_property ( +bustle_pcap_monitor_get_property ( GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - BustlePcap *self = BUSTLE_PCAP (object); - BustlePcapPrivate *priv = self->priv; + BustlePcapMonitor *self = BUSTLE_PCAP_MONITOR (object); + BustlePcapMonitorPrivate *priv = self->priv; switch (property_id) { @@ -113,14 +113,14 @@ bustle_pcap_get_property ( } static void -bustle_pcap_set_property ( +bustle_pcap_monitor_set_property ( GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - BustlePcap *self = BUSTLE_PCAP (object); - BustlePcapPrivate *priv = self->priv; + BustlePcapMonitor *self = BUSTLE_PCAP_MONITOR (object); + BustlePcapMonitorPrivate *priv = self->priv; switch (property_id) { @@ -139,27 +139,27 @@ bustle_pcap_set_property ( } static void -bustle_pcap_dispose (GObject *object) +bustle_pcap_monitor_dispose (GObject *object) { - BustlePcap *self = BUSTLE_PCAP (object); - BustlePcapPrivate *priv = self->priv; - GObjectClass *parent_class = bustle_pcap_parent_class; + BustlePcapMonitor *self = BUSTLE_PCAP_MONITOR (object); + BustlePcapMonitorPrivate *priv = self->priv; + GObjectClass *parent_class = bustle_pcap_monitor_parent_class; if (parent_class->dispose != NULL) parent_class->dispose (object); /* Make sure we're all closed up. */ - bustle_pcap_stop (self); + bustle_pcap_monitor_stop (self); g_clear_object (&priv->connection); } static void -bustle_pcap_finalize (GObject *object) +bustle_pcap_monitor_finalize (GObject *object) { - BustlePcap *self = BUSTLE_PCAP (object); - BustlePcapPrivate *priv = self->priv; - GObjectClass *parent_class = bustle_pcap_parent_class; + BustlePcapMonitor *self = BUSTLE_PCAP_MONITOR (object); + BustlePcapMonitorPrivate *priv = self->priv; + GObjectClass *parent_class = bustle_pcap_monitor_parent_class; if (parent_class->finalize != NULL) parent_class->finalize (object); @@ -172,17 +172,17 @@ bustle_pcap_finalize (GObject *object) } static void -bustle_pcap_class_init (BustlePcapClass *klass) +bustle_pcap_monitor_class_init (BustlePcapMonitorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GParamSpec *param_spec; - object_class->get_property = bustle_pcap_get_property; - object_class->set_property = bustle_pcap_set_property; - object_class->dispose = bustle_pcap_dispose; - object_class->finalize = bustle_pcap_finalize; + object_class->get_property = bustle_pcap_monitor_get_property; + object_class->set_property = bustle_pcap_monitor_set_property; + object_class->dispose = bustle_pcap_monitor_dispose; + object_class->finalize = bustle_pcap_monitor_finalize; - g_type_class_add_private (klass, sizeof (BustlePcapPrivate)); + g_type_class_add_private (klass, sizeof (BustlePcapMonitorPrivate)); #define THRICE(x) x, x, x @@ -200,7 +200,7 @@ bustle_pcap_class_init (BustlePcapClass *klass) g_object_class_install_property (object_class, PROP_VERBOSE, param_spec); signals[SIG_MESSAGE_LOGGED] = g_signal_new ("message-logged", - BUSTLE_TYPE_PCAP, G_SIGNAL_RUN_FIRST, + BUSTLE_TYPE_PCAP_MONITOR, G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); } @@ -231,7 +231,7 @@ log_thread (gpointer data) static gboolean emit_me (gpointer data) { - BustlePcap *self = BUSTLE_PCAP (data); + BustlePcapMonitor *self = BUSTLE_PCAP_MONITOR (data); g_signal_emit (self, signals[SIG_MESSAGE_LOGGED], 0); g_object_unref (self); @@ -245,7 +245,7 @@ filter ( gboolean is_incoming, gpointer user_data) { - BustlePcap *self = BUSTLE_PCAP (user_data); + BustlePcapMonitor *self = BUSTLE_PCAP_MONITOR (user_data); const gchar *sender, *dest; Message m; GError *error = NULL; @@ -381,8 +381,8 @@ initable_init ( GCancellable *cancellable, GError **error) { - BustlePcap *self = BUSTLE_PCAP (initable); - BustlePcapPrivate *priv = self->priv; + BustlePcapMonitor *self = BUSTLE_PCAP_MONITOR (initable); + BustlePcapMonitorPrivate *priv = self->priv; GDBusProxy *bus; if (priv->bus_type == G_BUS_TYPE_NONE) @@ -468,10 +468,10 @@ initable_init ( /* FIXME: make this async? */ void -bustle_pcap_stop ( - BustlePcap *self) +bustle_pcap_monitor_stop ( + BustlePcapMonitor *self) { - BustlePcapPrivate *priv = self->priv; + BustlePcapMonitorPrivate *priv = self->priv; if (priv->filter_id != 0) { @@ -518,15 +518,15 @@ initable_iface_init ( iface->init = initable_init; } -BustlePcap * -bustle_pcap_new ( +BustlePcapMonitor * +bustle_pcap_monitor_new ( GBusType bus_type, const gchar *filename, gboolean verbose, GError **error) { return g_initable_new ( - BUSTLE_TYPE_PCAP, NULL, error, + BUSTLE_TYPE_PCAP_MONITOR, NULL, error, "bus-type", bus_type, "filename", filename, "verbose", verbose, diff --git a/c-sources/pcap-monitor.h b/c-sources/pcap-monitor.h new file mode 100644 index 0000000..e986b4e --- /dev/null +++ b/c-sources/pcap-monitor.h @@ -0,0 +1,66 @@ +/* + * pcap-monitor.h - monitors a bus and dumps messages to a pcap file + * Copyright ©2011–2012 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef BUSTLE_PCAP_MONITOR_H +#define BUSTLE_PCAP_MONITOR_H + +#include <glib-object.h> +#include <gio/gio.h> + +typedef struct _BustlePcapMonitor BustlePcapMonitor; +typedef struct _BustlePcapMonitorClass BustlePcapMonitorClass; +typedef struct _BustlePcapMonitorPrivate BustlePcapMonitorPrivate; + +struct _BustlePcapMonitorClass { + GObjectClass parent_class; +}; + +struct _BustlePcapMonitor { + GObject parent; + + BustlePcapMonitorPrivate *priv; +}; + +GType bustle_pcap_monitor_get_type (void); + +BustlePcapMonitor *bustle_pcap_monitor_new ( + GBusType bus_type, + const gchar *filename, + gboolean verbose, + GError **error); +void bustle_pcap_monitor_stop ( + BustlePcapMonitor *self); + +/* TYPE MACROS */ +#define BUSTLE_TYPE_PCAP_MONITOR \ + (bustle_pcap_monitor_get_type ()) +#define BUSTLE_PCAP_MONITOR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), BUSTLE_TYPE_PCAP_MONITOR, BustlePcapMonitor)) +#define BUSTLE_PCAP_MONITOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), BUSTLE_TYPE_PCAP_MONITOR,\ + BustlePcapMonitorClass)) +#define BUSTLE_IS_PCAP_MONITOR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), BUSTLE_TYPE_PCAP_MONITOR)) +#define BUSTLE_IS_PCAP_MONITOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), BUSTLE_TYPE_PCAP_MONITOR)) +#define BUSTLE_PCAP_MONITOR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), BUSTLE_TYPE_PCAP_MONITOR, \ + BustlePcapMonitorClass)) + +#endif /* BUSTLE_PCAP_MONITOR_H */ diff --git a/c-sources/pcap.h b/c-sources/pcap.h deleted file mode 100644 index 4a37f34..0000000 --- a/c-sources/pcap.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * pcap.h - header for blah blah - * Copyright ©2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef BUSTLE_PCAP_H -#define BUSTLE_PCAP_H - -#include <glib-object.h> -#include <gio/gio.h> - -typedef struct _BustlePcap BustlePcap; -typedef struct _BustlePcapClass BustlePcapClass; -typedef struct _BustlePcapPrivate BustlePcapPrivate; - -struct _BustlePcapClass { - GObjectClass parent_class; -}; - -struct _BustlePcap { - GObject parent; - - BustlePcapPrivate *priv; -}; - -GType bustle_pcap_get_type (void); - -BustlePcap *bustle_pcap_new ( - GBusType bus_type, - const gchar *filename, - gboolean verbose, - GError **error); -void bustle_pcap_stop ( - BustlePcap *self); - -/* TYPE MACROS */ -#define BUSTLE_TYPE_PCAP \ - (bustle_pcap_get_type ()) -#define BUSTLE_PCAP(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), BUSTLE_TYPE_PCAP, BustlePcap)) -#define BUSTLE_PCAP_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), BUSTLE_TYPE_PCAP,\ - BustlePcapClass)) -#define BUSTLE_IS_PCAP(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), BUSTLE_TYPE_PCAP)) -#define BUSTLE_IS_PCAP_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), BUSTLE_TYPE_PCAP)) -#define BUSTLE_PCAP_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), BUSTLE_TYPE_PCAP, \ - BustlePcapClass)) - -#endif /* BUSTLE_PCAP_H */ |