[libgtop] Make some APIs that return struct introspectable



commit 3f8f65386e2e88257eca0a0a91c6b3f42132c019
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Nov 2 15:18:20 2011 -0400

    Make some APIs that return struct introspectable
    
    In order to do this, we need to define some boxed types. So we need
    to add a new dependency, GObject, to GTop.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663265

 configure.ac                    |    3 +-
 glibtop.h                       |    3 ++
 include/glibtop/mountlist.h     |   34 ++++++++++++++++++++++++++++
 include/glibtop/procmap.h       |   38 +++++++++++++++++++++++++++++++
 include/glibtop/procopenfiles.h |   39 ++++++++++++++++++++++++++++++++
 lib/Makefile.am                 |    2 +-
 lib/boxed.c                     |   47 +++++++++++++++++++++++++++++++++++++++
 lib/libgtop.sym                 |    7 +++++
 8 files changed, 171 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bc6f88f..3fe868e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,8 +91,9 @@ GNOME_LIBGTOP_SYSDEPS
 GNOME_LIBGTOP_TYPES
 
 GLIB_REQUIRED=2.6.0
+GOBJECT_REQUIRED=2.26.0
 
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GOBJECT_REQUIRED)
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
diff --git a/glibtop.h b/glibtop.h
index 8b31d10..0d3e7dd 100644
--- a/glibtop.h
+++ b/glibtop.h
@@ -23,6 +23,7 @@
 #define __GLIBTOP_H__
 
 #include <glib.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
@@ -138,6 +139,8 @@ glibtop_init_s (glibtop **server_ptr,
                unsigned long features,
                unsigned flags);
 
+GType     glibtop_get_type (void) G_GNUC_CONST;
+
 G_END_DECLS
 
 #endif
diff --git a/include/glibtop/mountlist.h b/include/glibtop/mountlist.h
index ee074a6..2517494 100644
--- a/include/glibtop/mountlist.h
+++ b/include/glibtop/mountlist.h
@@ -53,6 +53,38 @@ struct _glibtop_mountlist
        guint64 size;                   /* GLIBTOP_MOUNTLIST_SIZE       */
 };
 
+/**
+ * glibtop_get_mountlist:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer full):
+ */
+
+/**
+ * glibtop_get_mountlist_r:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_mountlist_s:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_mountlist_l:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer none):
+ */
+
 glibtop_mountentry *
 glibtop_get_mountlist(glibtop_mountlist *buf, int all_fs);
 
@@ -64,6 +96,8 @@ glibtop_get_mountlist_l (glibtop *server, glibtop_mountlist *buf, int all_fs);
 glibtop_mountentry *
 glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs);
 
+GType     glibtop_mountlist_get_type (void) G_GNUC_CONST;
+GType     glibtop_mountentry_get_type (void) G_GNUC_CONST;
 
 G_END_DECLS
 
diff --git a/include/glibtop/procmap.h b/include/glibtop/procmap.h
index f7d3d4b..4434cb5 100644
--- a/include/glibtop/procmap.h
+++ b/include/glibtop/procmap.h
@@ -92,6 +92,42 @@ glibtop_map_entry *
 glibtop_get_proc_map(glibtop_proc_map *buf, pid_t pid);
 
 
+/**
+ * glibtop_get_proc_map:
+ * @server:
+ * @buf: (out):
+ * @pid:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_proc_map_l:
+ * @server:
+ * @buf: (out):
+ * @pid:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_proc_map_p:
+ * @server:
+ * @buf: (out):
+ * @pid:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_proc_map_s:
+ * @server:
+ * @buf: (out):
+ * @pid:
+ *
+ * Returns: (transfer none):
+ */
+
 #if GLIBTOP_SUID_PROC_MAP
 #define glibtop_get_proc_map_r         glibtop_get_proc_map_p
 #else
@@ -113,6 +149,8 @@ glibtop_map_entry *
 glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid);
 #endif
 
+GType     glibtop_map_entry_get_type (void) G_GNUC_CONST;
+GType     glibtop_proc_map_get_type (void) G_GNUC_CONST;
 
 G_END_DECLS
 
diff --git a/include/glibtop/procopenfiles.h b/include/glibtop/procopenfiles.h
index 9809923..3a40eb9 100644
--- a/include/glibtop/procopenfiles.h
+++ b/include/glibtop/procopenfiles.h
@@ -94,6 +94,42 @@ struct _glibtop_proc_open_files
        guint64 size;                   /* GLIBTOP_PROC_OPEN_FILES_SIZE   */
 };
 
+/**
+ * glibtop_get_proc_open_files:
+ * @server:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_proc_open_files_l:
+ * @server:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_proc_open_files_p:
+ * @server:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer none):
+ */
+
+/**
+ * glibtop_get_proc_open_files_l:
+ * @server:
+ * @buf: (out):
+ * @all_fs:
+ *
+ * Returns: (transfer none):
+ */
+
 glibtop_open_files_entry *
 glibtop_get_proc_open_files(glibtop_proc_open_files *buf, pid_t pid);
 
@@ -118,6 +154,9 @@ glibtop_open_files_entry *
 glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pid_t pid);
 #endif
 
+GType     glibtop_open_files_entry_get_type (void) G_GNUC_CONST;
+GType     glibtop_proc_open_files_get_type (void) G_GNUC_CONST;
+
 G_END_DECLS
 
 #endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index f35ed00..75ab02f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,7 +5,7 @@ lib_LTLIBRARIES                 = libgtop-2.0.la
 
 libgtop_2_0_la_SOURCES         = init.c open.c close.c command.c read.c \
                                  read_data.c write.c lib.c parameter.c \
-                                 sysdeps.c
+                                 sysdeps.c boxed.c
 
 libgtop_2_0_la_LDFLAGS         = $(LT_VERSION_INFO) -export-symbols $(srcdir)/libgtop.sym -no-undefined
 libgtop_2_0_la_LIBADD          = $(GLIB_LIBS) $(top_builddir)/sysdeps/common/libgtop_common-2.0.la 
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps-2.0.la $(sysdeps_suid_lib)
diff --git a/lib/boxed.c b/lib/boxed.c
new file mode 100644
index 0000000..cfeff2b
--- /dev/null
+++ b/lib/boxed.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2011 Red Hat
+   This file is part of LibGTop 1.0.
+
+   Contributed by Jasper St. Pierre <jstpierre mecheye net>, November 2011
+
+   LibGTop is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License,
+   or (at your option) any later version.
+
+   LibGTop 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 General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with LibGTop; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/procmap.h>
+#include <glibtop/procopenfiles.h>
+
+#define DEFINE_BOXED(type)                              \
+    static type *                                       \
+    type##_copy (type *p)                               \
+    {                                                   \
+        type *n = g_new (type, 1);                      \
+        memcpy (n, p, sizeof (type));                   \
+        return n;                                       \
+    }                                                   \
+                                                        \
+    G_DEFINE_BOXED_TYPE (type,                          \
+                         type,                          \
+                         type##_copy,                   \
+                         g_free)
+
+DEFINE_BOXED (glibtop);
+DEFINE_BOXED (glibtop_map_entry);
+DEFINE_BOXED (glibtop_proc_map);
+DEFINE_BOXED (glibtop_open_files_entry);
+DEFINE_BOXED (glibtop_proc_open_files);
+DEFINE_BOXED (glibtop_mountentry);
+DEFINE_BOXED (glibtop_mountlist);
diff --git a/lib/libgtop.sym b/lib/libgtop.sym
index 67db450..d15adcc 100644
--- a/lib/libgtop.sym
+++ b/lib/libgtop.sym
@@ -68,3 +68,10 @@ glibtop_open_l
 glibtop_server_features
 glibtop_set_parameter_l
 glibtop_sys_siglist
+glibtop_mountlist_get_type
+glibtop_mountentry_get_type
+glibtop_open_files_entry_get_type
+glibtop_proc_open_files_get_type
+glibtop_map_entry_get_type
+glibtop_proc_map_get_type
+glibtop_get_type


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]