From 752d5b47d2134cd6e76465943aadcdcb0ea5e777 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 20 Nov 2000 22:37:15 +0000 Subject: [PATCH] Started with the big rewrite for GNOME 2.0: 2000-11-20 Martin Baulig Started with the big rewrite for GNOME 2.0: - split the `glibtop' structure into `glibtop_server' and `glibtop_client' and make `glibtop_client' a GObject. - cleanly separate the library and the backends. This stuff currently does not compile. * glibtop.h (glibtop_server_private, glibtop_server_info): Removed typedefs. (struct _glibtop, struct _glibtop_server_info): Removed. (glibtop_global_server, glibtop_server_features): Removed. (glibtop_server_ref, glibtop_server_unref): Removed. * glibtop.h (glibtop_init_s): First argument is now a `glibtop_server *'. * include/glibtop/*.h: Removed all #defines with the glibtop_global_server. (glibtop_get_*_l): First argument is now a `glibtop_client *'. (glibtop_get_*_s, glibtop_init_*_s): First argument is now a `glibtop_server *'. * lib/glibtop-client.c: New file. * sysdeps/common/xmalloc.c: Moved to lib/. * sysdeps/common/error.c: Moved to lib/. * lib/xmalloc.c: Moved here from sysdeps/common/. * lib/error.c: Moved here from sysdeps/common/. * include/glibtop/backend.h (glibtop_backend_open_func_t, glibtop_backend_close_func_t): First argument is now a `glibtop_server *'. (glibtop_backend_info): Added `glibtop_server *server'. (glibtop_open_backend_l): Returns `glibtop_backend *', first argument is `glibtop_client *' and added `GError **'. * include/glibtop/close.h (glibtop_close_s, glibtop_close_p): First argument is now a `glibtop_server *'. * include/glibtop/error.h (*): First argument is now a `glibtop_server *'. * include/glibtop/errors.h: Switched this to use GError. --- ChangeLog | 48 ++++++ backends/common/backend-common.c | 8 +- backends/common/marshal.pl | 8 +- backends/server/marshal.pl | 8 +- backends/sysdeps/backend-sysdeps.c | 8 +- backends/sysdeps/marshal.pl | 8 +- glibtop.h | 48 +----- include/glibtop/Makefile.am | 5 +- include/glibtop/backend.h | 15 +- include/glibtop/call-vector.pl | 8 +- include/glibtop/close.h | 4 +- include/glibtop/cpu.h | 8 +- include/glibtop/error.h | 42 +---- include/glibtop/errors.h | 71 ++++++--- include/glibtop/fsusage.h | 8 +- include/glibtop/glib-arrays.h | 17 +- include/glibtop/glibtop-client.h | 79 ++++++++++ include/glibtop/glibtop-server.h | 74 +++++++++ include/glibtop/inodedb.h | 10 +- include/glibtop/interfaces.h | 8 +- include/glibtop/loadavg.h | 8 +- include/glibtop/mem.h | 8 +- include/glibtop/mountlist.h | 6 +- include/glibtop/msg_limits.h | 8 +- include/glibtop/netinfo.h | 8 +- include/glibtop/netload.h | 8 +- include/glibtop/open.h | 7 +- include/glibtop/ppp.h | 8 +- include/glibtop/procargs.h | 8 +- include/glibtop/proccwd.h | 8 +- include/glibtop/prockernel.h | 8 +- include/glibtop/proclist.h | 8 +- include/glibtop/procmap.h | 8 +- include/glibtop/procmem.h | 8 +- include/glibtop/procsegment.h | 8 +- include/glibtop/procsignal.h | 8 +- include/glibtop/procstate.h | 8 +- include/glibtop/proctime.h | 8 +- include/glibtop/procuid.h | 8 +- include/glibtop/sem_limits.h | 8 +- include/glibtop/shm_limits.h | 8 +- include/glibtop/swap.h | 8 +- include/glibtop/sysdeps.h | 6 - include/glibtop/sysinfo.h | 4 +- include/glibtop/uptime.h | 8 +- include/glibtop/xmalloc.h | 16 +- lib/Makefile.am | 13 +- {sysdeps/common => lib}/error.c | 18 +-- lib/errors.c | 146 ++++++++++++++---- lib/glib-arrays.c | 27 ++-- lib/glibtop-client.c | 106 +++++++++++++ lib/init.c | 97 +----------- lib/open-backend.c | 110 ++++--------- lib/parameter.c | 6 +- {sysdeps/common => lib}/xmalloc.c | 10 +- po/POTFILES.in | 1 - sysdeps/common/Makefile.am | 3 +- sysdeps/common/fsusage.c | 4 +- sysdeps/common/mountlist.c | 5 +- sysdeps/common/xmalloc_suid.c | 10 +- sysdeps/stub/Makefile.am | 4 +- sysdeps/stub/close.c | 2 +- sysdeps/stub/cpu.c | 6 +- ...btop_server.h => glibtop_server_private.h} | 4 +- sysdeps/stub/interfaces.c | 6 +- sysdeps/stub/loadavg.c | 6 +- sysdeps/stub/mem.c | 6 +- sysdeps/stub/msg_limits.c | 6 +- sysdeps/stub/netload.c | 6 +- sysdeps/stub/open.c | 2 +- sysdeps/stub/ppp.c | 8 +- sysdeps/stub/procargs.c | 7 +- sysdeps/stub/proccwd.c | 6 +- sysdeps/stub/prockernel.c | 6 +- sysdeps/stub/proclist.c | 7 +- sysdeps/stub/procmap.c | 7 +- sysdeps/stub/procmem.c | 6 +- sysdeps/stub/procsegment.c | 6 +- sysdeps/stub/procsignal.c | 6 +- sysdeps/stub/procstate.c | 6 +- sysdeps/stub/proctime.c | 6 +- sysdeps/stub/procuid.c | 6 +- sysdeps/stub/sem_limits.c | 4 +- sysdeps/stub/shm_limits.c | 4 +- sysdeps/stub/swap.c | 6 +- sysdeps/stub/uptime.c | 6 +- 86 files changed, 792 insertions(+), 601 deletions(-) create mode 100644 include/glibtop/glibtop-client.h create mode 100644 include/glibtop/glibtop-server.h rename {sysdeps/common => lib}/error.c (84%) create mode 100644 lib/glibtop-client.c rename {sysdeps/common => lib}/xmalloc.c (86%) rename sysdeps/stub/{glibtop_server.h => glibtop_server_private.h} (95%) diff --git a/ChangeLog b/ChangeLog index 80e225af..c525766e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,51 @@ +2000-11-20 Martin Baulig + + Started with the big rewrite for GNOME 2.0: + + - split the `glibtop' structure into `glibtop_server' and + `glibtop_client' and make `glibtop_client' a GObject. + - cleanly separate the library and the backends. + + This stuff currently does not compile. + + * glibtop.h (glibtop_server_private, glibtop_server_info): + Removed typedefs. + (struct _glibtop, struct _glibtop_server_info): Removed. + (glibtop_global_server, glibtop_server_features): Removed. + (glibtop_server_ref, glibtop_server_unref): Removed. + + * glibtop.h (glibtop_init_s): First argument is now a + `glibtop_server *'. + + * include/glibtop/*.h: Removed all #defines with the + glibtop_global_server. + (glibtop_get_*_l): First argument is now a `glibtop_client *'. + (glibtop_get_*_s, glibtop_init_*_s): First argument is now a + `glibtop_server *'. + + * lib/glibtop-client.c: New file. + + * sysdeps/common/xmalloc.c: Moved to lib/. + * sysdeps/common/error.c: Moved to lib/. + + * lib/xmalloc.c: Moved here from sysdeps/common/. + * lib/error.c: Moved here from sysdeps/common/. + + * include/glibtop/backend.h + (glibtop_backend_open_func_t, glibtop_backend_close_func_t): + First argument is now a `glibtop_server *'. + (glibtop_backend_info): Added `glibtop_server *server'. + (glibtop_open_backend_l): Returns `glibtop_backend *', first + argument is `glibtop_client *' and added `GError **'. + + * include/glibtop/close.h (glibtop_close_s, glibtop_close_p): + First argument is now a `glibtop_server *'. + + * include/glibtop/error.h (*): + First argument is now a `glibtop_server *'. + + * include/glibtop/errors.h: Switched this to use GError. + 2000-11-20 Martin Baulig * glibtop.h (glibtop_server_info): New type. diff --git a/backends/common/backend-common.c b/backends/common/backend-common.c index b4f4ef97..1c616d86 100644 --- a/backends/common/backend-common.c +++ b/backends/common/backend-common.c @@ -32,10 +32,10 @@ #include static int -_open_common (glibtop *, glibtop_backend *, u_int64_t, const char **); +_open_common (glibtop_server *, glibtop_backend *, u_int64_t, const char **); static int -_close_common (glibtop *, glibtop_backend *); +_close_common (glibtop_server *, glibtop_backend *); extern glibtop_call_vector glibtop_backend_common_call_vector; @@ -52,7 +52,7 @@ glibtop_backend_info LibGTopBackendInfo_Common = { #endif static int -_open_common (glibtop *server, glibtop_backend *backend, +_open_common (glibtop_server *server, glibtop_backend *backend, u_int64_t features, const char **backend_args) { backend->_priv = glibtop_calloc_r @@ -62,7 +62,7 @@ _open_common (glibtop *server, glibtop_backend *backend, } static int -_close_common (glibtop *server, glibtop_backend *backend) +_close_common (glibtop_server *server, glibtop_backend *backend) { return -1; } diff --git a/backends/common/marshal.pl b/backends/common/marshal.pl index 50a570d7..5ae17238 100644 --- a/backends/common/marshal.pl +++ b/backends/common/marshal.pl @@ -141,16 +141,16 @@ sub output { $func_decl = 'static '.$retval."\n"; if ($line_fields[3] eq '') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend%s)\n", $feature, $param_decl); } elsif ($line_fields[3] eq 'array') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, glibtop_array *array%s)\n", $feature, $param_decl); } elsif ($line_fields[3] =~ /^array/) { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", $feature, 'glibtop_'.$feature, $param_decl); } else { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, %s *buf%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, %s *buf%s)\n", $feature, 'glibtop_'.$feature, $param_decl); } diff --git a/backends/server/marshal.pl b/backends/server/marshal.pl index 426bb8a8..8eff2e2b 100644 --- a/backends/server/marshal.pl +++ b/backends/server/marshal.pl @@ -261,16 +261,16 @@ sub output { $func_decl = 'static '.$retval."\n"; if ($line_fields[3] eq '') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend%s)\n", $feature, $param_decl); } elsif ($line_fields[3] eq 'array') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, glibtop_array *array%s)\n", $feature, $param_decl); } elsif ($line_fields[3] =~ /^array/) { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", $feature, 'glibtop_'.$feature, $param_decl); } else { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, %s *buf%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, %s *buf%s)\n", $feature, 'glibtop_'.$feature, $param_decl); } diff --git a/backends/sysdeps/backend-sysdeps.c b/backends/sysdeps/backend-sysdeps.c index 69217cbb..271dbf8c 100644 --- a/backends/sysdeps/backend-sysdeps.c +++ b/backends/sysdeps/backend-sysdeps.c @@ -32,10 +32,10 @@ #include static int -_open_sysdeps (glibtop *, glibtop_backend *, u_int64_t, const char **); +_open_sysdeps (glibtop_server *, glibtop_backend *, u_int64_t, const char **); static int -_close_sysdeps (glibtop *, glibtop_backend *); +_close_sysdeps (glibtop_server *, glibtop_backend *); extern glibtop_call_vector glibtop_backend_sysdeps_call_vector; @@ -52,7 +52,7 @@ glibtop_backend_info LibGTopBackendInfo_Sysdeps = { #endif static int -_open_sysdeps (glibtop *server, glibtop_backend *backend, +_open_sysdeps (glibtop_server *server, glibtop_backend *backend, u_int64_t features, const char **backend_args) { glibtop_init_func_t *init_fkt; @@ -77,7 +77,7 @@ _open_sysdeps (glibtop *server, glibtop_backend *backend, } static int -_close_sysdeps (glibtop *server, glibtop_backend *backend) +_close_sysdeps (glibtop_server *server, glibtop_backend *backend) { return -1; } diff --git a/backends/sysdeps/marshal.pl b/backends/sysdeps/marshal.pl index 6fd497ac..fec00daa 100644 --- a/backends/sysdeps/marshal.pl +++ b/backends/sysdeps/marshal.pl @@ -141,16 +141,16 @@ sub output { $func_decl = 'static '.$retval."\n"; if ($line_fields[3] eq '') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend%s)\n", $feature, $param_decl); } elsif ($line_fields[3] eq 'array') { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, glibtop_array *array%s)\n", $feature, $param_decl); } elsif ($line_fields[3] =~ /^array/) { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n", $feature, 'glibtop_'.$feature, $param_decl); } else { - $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, %s *buf%s)\n", + $func_decl .= sprintf ("_glibtop_get_%s_c (glibtop_server *server, glibtop_backend *backend, %s *buf%s)\n", $feature, 'glibtop_'.$feature, $param_decl); } diff --git a/glibtop.h b/glibtop.h index eb6af6f0..5e9bba87 100644 --- a/glibtop.h +++ b/glibtop.h @@ -32,71 +32,33 @@ #include #include - -#include #include +#include + BEGIN_LIBGTOP_DECLS typedef struct _glibtop glibtop; -typedef struct _glibtop_server_private glibtop_server_private; -typedef struct _glibtop_server_info glibtop_server_info; #include #include -#include +#include #ifdef _IN_LIBGTOP #include #endif -struct _glibtop_server_info -{ - int ncpu; /* Number of CPUs, zero if single-processor */ - unsigned long features; /* Server is required for this features */ - glibtop_sysdeps sysdeps; /* Detailed feature list */ - glibtop_sysdeps required; /* Required feature list */ - glibtop_sysdeps wanted; /* We only want this features */ -}; - -struct _glibtop -{ - int refcount; /* Reference count */ - unsigned flags; - unsigned long os_version_code; /* Version code of the operating system */ - const char *name; /* Program name for error messages */ - unsigned long server_port; /* Port on which daemon is listening */ - glibtop_parameter _param; /* Server parameter */ - glibtop_server_private *_priv; /* Private data */ - glibtop_server_info *info; /* Server Info */ - unsigned glibtop_errno; -}; - -extern glibtop *glibtop_global_server; - -extern const unsigned long glibtop_server_features; - -#define glibtop_init() glibtop_init_r(&glibtop_global_server, 0, 0); - -#define glibtop_close() glibtop_close_r(glibtop_global_server); - glibtop * glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags); -glibtop * -glibtop_init_s (glibtop **server_ptr, +void +glibtop_init_s (glibtop_server *server_ptr, unsigned long features, unsigned flags); -void -glibtop_server_ref (glibtop *server); - -void -glibtop_server_unref (glibtop *server); - END_LIBGTOP_DECLS #endif diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am index cd24503f..4d185c00 100644 --- a/include/glibtop/Makefile.am +++ b/include/glibtop/Makefile.am @@ -6,10 +6,11 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \ procmem.h procuid.h swap.h error.h open.h \ procsegment.h sysdeps.h xmalloc.h global.h \ procsignal.h union.h types.h proccwd.h \ - parameter.h mountlist.h fsusage.h procmap.h signal.h \ + mountlist.h fsusage.h procmap.h signal.h \ inodedb.h sysinfo.h ppp.h procargs.h netload.h \ netinfo.h interfaces.h limits.h array.h compat_10.h \ - errors.h glib-arrays.h backend.h call-vector.h + glib-arrays.h backend.h call-vector.h \ + glibtop-client.h glibtop-server.h BUILT_SOURCES = call-vector.h diff --git a/include/glibtop/backend.h b/include/glibtop/backend.h index 513f6fcf..76c720f1 100644 --- a/include/glibtop/backend.h +++ b/include/glibtop/backend.h @@ -29,7 +29,7 @@ #include #include -#include +#include BEGIN_LIBGTOP_DECLS @@ -42,9 +42,9 @@ typedef struct _glibtop_backend glibtop_backend; #include -typedef int (*glibtop_backend_open_func_t) (glibtop *, glibtop_backend *, +typedef int (*glibtop_backend_open_func_t) (glibtop_server *, glibtop_backend *, u_int64_t, const char **); -typedef int (*glibtop_backend_close_func_t) (glibtop *, glibtop_backend *); +typedef int (*glibtop_backend_close_func_t) (glibtop_server *, glibtop_backend *); struct _glibtop_backend_info { @@ -88,6 +88,8 @@ struct _glibtop_backend { const glibtop_backend_info *info; + glibtop_server *server; + /* private pointers */ glibtop_backend_private *_priv; glibtop_backend_module *_priv_module; @@ -108,9 +110,10 @@ glibtop_backend_by_name (const char *backend_name); void glibtop_init_backends (void); -int -glibtop_open_backend_l (glibtop *server, const char *backend_name, - u_int64_t features, const char **backend_args); +glibtop_backend * +glibtop_open_backend_l (glibtop_client *client, const char *backend_name, + u_int64_t features, const char **backend_args, + GError **error); END_LIBGTOP_DECLS diff --git a/include/glibtop/call-vector.pl b/include/glibtop/call-vector.pl index 21208ce5..53b16077 100644 --- a/include/glibtop/call-vector.pl +++ b/include/glibtop/call-vector.pl @@ -82,16 +82,16 @@ sub parse_features_def { if ($line_fields[3] eq '') { $func_decl_code .= sprintf - (qq[\t%s (*%s) (glibtop *, glibtop_backend *%s);\n], $retval, $feature, $param_decl); + (qq[\t%s (*%s) (glibtop_server *, glibtop_backend *%s);\n], $retval, $feature, $param_decl); } elsif ($line_fields[3] eq 'array') { $func_decl_code .= sprintf - (qq[\t%s (*%s) (glibtop *, glibtop_backend *, glibtop_array *%s);\n], $retval, $feature, $param_decl); + (qq[\t%s (*%s) (glibtop_server *, glibtop_backend *, glibtop_array *%s);\n], $retval, $feature, $param_decl); } elsif ($line_fields[3] =~ /^array/) { $func_decl_code .= sprintf - (qq[\t%s (*%s) (glibtop *, glibtop_backend *, glibtop_array *, %s *%s);\n], $retval, $feature, 'glibtop_'.$feature, $param_decl); + (qq[\t%s (*%s) (glibtop_server *, glibtop_backend *, glibtop_array *, %s *%s);\n], $retval, $feature, 'glibtop_'.$feature, $param_decl); } else { $func_decl_code .= sprintf - (qq[\t%s (*%s) (glibtop *, glibtop_backend *, %s *%s);\n], $retval, $feature, 'glibtop_'.$feature, $param_decl); + (qq[\t%s (*%s) (glibtop_server *, glibtop_backend *, %s *%s);\n], $retval, $feature, 'glibtop_'.$feature, $param_decl); } } diff --git a/include/glibtop/close.h b/include/glibtop/close.h index e5819a4f..9a060b1d 100644 --- a/include/glibtop/close.h +++ b/include/glibtop/close.h @@ -32,8 +32,8 @@ BEGIN_LIBGTOP_DECLS void glibtop_close_r (glibtop *server); -void glibtop_close_s (glibtop *server); -void glibtop_close_p (glibtop *server); +void glibtop_close_s (glibtop_server *server); +void glibtop_close_p (glibtop_server *server); END_LIBGTOP_DECLS diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h index 3876e9d2..ae100126 100644 --- a/include/glibtop/cpu.h +++ b/include/glibtop/cpu.h @@ -66,22 +66,20 @@ struct _glibtop_cpu xcpu_flags; /* GLIBTOP_CPU_XCPU_FLAGS */ }; -#define glibtop_get_cpu(cpu) glibtop_get_cpu_l(glibtop_global_server, cpu) - #if GLIBTOP_SUID_CPU #define glibtop_get_cpu_r glibtop_get_cpu_p #else #define glibtop_get_cpu_r glibtop_get_cpu_s #endif -int glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf); +int glibtop_get_cpu_l (glibtop_client *client, glibtop_cpu *buf); #if GLIBTOP_SUID_CPU int glibtop_init_cpu_p (glibtop *server); int glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf); #else -int glibtop_init_cpu_s (glibtop *server); -int glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf); +int glibtop_init_cpu_s (glibtop_server *server); +int glibtop_get_cpu_s (glibtop_server *server, glibtop_cpu *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/error.h b/include/glibtop/error.h index c0de8b6f..0740a824 100644 --- a/include/glibtop/error.h +++ b/include/glibtop/error.h @@ -30,42 +30,16 @@ BEGIN_LIBGTOP_DECLS -#ifndef G_GNUC_UNUSED -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -#define G_GNUC_UNUSED \ - __attribute__((unused)) -#else /* !__GNUC__ */ -#define G_GNUC_UNUSED -#endif /* !__GNUC__ */ -#endif /* defined G_GNUC_UNUSED */ +void glibtop_error_vr (glibtop_server *server, char *format, va_list args); +void glibtop_warn_vr (glibtop_server *server, char *format, va_list args); -void glibtop_error_vr (glibtop *server, char *format, va_list args); -void glibtop_warn_vr (glibtop *server, char *format, va_list args); +void glibtop_error_io_vr (glibtop_server *server, char *format, int, va_list args); +void glibtop_warn_io_vr (glibtop_server *server, char *format, int, va_list args); -void glibtop_error_io_vr (glibtop *server, char *format, int, va_list args); -void glibtop_warn_io_vr (glibtop *server, char *format, int, va_list args); - -void glibtop_error_r (glibtop *server, char *format, ...); -void glibtop_warn_r (glibtop *server, char *format, ...); -void glibtop_error_io_r (glibtop *server, char *format, ...); -void glibtop_warn_io_r (glibtop *server, char *format, ...); - -#ifdef __GNUC__ - -#define glibtop_error(p1, args...) glibtop_error_r(glibtop_global_server , p1 , ## args) -#define glibtop_warn(p1, args...) glibtop_warn_r(glibtop_global_server , p1 , ## args) - -#define glibtop_error_io(p1, args...) glibtop_error_io_r(glibtop_global_server , p1 , ## args) -#define glibtop_warn_io(p1, args...) glibtop_warn_io_r(glibtop_global_server , p1 , ## args) - -#else /* no __GNUC__ */ - -void glibtop_error (char *format, ...); -void glibtop_warn (char *format, ...); -void glibtop_error_io (char *format, ...); -void glibtop_warn_io (char *format, ...); - -#endif /* no __GNUC__ */ +void glibtop_error_r (glibtop_server *server, char *format, ...); +void glibtop_warn_r (glibtop_server *server, char *format, ...); +void glibtop_error_io_r (glibtop_server *server, char *format, ...); +void glibtop_warn_io_r (glibtop_server *server, char *format, ...); END_LIBGTOP_DECLS diff --git a/include/glibtop/errors.h b/include/glibtop/errors.h index 56f5b9a7..9936eead 100644 --- a/include/glibtop/errors.h +++ b/include/glibtop/errors.h @@ -28,38 +28,67 @@ #include +#include + BEGIN_LIBGTOP_DECLS -#define GLIBTOP_ERROR_NO_ERROR 0 -#define GLIBTOP_ERROR_UNKNOWN 1 -#define GLIBTOP_ERROR_INVALID_ARGUMENT 2 -#define GLIBTOP_ERROR_NO_SUCH_PARAMETER 3 -#define GLIBTOP_ERROR_READONLY_VALUE 4 -#define GLIBTOP_ERROR_SIZE_MISMATCH 5 +#define GLIBTOP_ERROR glibtop_error_quark () -#define GLIBTOP_ERROR_SERVER_COMM_FAILURE 6 +GQuark glibtop_error_quark (void) G_GNUC_CONST; -#define GLIBTOP_ERROR_NO_SUCH_PROCESS 7 +typedef enum { + GLIBTOP_ERROR_NO_ERROR = 0, + GLIBTOP_ERROR_UNKNOWN, + GLIBTOP_ERROR_INVALID_ARGUMENT, + GLIBTOP_ERROR_NO_SUCH_PARAMETER, + GLIBTOP_ERROR_READONLY_VALUE, + GLIBTOP_ERROR_SIZE_MISMATCH, -#define GLIBTOP_ERROR_NO_KERNEL_SUPPORT 8 -#define GLIBTOP_ERROR_INCOMPATIBLE_KERNEL 9 + GLIBTOP_ERROR_SERVER_COMM_FAILURE, -#define GLIBTOP_ERROR_NO_SUCH_BACKEND 10 -#define GLIBTOP_ERROR_NOT_IMPLEMENTED 11 -#define GLIBTOP_ERROR_NO_BACKEND_OPENED 12 + GLIBTOP_ERROR_NO_SUCH_PROCESS, -#define GLIBTOP_ERROR_DEMARSHAL_ERROR 13 + GLIBTOP_ERROR_NO_KERNEL_SUPPORT, + GLIBTOP_ERROR_INCOMPATIBLE_KERNEL, -#define GLIBTOP_MAX_ERROR 14 + GLIBTOP_ERROR_NO_SUCH_BACKEND, + GLIBTOP_ERROR_NOT_IMPLEMENTED, + GLIBTOP_ERROR_NO_BACKEND_OPENED, -char * -glibtop_get_error_string_l (glibtop *server, unsigned error_number); + GLIBTOP_ERROR_DEMARSHAL_ERROR +} glibtop_error; -unsigned -glibtop_get_errno_l (glibtop *server); +void +glibtop_error_vl (glibtop_client *client, glibtop_error code, + const char *format, va_list args); -unsigned -glibtop_clear_errno_l (glibtop *server); +void +glibtop_error_io_vl (glibtop_client *client, glibtop_error code, + int io_errno, const char *format, va_list args); + +void +glibtop_warn_vl (glibtop_client *client, glibtop_error code, + const char *format, va_list args); + +void +glibtop_warn_io_vl (glibtop_client *client, glibtop_error code, + int io_errno, const char *format, va_list args); + +void +glibtop_error_l (glibtop_client *client, glibtop_error code, + char *format, ...); + +void +glibtop_warn_l (glibtop_client *client, glibtop_error code, + char *format, ...); + +void +glibtop_error_io_l (glibtop_client *client, glibtop_error code, + char *format, ...); + +void +glibtop_warn_io_l (glibtop_client *client, glibtop_error code, + char *format, ...); END_LIBGTOP_DECLS diff --git a/include/glibtop/fsusage.h b/include/glibtop/fsusage.h index 97f50929..4ffe367c 100644 --- a/include/glibtop/fsusage.h +++ b/include/glibtop/fsusage.h @@ -51,12 +51,8 @@ struct _glibtop_fsusage ffree; /* Free file nodes. */ }; -#define glibtop_get_fsusage(fsusage,disk) glibtop_get_fsusage_l(glibtop_global_server, fsusage, disk) - -#define glibtop_get_fsusage_r glibtop_get_fsusage_s - -int glibtop_get_fsusage_l (glibtop *server, glibtop_fsusage *buf, const char *mount_dir); -int glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, const char *mount_dir); +int glibtop_get_fsusage_l (glibtop_client *client, glibtop_fsusage *buf, const char *mount_dir); +int glibtop_get_fsusage_s (glibtop_server *server, glibtop_fsusage *buf, const char *mount_dir); #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/glib-arrays.h b/include/glibtop/glib-arrays.h index bb4b99bb..d99436be 100644 --- a/include/glibtop/glib-arrays.h +++ b/include/glibtop/glib-arrays.h @@ -29,31 +29,22 @@ #include #include #include -#include #include BEGIN_LIBGTOP_DECLS -#define glibtop_get_proc_args_as_array(pid) glibtop_get_proc_args_as_array_l(glibtop_global_server, pid) - GPtrArray * -glibtop_get_proc_args_as_array_l (glibtop *server, pid_t pid); - -#define glibtop_get_proclist_as_array(which,arg) glibtop_get_proclist_as_array_l(glibtop_global_server, which, arg) +glibtop_get_proc_args_as_array_l (glibtop_client *client, pid_t pid); GArray * -glibtop_get_proclist_as_array_l (glibtop *server, int64_t which, int64_t arg); - -#define glibtop_get_proc_map_as_array(pid) glibtop_get_proc_map_as_array_l(glibtop_global_server, pid) +glibtop_get_proclist_as_array_l (glibtop_client *client, int64_t which, int64_t arg); GPtrArray * -glibtop_get_proc_map_as_array_l (glibtop *server, pid_t pid); - -#define glibtop_get_mountlist_as_array(all_fs) glibtop_get_mountlist_as_array_l(glibtop_global_server, all_fs) +glibtop_get_proc_map_as_array_l (glibtop_client *client, pid_t pid); GPtrArray * -glibtop_get_mountlist_as_array_l (glibtop *server, int all_fs); +glibtop_get_mountlist_as_array_l (glibtop_client *client, int all_fs); END_LIBGTOP_DECLS #endif diff --git a/include/glibtop/glibtop-client.h b/include/glibtop/glibtop-client.h new file mode 100644 index 00000000..6abacc0b --- /dev/null +++ b/include/glibtop/glibtop-client.h @@ -0,0 +1,79 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* $Id$ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 2.0. + + Contributed by Martin Baulig , April 1998. + + 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. +*/ + +#ifndef __GLIBTOP_CLIENT_H__ +#define __GLIBTOP_CLIENT_H__ + +#include +#include + +BEGIN_LIBGTOP_DECLS + +#define GLIBTOP_TYPE_CLIENT (glibtop_client_get_type ()) +#define GLIBTOP_CLIENT(client) (G_TYPE_CHECK_INSTANCE_CAST ((client), GLIBTOP_TYPE_CLIENT, glibtop_client)) +#define GLIBTOP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLIBTOP_TYPE_CLIENT, glibtop_client_class)) +#define GLIBTOP_IS_CLIENT(client) (G_TYPE_CHECK_INSTANCE_TYPE ((client), GLIBTOP_TYPE_CLIENT)) +#define GLIBTOP_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLIBTOP_TYPE_CLIENT)) +#define GLIBTOP_CLIENT_GET_CLASS(client)(G_TYPE_INSTANCE_GET_CLASS ((client), GLIBTOP_TYPE_CLIENT, glibtop_client_class)) + +#define GLIBTOP_CLIENT_TYPE(client) (G_TYPE_FROM_INSTANCE (client)) +#define GLIBTOP_CLIENT_TYPE_NAME(client)(g_type_name (GLIBTOP_CLIENT_TYPE (client))) + +/* --- typedefs & structures --- */ +typedef struct _glibtop_client glibtop_client; +typedef struct _glibtop_client_class glibtop_client_class; +typedef struct _glibtop_client_private glibtop_client_private; + +struct _glibtop_client +{ + GObject object; + + /* */ + GError *error; + + /* */ + glibtop_client_private *_priv; +}; + +struct _glibtop_client_class +{ + GObjectClass parent_class;; +}; + +GType +glibtop_client_get_type (void); + +glibtop_client * +glibtop_client_new (void); + +void +glibtop_client_propagate_error (glibtop_client *client, GError *error); + +void +glibtop_client_propagate_warning (glibtop_client *client, GError *error); + +END_LIBGTOP_DECLS + +#endif diff --git a/include/glibtop/glibtop-server.h b/include/glibtop/glibtop-server.h new file mode 100644 index 00000000..a781ac88 --- /dev/null +++ b/include/glibtop/glibtop-server.h @@ -0,0 +1,74 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* $Id$ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 2.0. + + Contributed by Martin Baulig , April 1998. + + 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. +*/ + +#ifndef __GLIBTOP_SERVER_H__ +#define __GLIBTOP_SERVER_H__ + +#include +#include + +BEGIN_LIBGTOP_DECLS + +typedef struct _glibtop_server glibtop_server; +typedef struct _glibtop_server_info glibtop_server_info; +typedef struct _glibtop_server_private glibtop_server_private; + +typedef int (*glibtop_init_func_t) (glibtop_server *); + +extern glibtop_init_func_t _glibtop_init_hook_s []; +extern glibtop_init_func_t _glibtop_init_hook_p []; + +struct _glibtop_server_info +{ + int ncpu; /* Number of CPUs, zero if single-processor */ + unsigned long features; /* Server is required for this features */ + glibtop_sysdeps sysdeps; /* Detailed feature list */ + glibtop_sysdeps required; /* Required feature list */ + glibtop_sysdeps wanted; /* We only want this features */ +}; + +struct _glibtop_server +{ + glibtop_server_info *info; + + int refcount; + unsigned flags; + const char *name; + + glibtop_server_private *_priv; +}; + +glibtop_server * +glibtop_server_new (void); + +void +glibtop_server_ref (glibtop_server *server); + +void +glibtop_server_unref (glibtop_server *server); + +END_LIBGTOP_DECLS + +#endif diff --git a/include/glibtop/inodedb.h b/include/glibtop/inodedb.h index f284b322..aac9259a 100644 --- a/include/glibtop/inodedb.h +++ b/include/glibtop/inodedb.h @@ -49,20 +49,16 @@ struct _glibtop_inodedb GDBM_FILE system_dbf, user_dbf; }; -#define glibtop_inodedb_open(p1,p2) glibtop_inodedb_open_s(glibtop_global_server, p1, p2) -#define glibtop_inodedb_lookup(p1,p2,p3) glibtop_inodedb_lookup_s(glibtop_global_server, p1, p2, p3) -#define glibtop_inodedb_close(p1) glibtop_inodedb_close_s(glibtop_global_server) - glibtop_inodedb * -glibtop_inodedb_open_s (glibtop *server, unsigned databases, unsigned long cache_size); +glibtop_inodedb_open_s (glibtop_server *server, unsigned databases, unsigned long cache_size); const char * -glibtop_inodedb_lookup_s (glibtop *server, +glibtop_inodedb_lookup_s (glibtop_server *server, glibtop_inodedb *inodedb, u_int64_t device, u_int64_t inode); void -glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb); +glibtop_inodedb_close_s (glibtop_server *server, glibtop_inodedb *inodedb); END_LIBGTOP_DECLS diff --git a/include/glibtop/interfaces.h b/include/glibtop/interfaces.h index 6341de6c..9c80cec9 100644 --- a/include/glibtop/interfaces.h +++ b/include/glibtop/interfaces.h @@ -171,22 +171,20 @@ struct _glibtop_interface char name [GLIBTOP_INTERFACE_LEN]; }; -#define glibtop_get_interface_names(array,interface,number,instance,strategy) glibtop_get_interface_names_l (glibtop_global_server, array, interface, number, instance, strategy) - #if GLIBTOP_SUID_INTERFACE_NAMES #define glibtop_get_interface_names_r glibtop_get_interface_names_p #else #define glibtop_get_interface_names_r glibtop_get_interface_names_s #endif -glibtop_interface *glibtop_get_interface_names_l (glibtop *server, glibtop_array *array, u_int64_t interface, u_int64_t number, u_int64_t instance, u_int64_t strategy); +glibtop_interface *glibtop_get_interface_names_l (glibtop_client *client, glibtop_array *array, u_int64_t interface, u_int64_t number, u_int64_t instance, u_int64_t strategy); #if GLIBTOP_SUID_INTERFACE_NAMES int glibtop_init_interface_names_p (glibtop *server); glibtop_interface *glibtop_get_interface_names_p (glibtop *server, glibtop_array *array, u_int64_t interface, u_int64_t number, u_int64_t instance, u_int64_t strategy); #else -int glibtop_init_interface_names_s (glibtop *server); -glibtop_interface *glibtop_get_interface_names_s (glibtop *server, glibtop_array *array, u_int64_t interface, u_int64_t number, u_int64_t instance, u_int64_t strategy); +int glibtop_init_interface_names_s (glibtop_server *server); +glibtop_interface *glibtop_get_interface_names_s (glibtop_server *server, glibtop_array *array, u_int64_t interface, u_int64_t number, u_int64_t instance, u_int64_t strategy); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h index 8ebfbec8..bb100155 100644 --- a/include/glibtop/loadavg.h +++ b/include/glibtop/loadavg.h @@ -49,22 +49,20 @@ struct _glibtop_loadavg last_pid; /* GLIBTOP_LOADAVG_LAST_PID */ }; -#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg_l(glibtop_global_server, loadavg) - #if GLIBTOP_SUID_LOADAVG #define glibtop_get_loadavg_r glibtop_get_loadavg_p #else #define glibtop_get_loadavg_r glibtop_get_loadavg_s #endif -int glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf); +int glibtop_get_loadavg_l (glibtop_client *client, glibtop_loadavg *buf); #if GLIBTOP_SUID_LOADAVG int glibtop_init_loadavg_p (glibtop *server); int glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf); #else -int glibtop_init_loadavg_s (glibtop *server); -int glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf); +int glibtop_init_loadavg_s (glibtop_server *server); +int glibtop_get_loadavg_s (glibtop_server *server, glibtop_loadavg *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h index 8c28def8..26058caa 100644 --- a/include/glibtop/mem.h +++ b/include/glibtop/mem.h @@ -57,22 +57,20 @@ struct _glibtop_mem locked; /* GLIBTOP_MEM_LOCKED */ }; -#define glibtop_get_mem(mem) glibtop_get_mem_l(glibtop_global_server, mem) - #if GLIBTOP_SUID_MEM #define glibtop_get_mem_r glibtop_get_mem_p #else #define glibtop_get_mem_r glibtop_get_mem_s #endif -int glibtop_get_mem_l (glibtop *server, glibtop_mem *buf); +int glibtop_get_mem_l (glibtop_client *client, glibtop_mem *buf); #if GLIBTOP_SUID_MEM int glibtop_init_mem_p (glibtop *server); int glibtop_get_mem_p (glibtop *server, glibtop_mem *buf); #else -int glibtop_init_mem_s (glibtop *server); -int glibtop_get_mem_s (glibtop *server, glibtop_mem *buf); +int glibtop_init_mem_s (glibtop_server *server); +int glibtop_get_mem_s (glibtop_server *server, glibtop_mem *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/mountlist.h b/include/glibtop/mountlist.h index 897a2424..731afe23 100644 --- a/include/glibtop/mountlist.h +++ b/include/glibtop/mountlist.h @@ -44,15 +44,13 @@ struct _glibtop_mountentry char type [GLIBTOP_MOUNTENTRY_LEN+1]; }; -#define glibtop_get_mountlist(array,all_fs) glibtop_get_mountlist_l(glibtop_global_server, array, all_fs) - #define glibtop_get_mountlist_r glibtop_get_mountlist_s glibtop_mountentry * -glibtop_get_mountlist_l (glibtop *server, glibtop_array *array, int all_fs); +glibtop_get_mountlist_l (glibtop_client *client, glibtop_array *array, int all_fs); glibtop_mountentry * -glibtop_get_mountlist_s (glibtop *server, glibtop_array *array, int all_fs); +glibtop_get_mountlist_s (glibtop_server *server, glibtop_array *array, int all_fs); #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/msg_limits.h b/include/glibtop/msg_limits.h index 2295ce8e..366390ce 100644 --- a/include/glibtop/msg_limits.h +++ b/include/glibtop/msg_limits.h @@ -55,22 +55,20 @@ struct _glibtop_msg_limits msgtql; /* GLIBTOP_MSG_LIMITS_MSGTQL */ }; -#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits_l(glibtop_global_server, msg) - #if GLIBTOP_SUID_MSG_LIMITS #define glibtop_get_msg_limits_r glibtop_get_msg_limits_p #else #define glibtop_get_msg_limits_r glibtop_get_msg_limits_s #endif -int glibtop_get_msg_limits_l (glibtop *server, glibtop_msg_limits *buf); +int glibtop_get_msg_limits_l (glibtop_client *client, glibtop_msg_limits *buf); #if GLIBTOP_SUID_MSG_LIMITS int glibtop_init_msg_limits_p (glibtop *server); int glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf); #else -int glibtop_init_msg_limits_s (glibtop *server); -int glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf); +int glibtop_init_msg_limits_s (glibtop_server *server); +int glibtop_get_msg_limits_s (glibtop_server *server, glibtop_msg_limits *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/netinfo.h b/include/glibtop/netinfo.h index 0c202c74..147afee8 100644 --- a/include/glibtop/netinfo.h +++ b/include/glibtop/netinfo.h @@ -51,22 +51,20 @@ struct _glibtop_netinfo mtu; /* GLIBTOP_NETINFO_MTU */ }; -#define glibtop_get_netinfo(array,netinfo,interface,transport) glibtop_get_netinfo_l(glibtop_global_server, array, netinfo, interface, transport) - #if GLIBTOP_SUID_NETINFO #define glibtop_get_netinfo_r glibtop_get_netinfo_p #else #define glibtop_get_netinfo_r glibtop_get_netinfo_s #endif -glibtop_ifaddr *glibtop_get_netinfo_l (glibtop *server, glibtop_array *array, glibtop_netinfo *buf, const char *interface, u_int64_t transport); +glibtop_ifaddr *glibtop_get_netinfo_l (glibtop_client *client, glibtop_array *array, glibtop_netinfo *buf, const char *interface, u_int64_t transport); #if GLIBTOP_SUID_NETINFO int glibtop_init_netinfo_p (glibtop *server); glibtop_ifaddr *glibtop_get_netinfo_p (glibtop *server, glibtop_array *array, glibtop_netinfo *buf, const char *interface, u_int64_t transport); #else -int glibtop_init_netinfo_s (glibtop *server); -glibtop_ifaddr *glibtop_get_netinfo_s (glibtop *server, glibtop_array *array, glibtop_netinfo *buf, const char *interface, u_int64_t transport); +int glibtop_init_netinfo_s (glibtop_server *server); +glibtop_ifaddr *glibtop_get_netinfo_s (glibtop_server *server, glibtop_array *array, glibtop_netinfo *buf, const char *interface, u_int64_t transport); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/netload.h b/include/glibtop/netload.h index fe1e3238..fd4039f4 100644 --- a/include/glibtop/netload.h +++ b/include/glibtop/netload.h @@ -63,22 +63,20 @@ struct _glibtop_netload collisions; /* GLIBTOP_NETLOAD_COLLISIONS */ }; -#define glibtop_get_netload(netload,interface,transport,protocol) glibtop_get_netload_l(glibtop_global_server, netload, interface, transport, protocol) - #if GLIBTOP_SUID_NETLOAD #define glibtop_get_netload_r glibtop_get_netload_p #else #define glibtop_get_netload_r glibtop_get_netload_s #endif -int glibtop_get_netload_l (glibtop *server, glibtop_netload *buf, const char *interface, unsigned transport, unsigned protocol); +int glibtop_get_netload_l (glibtop_client *client, glibtop_netload *buf, const char *interface, unsigned transport, unsigned protocol); #if GLIBTOP_SUID_NETLOAD int glibtop_init_netload_p (glibtop *server); int glibtop_get_netload_p (glibtop *server, glibtop_netload *buf, const char *interface, unsigned transport, unsigned protocol); #else -int glibtop_init_netload_s (glibtop *server); -int glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, const char *interface, unsigned transport, unsigned protocol); +int glibtop_init_netload_s (glibtop_server *server); +int glibtop_get_netload_s (glibtop_server *server, glibtop_netload *buf, const char *interface, unsigned transport, unsigned protocol); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/open.h b/include/glibtop/open.h index 7f8d5f25..19623c30 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -25,7 +25,6 @@ #define __GLIBTOP_OPEN_H__ #include -#include BEGIN_LIBGTOP_DECLS @@ -53,7 +52,7 @@ BEGIN_LIBGTOP_DECLS #define GLIBTOP_ERROR_METHOD_DEFAULT GLIBTOP_ERROR_METHOD_WARN_ONCE void -glibtop_open_l (glibtop *server, const char *backend_name, +glibtop_open_l (glibtop_client *client, const char *backend_name, const unsigned long features, const unsigned flags); void @@ -61,11 +60,11 @@ glibtop_init_p (glibtop *server, const unsigned long features, const unsigned flags); void -glibtop_open_p (glibtop *server, const char *program_name, +glibtop_open_p (glibtop_server *server, const char *program_name, const unsigned long features, const unsigned flags); void -glibtop_open_s (glibtop *server, const char *program_name, +glibtop_open_s (glibtop_server *server, const char *program_name, const unsigned long features, const unsigned flags); #ifdef _IN_LIBGTOP diff --git a/include/glibtop/ppp.h b/include/glibtop/ppp.h index 2df5bccd..96e58176 100644 --- a/include/glibtop/ppp.h +++ b/include/glibtop/ppp.h @@ -53,22 +53,20 @@ struct _glibtop_ppp bytes_out; /* GLIBTOP_PPP_BYTES_OUT */ }; -#define glibtop_get_ppp(ppp,device,use_isdn) glibtop_get_ppp_l(glibtop_global_server, ppp, device, use_isdn) - #if GLIBTOP_SUID_PPP #define glibtop_get_ppp_r glibtop_get_ppp_p #else #define glibtop_get_ppp_r glibtop_get_ppp_s #endif -int glibtop_get_ppp_l (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); +int glibtop_get_ppp_l (glibtop_client *client, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); #if GLIBTOP_SUID_PPP int glibtop_init_ppp_p (glibtop *server); int glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); #else -int glibtop_init_ppp_s (glibtop *server); -int glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); +int glibtop_init_ppp_s (glibtop_server *server); +int glibtop_get_ppp_s (glibtop_server *server, glibtop_ppp *buf, unsigned short device, unsigned short use_isdn); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/procargs.h b/include/glibtop/procargs.h index f7624cb9..43bcb6c0 100644 --- a/include/glibtop/procargs.h +++ b/include/glibtop/procargs.h @@ -34,8 +34,6 @@ BEGIN_LIBGTOP_DECLS -#define glibtop_get_proc_args(array,pid) glibtop_get_proc_args_l(glibtop_global_server, array, pid) - #if GLIBTOP_SUID_PROC_ARGS #define glibtop_get_proc_args_r glibtop_get_proc_args_p #else @@ -43,7 +41,7 @@ BEGIN_LIBGTOP_DECLS #endif char ** -glibtop_get_proc_args_l (glibtop *server, glibtop_array *array, pid_t pid); +glibtop_get_proc_args_l (glibtop_client *client, glibtop_array *array, pid_t pid); #if GLIBTOP_SUID_PROC_ARGS int glibtop_init_proc_args_p (glibtop *server); @@ -51,10 +49,10 @@ int glibtop_init_proc_args_p (glibtop *server); char ** glibtop_get_proc_args_p (glibtop *server, glibtop_array *array, pid_t pid); #else -int glibtop_init_proc_args_s (glibtop *server); +int glibtop_init_proc_args_s (glibtop_server *server); char ** -glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid); +glibtop_get_proc_args_s (glibtop_server *server, glibtop_array *array, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/proccwd.h b/include/glibtop/proccwd.h index 991b1fab..382da788 100644 --- a/include/glibtop/proccwd.h +++ b/include/glibtop/proccwd.h @@ -51,22 +51,20 @@ struct _glibtop_proc_cwd inode; }; -#define glibtop_get_proc_cwd(p1, p2) glibtop_get_proc_cwd_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_CWD #define glibtop_get_proc_cwd_r glibtop_get_proc_cwd_p #else #define glibtop_get_proc_cwd_r glibtop_get_proc_cwd_s #endif -char *glibtop_get_proc_cwd_l (glibtop *server, glibtop_proc_cwd *buf, pid_t pid); +char *glibtop_get_proc_cwd_l (glibtop_client *client, glibtop_proc_cwd *buf, pid_t pid); #if GLIBTOP_SUID_PROC_CWD int glibtop_init_proc_cwd_p (glibtop *server); char *glibtop_get_proc_cwd_p (glibtop *server, glibtop_proc_cwd *buf, pid_t pid); #else -int glibtop_init_proc_cwd_s (glibtop *server); -char *glibtop_get_proc_cwd_s (glibtop *server, glibtop_proc_cwd *buf, pid_t pid); +int glibtop_init_proc_cwd_s (glibtop_server *server); +char *glibtop_get_proc_cwd_s (glibtop_server *server, glibtop_proc_cwd *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/prockernel.h b/include/glibtop/prockernel.h index a195ea55..ae7d35e5 100644 --- a/include/glibtop/prockernel.h +++ b/include/glibtop/prockernel.h @@ -77,22 +77,20 @@ struct _glibtop_proc_kernel char wchan [40]; }; -#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_KERNEL #define glibtop_get_proc_kernel_r glibtop_get_proc_kernel_p #else #define glibtop_get_proc_kernel_r glibtop_get_proc_kernel_s #endif -int glibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf, pid_t pid); +int glibtop_get_proc_kernel_l (glibtop_client *client, glibtop_proc_kernel *buf, pid_t pid); #if GLIBTOP_SUID_PROC_KERNEL int glibtop_init_proc_kernel_p (glibtop *server); int glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, pid_t pid); #else -int glibtop_init_proc_kernel_s (glibtop *server); -int glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid); +int glibtop_init_proc_kernel_s (glibtop_server *server); +int glibtop_get_proc_kernel_s (glibtop_server *server, glibtop_proc_kernel *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h index a0fe9172..134117e5 100644 --- a/include/glibtop/proclist.h +++ b/include/glibtop/proclist.h @@ -52,8 +52,6 @@ BEGIN_LIBGTOP_DECLS #define GLIBTOP_EXCLUDE_SYSTEM 0x2000 #define GLIBTOP_EXCLUDE_NOTTY 0x4000 -#define glibtop_get_proclist(array,which,arg) glibtop_get_proclist_l(glibtop_global_server, array, which, arg) - #if GLIBTOP_SUID_PROCLIST #define glibtop_get_proclist_r glibtop_get_proclist_p #else @@ -61,7 +59,7 @@ BEGIN_LIBGTOP_DECLS #endif unsigned * -glibtop_get_proclist_l (glibtop *server, glibtop_array *array, +glibtop_get_proclist_l (glibtop_client *client, glibtop_array *array, int64_t which, int64_t arg); #if GLIBTOP_SUID_PROCLIST @@ -71,10 +69,10 @@ unsigned * glibtop_get_proclist_p (glibtop *server, glibtop_array *array, int64_t which, int64_t arg); #else -int glibtop_init_proclist_s (glibtop *server); +int glibtop_init_proclist_s (glibtop_server *server); unsigned * -glibtop_get_proclist_s (glibtop *server, glibtop_array *array, +glibtop_get_proclist_s (glibtop_server *server, glibtop_array *array, int64_t which, int64_t arg); #endif diff --git a/include/glibtop/procmap.h b/include/glibtop/procmap.h index fbcda9d4..698a6656 100644 --- a/include/glibtop/procmap.h +++ b/include/glibtop/procmap.h @@ -60,8 +60,6 @@ struct _glibtop_map_entry char filename [GLIBTOP_MAP_FILENAME_LEN+1]; }; -#define glibtop_get_proc_map(array,pid) glibtop_get_proc_map_l(glibtop_global_server, array, pid) - #if GLIBTOP_SUID_PROC_MAP #define glibtop_get_proc_map_r glibtop_get_proc_map_p #else @@ -69,7 +67,7 @@ struct _glibtop_map_entry #endif glibtop_map_entry * -glibtop_get_proc_map_l (glibtop *server, glibtop_array *array, pid_t pid); +glibtop_get_proc_map_l (glibtop_client *client, glibtop_array *array, pid_t pid); #if GLIBTOP_SUID_PROC_MAP int glibtop_init_proc_map_p (glibtop *server); @@ -77,10 +75,10 @@ int glibtop_init_proc_map_p (glibtop *server); glibtop_map_entry * glibtop_get_proc_map_p (glibtop *server, glibtop_array *array, pid_t pid); #else -int glibtop_init_proc_map_s (glibtop *server); +int glibtop_init_proc_map_s (glibtop_server *server); glibtop_map_entry * -glibtop_get_proc_map_s (glibtop *server, glibtop_array *array, pid_t pid); +glibtop_get_proc_map_s (glibtop_server *server, glibtop_array *array, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/procmem.h b/include/glibtop/procmem.h index dd232f66..714357e3 100644 --- a/include/glibtop/procmem.h +++ b/include/glibtop/procmem.h @@ -57,22 +57,20 @@ struct _glibtop_proc_mem * of the process; usually 2,147,483,647 */ }; -#define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_MEM #define glibtop_get_proc_mem_r glibtop_get_proc_mem_p #else #define glibtop_get_proc_mem_r glibtop_get_proc_mem_s #endif -int glibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf, pid_t pid); +int glibtop_get_proc_mem_l (glibtop_client *client, glibtop_proc_mem *buf, pid_t pid); #if GLIBTOP_SUID_PROC_MEM int glibtop_init_proc_mem_p (glibtop *server); int glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, pid_t pid); #else -int glibtop_init_proc_mem_s (glibtop *server); -int glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid); +int glibtop_init_proc_mem_s (glibtop_server *server); +int glibtop_get_proc_mem_s (glibtop_server *server, glibtop_proc_mem *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h index 898ae11d..815689f0 100644 --- a/include/glibtop/procsegment.h +++ b/include/glibtop/procsegment.h @@ -77,22 +77,20 @@ struct _glibtop_proc_segment env_end; }; -#define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_SEGMENT #define glibtop_get_proc_segment_r glibtop_get_proc_segment_p #else #define glibtop_get_proc_segment_r glibtop_get_proc_segment_s #endif -int glibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf, pid_t pid); +int glibtop_get_proc_segment_l (glibtop_client *client, glibtop_proc_segment *buf, pid_t pid); #if GLIBTOP_SUID_PROC_SEGMENT int glibtop_init_proc_segment_p (glibtop *server); int glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, pid_t pid); #else -int glibtop_init_proc_segment_s (glibtop *server); -int glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, pid_t pid); +int glibtop_init_proc_segment_s (glibtop_server *server); +int glibtop_get_proc_segment_s (glibtop_server *server, glibtop_proc_segment *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/procsignal.h b/include/glibtop/procsignal.h index 1fe5859d..b4a83e09 100644 --- a/include/glibtop/procsignal.h +++ b/include/glibtop/procsignal.h @@ -51,22 +51,20 @@ struct _glibtop_proc_signal sigcatch [2]; /* mask of caught signals */ }; -#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_SIGNAL #define glibtop_get_proc_signal_r glibtop_get_proc_signal_p #else #define glibtop_get_proc_signal_r glibtop_get_proc_signal_s #endif -int glibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf, pid_t pid); +int glibtop_get_proc_signal_l (glibtop_client *client, glibtop_proc_signal *buf, pid_t pid); #if GLIBTOP_SUID_PROC_SIGNAL int glibtop_init_proc_signal_p (glibtop *server); int glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, pid_t pid); #else -int glibtop_init_proc_signal_s (glibtop *server); -int glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid); +int glibtop_init_proc_signal_s (glibtop_server *server); +int glibtop_get_proc_signal_s (glibtop_server *server, glibtop_proc_signal *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h index c5eb1ac9..c4b8485f 100644 --- a/include/glibtop/procstate.h +++ b/include/glibtop/procstate.h @@ -77,22 +77,20 @@ struct _glibtop_proc_state }; -#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_STATE #define glibtop_get_proc_state_r glibtop_get_proc_state_p #else #define glibtop_get_proc_state_r glibtop_get_proc_state_s #endif -int glibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf, pid_t pid); +int glibtop_get_proc_state_l (glibtop_client *client, glibtop_proc_state *buf, pid_t pid); #if GLIBTOP_SUID_PROC_STATE int glibtop_init_proc_state_p (glibtop *server); int glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, pid_t pid); #else -int glibtop_init_proc_state_s (glibtop *server); -int glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid); +int glibtop_init_proc_state_s (glibtop_server *server); +int glibtop_get_proc_state_s (glibtop_server *server, glibtop_proc_state *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/proctime.h b/include/glibtop/proctime.h index fe0ee0cc..f4b77298 100644 --- a/include/glibtop/proctime.h +++ b/include/glibtop/proctime.h @@ -74,22 +74,20 @@ struct _glibtop_proc_time xcpu_flags; }; -#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_TIME #define glibtop_get_proc_time_r glibtop_get_proc_time_p #else #define glibtop_get_proc_time_r glibtop_get_proc_time_s #endif -int glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf, pid_t pid); +int glibtop_get_proc_time_l (glibtop_client *client, glibtop_proc_time *buf, pid_t pid); #if GLIBTOP_SUID_PROC_TIME int glibtop_init_proc_time_p (glibtop *server); int glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, pid_t pid); #else -int glibtop_init_proc_time_s (glibtop *server); -int glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid); +int glibtop_init_proc_time_s (glibtop_server *server); +int glibtop_get_proc_time_s (glibtop_server *server, glibtop_proc_time *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h index 1ec955a5..157f4908 100644 --- a/include/glibtop/procuid.h +++ b/include/glibtop/procuid.h @@ -79,22 +79,20 @@ struct _glibtop_proc_uid groups [GLIBTOP_MAX_GROUPS]; /* additional prcess groups */ }; -#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid_l(glibtop_global_server, p1, p2) - #if GLIBTOP_SUID_PROC_UID #define glibtop_get_proc_uid_r glibtop_get_proc_uid_p #else #define glibtop_get_proc_uid_r glibtop_get_proc_uid_s #endif -int glibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf, pid_t pid); +int glibtop_get_proc_uid_l (glibtop_client *client, glibtop_proc_uid *buf, pid_t pid); #if GLIBTOP_SUID_PROC_UID int glibtop_init_proc_uid_p (glibtop *server); int glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, pid_t pid); #else -int glibtop_init_proc_uid_s (glibtop *server); -int glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid); +int glibtop_init_proc_uid_s (glibtop_server *server); +int glibtop_get_proc_uid_s (glibtop_server *server, glibtop_proc_uid *buf, pid_t pid); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/sem_limits.h b/include/glibtop/sem_limits.h index 60c3338f..8e0a30f5 100644 --- a/include/glibtop/sem_limits.h +++ b/include/glibtop/sem_limits.h @@ -61,22 +61,20 @@ struct _glibtop_sem_limits semaem; /* GLIBTOP_SEM_LIMITS_SEMAEM */ }; -#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits_l(glibtop_global_server, sem) - #if GLIBTOP_SUID_SEM_LIMITS #define glibtop_get_sem_limits_r glibtop_get_sem_limits_p #else #define glibtop_get_sem_limits_r glibtop_get_sem_limits_s #endif -int glibtop_get_sem_limits_l (glibtop *server, glibtop_sem_limits *buf); +int glibtop_get_sem_limits_l (glibtop_client *client, glibtop_sem_limits *buf); #if GLIBTOP_SUID_SEM_LIMITS int glibtop_init_sem_limits_p (glibtop *server); int glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf); #else -int glibtop_init_sem_limits_s (glibtop *server); -int glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf); +int glibtop_init_sem_limits_s (glibtop_server *server); +int glibtop_get_sem_limits_s (glibtop_server *server, glibtop_sem_limits *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/shm_limits.h b/include/glibtop/shm_limits.h index 93f6e79b..924b3b6c 100644 --- a/include/glibtop/shm_limits.h +++ b/include/glibtop/shm_limits.h @@ -51,22 +51,20 @@ struct _glibtop_shm_limits shmall; /* GLIBTOP_SHM_LIMITS_SHMALL */ }; -#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits_l(glibtop_global_server, shm) - #if GLIBTOP_SUID_SHM_LIMITS #define glibtop_get_shm_limits_r glibtop_get_shm_limits_p #else #define glibtop_get_shm_limits_r glibtop_get_shm_limits_s #endif -int glibtop_get_shm_limits_l (glibtop *server, glibtop_shm_limits *buf); +int glibtop_get_shm_limits_l (glibtop_client *client, glibtop_shm_limits *buf); #if GLIBTOP_SUID_SHM_LIMITS int glibtop_init_shm_limits_p (glibtop *server); int glibtop_get_shm_limits_p (glibtop *, glibtop_shm_limits *buf); #else -int glibtop_init_shm_limits_s (glibtop *server); -int glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf); +int glibtop_init_shm_limits_s (glibtop_server *server); +int glibtop_get_shm_limits_s (glibtop_server *server, glibtop_shm_limits *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/swap.h b/include/glibtop/swap.h index 43b9c5a6..683854ce 100644 --- a/include/glibtop/swap.h +++ b/include/glibtop/swap.h @@ -51,22 +51,20 @@ struct _glibtop_swap pageout; /* GLIBTOP_SWAP_PAGEOUT */ }; -#define glibtop_get_swap(swap) glibtop_get_swap_l(glibtop_global_server, swap) - #if GLIBTOP_SUID_SWAP #define glibtop_get_swap_r glibtop_get_swap_p #else #define glibtop_get_swap_r glibtop_get_swap_s #endif -int glibtop_get_swap_l (glibtop *server, glibtop_swap *buf); +int glibtop_get_swap_l (glibtop_client *client, glibtop_swap *buf); #if GLIBTOP_SUID_SWAP int glibtop_init_swap_p (glibtop *server); int glibtop_get_swap_p (glibtop *server, glibtop_swap *buf); #else -int glibtop_init_swap_s (glibtop *server); -int glibtop_get_swap_s (glibtop *server, glibtop_swap *buf); +int glibtop_init_swap_s (glibtop_server *server); +int glibtop_get_swap_s (glibtop_server *server, glibtop_swap *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index efe90c7a..120c37ab 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -60,10 +60,6 @@ BEGIN_LIBGTOP_DECLS #define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1) -typedef int (*glibtop_init_func_t) (glibtop *); -extern glibtop_init_func_t _glibtop_init_hook_s []; -extern glibtop_init_func_t _glibtop_init_hook_p []; - typedef struct _glibtop_sysdeps glibtop_sysdeps; struct _glibtop_sysdeps @@ -98,8 +94,6 @@ struct _glibtop_sysdeps ppp; /* glibtop_ppp */ }; -#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps_r(glibtop_global_server,sysdeps) - void glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf); #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/sysinfo.h b/include/glibtop/sysinfo.h index 59a988b8..230d4276 100644 --- a/include/glibtop/sysinfo.h +++ b/include/glibtop/sysinfo.h @@ -55,11 +55,9 @@ struct _glibtop_sysinfo glibtop_entry cpuinfo [GLIBTOP_NCPU]; }; -#define glibtop_get_sysinfo() glibtop_get_sysinfo_s(glibtop_global_server) - #define glibtop_get_sysinfo_r glibtop_get_sysinfo_s -glibtop_sysinfo *glibtop_get_sysinfo_s (glibtop *server); +glibtop_sysinfo *glibtop_get_sysinfo_s (glibtop_server *server); END_LIBGTOP_DECLS diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h index 529e9177..5d29da48 100644 --- a/include/glibtop/uptime.h +++ b/include/glibtop/uptime.h @@ -47,22 +47,20 @@ struct _glibtop_uptime u_int64_t boot_time; /* GLIBTOP_UPTIME_BOOT_TIME */ }; -#define glibtop_get_uptime(uptime) glibtop_get_uptime_l(glibtop_global_server, uptime) - #if GLIBTOP_SUID_UPTIME #define glibtop_get_uptime_r glibtop_get_uptime_p #else #define glibtop_get_uptime_r glibtop_get_uptime_s #endif -int glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf); +int glibtop_get_uptime_l (glibtop_client *client, glibtop_uptime *buf); #if GLIBTOP_SUID_UPTIME int glibtop_init_uptime_p (glibtop *server); int glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf); #else -int glibtop_init_uptime_s (glibtop *server); -int glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf); +int glibtop_init_uptime_s (glibtop_server *server); +int glibtop_get_uptime_s (glibtop_server *server, glibtop_uptime *buf); #endif #ifdef GLIBTOP_NAMES diff --git a/include/glibtop/xmalloc.h b/include/glibtop/xmalloc.h index d7b6ce57..657fd865 100644 --- a/include/glibtop/xmalloc.h +++ b/include/glibtop/xmalloc.h @@ -31,17 +31,11 @@ BEGIN_LIBGTOP_DECLS -#define glibtop_malloc(p1) glibtop_malloc_r(glibtop_global_server, p1) -#define glibtop_calloc(p1, p2) glibtop_calloc_r(glibtop_global_server, p1, p2) -#define glibtop_realloc(p1, p2) glibtop_realloc_r(glibtop_global_server, p1, p2) -#define glibtop_strdup(p1) glibtop_strdup_r(glibtop_global_server, p1) -#define glibtop_free(p1) glibtop_free_r(glibtop_global_server, p1) - -void *glibtop_malloc_r (glibtop *server, size_t size); -void *glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size); -void *glibtop_realloc_r (glibtop *server, void *ptr, size_t size); -char *glibtop_strdup_r (glibtop *server, const char *string); -void glibtop_free_r (glibtop *server, const void *ptr); +void *glibtop_malloc_r (glibtop_server *server, size_t size); +void *glibtop_calloc_r (glibtop_server *server, size_t nmemb, size_t size); +void *glibtop_realloc_r (glibtop_server *server, void *ptr, size_t size); +char *glibtop_strdup_r (glibtop_server *server, const char *string); +void glibtop_free_r (glibtop_server *server, const void *ptr); END_LIBGTOP_DECLS diff --git a/lib/Makefile.am b/lib/Makefile.am index e09b2cf3..9f7a2318 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,12 +2,15 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ INCLUDES = @INCLUDES@ -lib_LTLIBRARIES = libgtop.la +lib_LTLIBRARIES = libgtop.la libgtop_server.la -libgtop_la_SOURCES = init.c open.c close.c lib.c parameter.c \ - sysdeps.c errors.c glib-arrays.c \ - backend.c init-backends.c open-backend.c \ - sysdeps-init.c +libgtop_la_SOURCES = errors.c glib-arrays.c backend.c \ + init-backends.c open-backend.c \ + glibtop-client.c + +libgtop_server_la_SOURCES = error.c xmalloc.c + +libgtop_server_la_LDFLAGS = $(LT_VERSION_INFO) libgtop_la_LDFLAGS = $(LT_VERSION_INFO) libgtop_la_LIBADD = $(LIBGTOP_XML_LIB) diff --git a/sysdeps/common/error.c b/lib/error.c similarity index 84% rename from sysdeps/common/error.c rename to lib/error.c index ae80c705..9b2abe7e 100644 --- a/sysdeps/common/error.c +++ b/lib/error.c @@ -30,7 +30,7 @@ /* Prints error message and exits. */ static void -print_server_name (glibtop *server) +print_server_name (glibtop_server *server) { fprintf (stderr, "%s: ", server ? (server->name ? server->name : DEFAULT_NAME) @@ -38,7 +38,7 @@ print_server_name (glibtop *server) } void -glibtop_error_vr (glibtop *server, char *format, va_list args) +glibtop_error_vr (glibtop_server *server, char *format, va_list args) { print_server_name (server); vfprintf (stderr, format, args); @@ -52,7 +52,7 @@ glibtop_error_vr (glibtop *server, char *format, va_list args) } void -glibtop_error_io_vr (glibtop *server, char *format, int error, va_list args) +glibtop_error_io_vr (glibtop_server *server, char *format, int error, va_list args) { print_server_name (server); vfprintf (stderr, format, args); @@ -66,7 +66,7 @@ glibtop_error_io_vr (glibtop *server, char *format, int error, va_list args) } void -glibtop_warn_vr (glibtop *server, char *format, va_list args) +glibtop_warn_vr (glibtop_server *server, char *format, va_list args) { print_server_name (server); vfprintf (stderr, format, args); @@ -78,7 +78,7 @@ glibtop_warn_vr (glibtop *server, char *format, va_list args) } void -glibtop_warn_io_vr (glibtop *server, char *format, int error, va_list args) +glibtop_warn_io_vr (glibtop_server *server, char *format, int error, va_list args) { print_server_name (server); vfprintf (stderr, format, args); @@ -90,7 +90,7 @@ glibtop_warn_io_vr (glibtop *server, char *format, int error, va_list args) } void -glibtop_error_r (glibtop *server, char *format, ...) +glibtop_error_r (glibtop_server *server, char *format, ...) { va_list args; @@ -100,7 +100,7 @@ glibtop_error_r (glibtop *server, char *format, ...) } void -glibtop_warn_r (glibtop *server, char *format, ...) +glibtop_warn_r (glibtop_server *server, char *format, ...) { va_list args; @@ -110,7 +110,7 @@ glibtop_warn_r (glibtop *server, char *format, ...) } void -glibtop_error_io_r (glibtop *server, char *format, ...) +glibtop_error_io_r (glibtop_server *server, char *format, ...) { va_list args; @@ -120,7 +120,7 @@ glibtop_error_io_r (glibtop *server, char *format, ...) } void -glibtop_warn_io_r (glibtop *server, char *format, ...) +glibtop_warn_io_r (glibtop_server *server, char *format, ...) { va_list args; diff --git a/lib/errors.c b/lib/errors.c index 56205153..f4c892a7 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -25,42 +25,132 @@ #include #include -#include +#include -const char *glibtop_error_strings[GLIBTOP_MAX_ERROR] = { - N_("No error"), - N_("Unknown error"), - N_("Invalid argument"), - N_("No such parameter"), - N_("Attempted to modify a read-only value"), - N_("Parameter size mismatch"), - N_("Communication with LibGTop server failed"), - N_("No such process"), - N_("No kernel support"), - N_("Incompatible kernel version") -}; - -char * -glibtop_get_error_string_l (glibtop *server, unsigned error_number) +/* Error quark */ +GQuark +glibtop_error_quark (void) { - if (error_number >= GLIBTOP_MAX_ERROR) - error_number = GLIBTOP_ERROR_UNKNOWN; + static GQuark q = 0; + if (q == 0) + q = g_quark_from_static_string ("glibtop-error-quark"); - return glibtop_strdup_r (server, _(glibtop_error_strings [error_number])); + return q; } -unsigned -glibtop_get_errno_l (glibtop *server) +void +glibtop_error_vl (glibtop_client *client, glibtop_error code, + const char *format, va_list args) { - return server->glibtop_errno; + gchar *message; + GError *error; + + g_return_if_fail (GLIBTOP_IS_CLIENT (client)); + message = g_strdup_vprintf (format, args); + + error = g_error_new_literal (GLIBTOP_ERROR, code, message); + glibtop_client_propagate_error (client, error); + + g_error_free (error); + g_free (message); } -unsigned -glibtop_clear_errno_l (glibtop *server) +void +glibtop_error_io_vl (glibtop_client *client, glibtop_error code, + int io_errno, const char *format, va_list args) { - unsigned old_errno; + gchar *message, *fullmessage; + GError *error; - old_errno = server->glibtop_errno; - server->glibtop_errno = 0; - return old_errno; + g_return_if_fail (GLIBTOP_IS_CLIENT (client)); + message = g_strdup_vprintf (format, args); + fullmessage = g_strdup_printf ("%s: %s", message, strerror (io_errno)); + + error = g_error_new_literal (GLIBTOP_ERROR, code, message); + glibtop_client_propagate_error (client, error); + + g_error_free (error); + g_free (fullmessage); + g_free (message); } + +void +glibtop_warn_vl (glibtop_client *client, glibtop_error code, + const char *format, va_list args) +{ + gchar *message; + GError *error; + + g_return_if_fail (GLIBTOP_IS_CLIENT (client)); + message = g_strdup_vprintf (format, args); + + error = g_error_new_literal (GLIBTOP_ERROR, code, message); + glibtop_client_propagate_warning (client, error); + + g_error_free (error); + g_free (message); +} + +void +glibtop_warn_io_vl (glibtop_client *client, glibtop_error code, + int io_errno, const char *format, va_list args) +{ + gchar *message, *fullmessage; + GError *error; + + g_return_if_fail (GLIBTOP_IS_CLIENT (client)); + message = g_strdup_vprintf (format, args); + fullmessage = g_strdup_printf ("%s: %s", message, strerror (io_errno)); + + error = g_error_new_literal (GLIBTOP_ERROR, code, message); + glibtop_client_propagate_warning (client, error); + + g_error_free (error); + g_free (fullmessage); + g_free (message); +} + +void +glibtop_error_l (glibtop_client *client, glibtop_error code, + char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_error_vl (client, code, format, args); + va_end (args); +} + +void +glibtop_warn_l (glibtop_client *client, glibtop_error code, + char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_warn_vl (client, code, format, args); + va_end (args); +} + +void +glibtop_error_io_l (glibtop_client *client, glibtop_error code, + char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_error_io_vl (client, code, errno, format, args); + va_end (args); +} + +void +glibtop_warn_io_l (glibtop_client *client, glibtop_error code, + char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_warn_io_vl (client, code, errno, format, args); + va_end (args); +} + diff --git a/lib/glib-arrays.c b/lib/glib-arrays.c index d0310eb6..13c80422 100644 --- a/lib/glib-arrays.c +++ b/lib/glib-arrays.c @@ -29,14 +29,15 @@ #include GArray * -glibtop_get_proclist_as_array_l (glibtop *server, int64_t which, int64_t arg) +glibtop_get_proclist_as_array_l (glibtop_client *client, int64_t which, + int64_t arg) { glibtop_array array; GArray *retval; unsigned *ptr; int i; - ptr = glibtop_get_proclist_l (server, &array, which, arg); + ptr = glibtop_get_proclist_l (client, &array, which, arg); if (!ptr) return NULL; retval = g_array_new (FALSE, TRUE, sizeof (guint)); @@ -45,20 +46,20 @@ glibtop_get_proclist_as_array_l (glibtop *server, int64_t which, int64_t arg) for (i = 0; i < array.number; i++) g_array_index (retval, guint, i) = ptr [i]; - glibtop_free_r (server, ptr); + g_free (ptr); return retval; } GPtrArray * -glibtop_get_proc_args_as_array_l (glibtop *server, pid_t pid) +glibtop_get_proc_args_as_array_l (glibtop_client *client, pid_t pid) { glibtop_array array; GPtrArray *retval; char **ptr; int i; - ptr = glibtop_get_proc_args_l (server, &array, pid); + ptr = glibtop_get_proc_args_l (client, &array, pid); if (!ptr) return NULL; retval = g_ptr_array_new (); @@ -66,23 +67,23 @@ glibtop_get_proc_args_as_array_l (glibtop *server, pid_t pid) for (i = 0; i < array.number; i++) { retval->pdata [i] = g_strdup (ptr [i]); - glibtop_free_r (server, ptr [i]); + g_free (ptr [i]); } - glibtop_free_r (server, ptr); + g_free (ptr); return retval; } GPtrArray * -glibtop_get_proc_map_as_array_l (glibtop *server, pid_t pid) +glibtop_get_proc_map_as_array_l (glibtop_client *client, pid_t pid) { glibtop_array array; GPtrArray *retval; glibtop_map_entry *ptr; int i; - ptr = glibtop_get_proc_map_l (server, &array, pid); + ptr = glibtop_get_proc_map_l (client, &array, pid); if (!ptr) return NULL; retval = g_ptr_array_new (); @@ -91,20 +92,20 @@ glibtop_get_proc_map_as_array_l (glibtop *server, pid_t pid) for (i = 0; i < array.number; i++) retval->pdata [i] = g_memdup (ptr+i, sizeof (glibtop_map_entry)); - glibtop_free_r (server, ptr); + g_free (ptr); return retval; } GPtrArray * -glibtop_get_mountlist_as_array_l (glibtop *server, int all_fs) +glibtop_get_mountlist_as_array_l (glibtop_client *client, int all_fs) { glibtop_array array; GPtrArray *retval; glibtop_mountentry *ptr; int i; - ptr = glibtop_get_mountlist_l (server, &array, all_fs); + ptr = glibtop_get_mountlist_l (client, &array, all_fs); if (!ptr) return NULL; retval = g_ptr_array_new (); @@ -113,7 +114,7 @@ glibtop_get_mountlist_as_array_l (glibtop *server, int all_fs) for (i = 0; i < array.number; i++) retval->pdata [i] = g_memdup (ptr+i, sizeof (glibtop_mountentry)); - glibtop_free_r (server, ptr); + g_free (ptr); return retval; } diff --git a/lib/glibtop-client.c b/lib/glibtop-client.c new file mode 100644 index 00000000..f4f98024 --- /dev/null +++ b/lib/glibtop-client.c @@ -0,0 +1,106 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* $Id$ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 2.0. + + Contributed by Martin Baulig , April 1998. + + 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 + +static void glibtop_client_class_init (glibtop_client_class *klass); +static void glibtop_client_init (glibtop_client *client); +static void glibtop_client_finalize (GObject *object); + +static gpointer parent_class = NULL; + + +/* Internal data */ + +struct _glibtop_client_private +{ +}; + +GType +glibtop_client_get_type (void) +{ + static GType glibtop_client_type = 0; + + if (!glibtop_client_type) { + static const GTypeInfo glibtop_client_info = { + sizeof (glibtop_client_class), + NULL, /* base_class_init */ + NULL, /* base_class_finalize */ + (GClassInitFunc) glibtop_client_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (glibtop_client), + 16, /* n_preallocs */ + (GInstanceInitFunc) glibtop_client_init, + }; + + glibtop_client_type = g_type_register_static + (G_TYPE_OBJECT, "glibtop_client", &glibtop_client_info, 0); + } + + return glibtop_client_type; +} + +static void +glibtop_client_class_init (glibtop_client_class *class) +{ + GObjectClass *gobject_class; + + gobject_class = (GObjectClass *) class; + + parent_class = g_type_class_ref (G_TYPE_OBJECT); + + gobject_class->finalize = glibtop_client_finalize; +} + +static void +glibtop_client_init (glibtop_client *glibtop) +{ + glibtop_client_private *priv; + + priv = g_new0 (glibtop_client_private, 1); + glibtop->_priv = priv; +} + +static void +glibtop_client_finalize (GObject *object) +{ + glibtop_client *glibtop; + glibtop_client_private *priv = NULL; + + glibtop = GLIBTOP_CLIENT (object); + priv = glibtop->_priv; + + g_free (priv); + + if (G_OBJECT_CLASS (parent_class)->finalize) + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +glibtop_client * +glibtop_client_new (void) +{ + return g_object_new (GLIBTOP_TYPE_CLIENT, NULL); +} diff --git a/lib/init.c b/lib/init.c index 90a4a32c..1ca58b47 100644 --- a/lib/init.c +++ b/lib/init.c @@ -28,104 +28,9 @@ #include #include -#ifndef DEFAULT_PORT -#define DEFAULT_PORT 42800 -#endif - -static glibtop _glibtop_global_server; -glibtop *glibtop_global_server = &_glibtop_global_server; - void -glibtop_server_ref (glibtop *server) +glibtop_init_s (glibtop_server *server, unsigned long features, unsigned flags) { - if (server == NULL) - return; - - server->refcount++; -} - -void -glibtop_server_unref (glibtop *server) -{ - if (server == NULL) - return; - - if (!server->refcount) { - glibtop_warn_r (server, "Attempted to unref server " - "which refcount == 0"); - return; - } - - server->refcount--; -} - -glibtop * -glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags) -{ - glibtop *server; - - if (server_ptr == NULL) - return NULL; - - if (*server_ptr == NULL) - *server_ptr = glibtop_global_server; - - server = *server_ptr; - - /* Should we do the initialization? */ - - if (flags & GLIBTOP_INIT_NO_INIT) - return server; - - if (!server->info) { - server->info = g_new0 (glibtop_server_info, 1); - } - - /* Do the initialization, but only if not already initialized. */ - - if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) { - if (flags & GLIBTOP_FEATURES_EXCEPT) - features = ~features & GLIBTOP_SYSDEPS_ALL; - - if (features == 0) - features = GLIBTOP_SYSDEPS_ALL; - - if (flags & GLIBTOP_FEATURES_NO_SERVER) { - features = 0; - } - - server->info->features = features; - - server->flags |= _GLIBTOP_INIT_STATE_INIT; - } - - /* Should we open the server? */ - - if (flags & GLIBTOP_INIT_NO_OPEN) - return server; - - /* Open server, but only if not already opened. */ - - if ((server->flags & _GLIBTOP_INIT_STATE_OPEN) == 0) - glibtop_open_l (glibtop_global_server, "glibtop", - features, flags); - - return server; -} - -glibtop * -glibtop_init_s (glibtop **server_ptr, unsigned long features, unsigned flags) -{ - glibtop *server; - - if (server_ptr == NULL) - return NULL; - - if (*server_ptr == NULL) - *server_ptr = glibtop_global_server; - - server = *server_ptr; - /* Should we do the initialization? */ if (flags & GLIBTOP_INIT_NO_INIT) diff --git a/lib/open-backend.c b/lib/open-backend.c index 5dda16bb..9caae1cc 100644 --- a/lib/open-backend.c +++ b/lib/open-backend.c @@ -25,12 +25,9 @@ #include #include -#include #include -#if LIBGTOP_USE_GMODULE - #include static void @@ -40,7 +37,8 @@ unload_module (gpointer data, gpointer user_data) } static int -load_extra_libs (glibtop *server, glibtop_backend_entry *entry) +load_extra_libs (glibtop_client *client, glibtop_backend_entry *entry, + GError **error) { GSList *list; GSList *loaded_here = NULL; @@ -51,9 +49,10 @@ load_extra_libs (glibtop *server, glibtop_backend_entry *entry) module = g_module_open (filename, G_MODULE_BIND_LAZY); if (!module) { - glibtop_warn_r (server, "Cannot open extra shared library `%s' " - "for backend `%s' (%s)", filename, entry->name, - g_module_error ()); + g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, + "Cannot open extra shared library `%s' " + "for backend `%s' (%s)", filename, entry->name, + g_module_error ()); g_slist_foreach (loaded_here, unload_module, NULL); return -GLIBTOP_ERROR_NO_SUCH_BACKEND; } @@ -67,119 +66,78 @@ load_extra_libs (glibtop *server, glibtop_backend_entry *entry) return 0; } -#else /* not LIBGTOP_USE_GMODULE */ - -extern glibtop_backend_info LibGTopBackendInfo_Sysdeps; -extern glibtop_backend_info LibGTopBackendInfo_Common; -extern glibtop_backend_info LibGTopBackendInfo_Server; - -typedef struct { - const char *name; - glibtop_backend_info *backend_info; -} backend_init_table_entry; - -static backend_init_table_entry backend_init_table [] = { -#ifdef LIBGTOP_HAVE_SYSDEPS - { "glibtop-backend-sysdeps", &LibGTopBackendInfo_Sysdeps }, -#endif - { "glibtop-backend-common", &LibGTopBackendInfo_Common }, -#ifdef LIBGTOP_NEED_SERVER - { "glibtop-backend-server", &LibGTopBackendInfo_Server }, -#endif - { NULL, NULL } -}; - -static glibtop_backend_info * -find_backend_by_name (const char *backend_name) -{ - backend_init_table_entry *table; - - for (table = backend_init_table; table->name; table++) - if (!strcmp (backend_name, table->name)) - return table->backend_info; - - return NULL; -} - -#endif /* LIBGTOP_USE_GMODULE */ - -int -glibtop_open_backend_l (glibtop *server, const char *backend_name, - u_int64_t features, const char **backend_args) +glibtop_backend * +glibtop_open_backend_l (glibtop_client *client, const char *backend_name, + u_int64_t features, const char **backend_args, + GError **error) { const glibtop_backend_info *info; glibtop_backend_entry *entry; glibtop_backend *backend; + g_return_val_if_fail (GLIBTOP_IS_CLIENT (client), NULL); + entry = glibtop_backend_by_name (backend_name); - if (!entry) return -GLIBTOP_ERROR_NO_SUCH_BACKEND; + if (!entry) return NULL; if (!entry->_priv) { entry->_priv = g_new0 (glibtop_backend_module, 1); -#if LIBGTOP_USE_GMODULE if (entry->extra_libs) { int retval; - retval = load_extra_libs (server, entry); - if (retval < 0) return retval; + retval = load_extra_libs (client, entry, error); + if (retval < 0) return NULL; } entry->_priv->module = g_module_open (entry->shlib_name, G_MODULE_BIND_LAZY); if (!entry->_priv->module) { - glibtop_warn_r (server, "Cannot open shared library `%s' " - "for backend `%s' (%s)", entry->shlib_name, - entry->name, g_module_error ()); - return -GLIBTOP_ERROR_NO_SUCH_BACKEND; + g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, + "Cannot open shared library `%s' " + "for backend `%s' (%s)", entry->shlib_name, + entry->name, g_module_error ()); + return NULL; } if (!g_module_symbol (entry->_priv->module, "LibGTopBackendInfo", (gpointer*) &entry->info)) { - glibtop_warn_r (server, "Library `%s' is not a valid " - "LibGTop Backend library (start symbol not found)", - entry->shlib_name); + g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, + "Library `%s' is not a valid " + "LibGTop Backend library (start symbol not found)", + entry->shlib_name); g_module_close (entry->_priv->module); g_free (entry->_priv); entry->_priv = NULL; - return -GLIBTOP_ERROR_NO_SUCH_BACKEND; + return NULL; } -#else /* not LIBGTOP_USE_GMODULE */ - entry->info = find_backend_by_name (backend_name); - if (!entry->info) - return -GLIBTOP_ERROR_NO_SUCH_BACKEND; -#endif /* not LIBGTOP_USE_GMODULE */ } entry->_priv->refcount++; info = entry->info; - if (!info) return -GLIBTOP_ERROR_NO_SUCH_BACKEND; + if (!info) return NULL; - backend = glibtop_calloc_r (server, 1, sizeof (glibtop_backend)); + backend = g_new0 (glibtop_backend, 1); backend->_priv_module = entry->_priv; backend->info = info; - if (!server->_priv) - server->_priv = glibtop_calloc_r - (server, 1, sizeof (glibtop_server_private)); + backend->server = glibtop_server_new (); if (info->open) { int retval; - retval = info->open (server, backend, features, backend_args); + retval = info->open (backend->server, backend, features, backend_args); if (retval) { - glibtop_free_r (server, backend->_priv); - glibtop_free_r (server, backend); - return retval; + glibtop_server_unref (backend->server); + g_free (backend->_priv); + g_free (backend); + return NULL; } } - server->_priv->backend_list = g_slist_append - (server->_priv->backend_list, backend); - - return 0; + return backend; } diff --git a/lib/parameter.c b/lib/parameter.c index 4ec58c0b..745fb227 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -45,7 +45,7 @@ #define _strlen(ptr) (ptr ? strlen (ptr) : 0) ssize_t -glibtop_get_parameter_l (glibtop *server, const unsigned parameter, +glibtop_get_parameter_l (glibtop_client *client, const unsigned parameter, void *data_ptr, size_t data_size) { switch (parameter) { @@ -70,7 +70,7 @@ glibtop_get_parameter_l (glibtop *server, const unsigned parameter, } int -glibtop_get_parameter_size_l (glibtop *server, const unsigned parameter) +glibtop_get_parameter_size_l (glibtop_client *client, const unsigned parameter) { switch (parameter) { case GLIBTOP_PARAM_ERROR_METHOD: @@ -89,7 +89,7 @@ glibtop_get_parameter_size_l (glibtop *server, const unsigned parameter) } int -glibtop_set_parameter_l (glibtop *server, const unsigned parameter, +glibtop_set_parameter_l (glibtop_client *client, const unsigned parameter, const void *data_ptr, size_t data_size) { switch (parameter) { diff --git a/sysdeps/common/xmalloc.c b/lib/xmalloc.c similarity index 86% rename from sysdeps/common/xmalloc.c rename to lib/xmalloc.c index 4c958a36..f46ea55b 100644 --- a/sysdeps/common/xmalloc.c +++ b/lib/xmalloc.c @@ -32,7 +32,7 @@ /* Wrappers to malloc, calloc, realloc ... */ void * -glibtop_malloc_r (glibtop *server, size_t size) +glibtop_malloc_r (glibtop_server *server, size_t size) { #ifdef LIBGTOP_USE_GLIB_MALLOC return g_malloc0 (size); @@ -47,7 +47,7 @@ glibtop_malloc_r (glibtop *server, size_t size) } void * -glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size) +glibtop_calloc_r (glibtop_server *server, size_t nmemb, size_t size) { #ifdef LIBGTOP_USE_GLIB_MALLOC return g_malloc0 (size * nmemb); @@ -63,7 +63,7 @@ glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size) } void * -glibtop_realloc_r (glibtop *server, void *ptr, size_t size) +glibtop_realloc_r (glibtop_server *server, void *ptr, size_t size) { #ifdef LIBGTOP_USE_GLIB_MALLOC return g_realloc (ptr, size); @@ -78,7 +78,7 @@ glibtop_realloc_r (glibtop *server, void *ptr, size_t size) } char * -glibtop_strdup_r (glibtop *server, const char *string) +glibtop_strdup_r (glibtop_server *server, const char *string) { #ifdef LIBGTOP_USE_GLIB_MALLOC return g_strdup (string); @@ -88,7 +88,7 @@ glibtop_strdup_r (glibtop *server, const char *string) } void -glibtop_free_r (glibtop *server, const void *ptr) +glibtop_free_r (glibtop_server *server, const void *ptr) { #ifdef LIBGTOP_USE_GLIB_MALLOC g_free (ptr); diff --git a/po/POTFILES.in b/po/POTFILES.in index 18a9dbd3..97c28169 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -44,7 +44,6 @@ include/glibtop/mem.h include/glibtop/mountlist.h include/glibtop/msg_limits.h include/glibtop/open.h -include/glibtop/parameter.h include/glibtop/prockernel.h include/glibtop/proclist.h include/glibtop/procmap.h diff --git a/sysdeps/common/Makefile.am b/sysdeps/common/Makefile.am index 4e4f547d..07c17eaa 100644 --- a/sysdeps/common/Makefile.am +++ b/sysdeps/common/Makefile.am @@ -16,8 +16,7 @@ CFLAGS = @CFLAGS@ $(inodedb_DEFS) lib_LTLIBRARIES = libgtop_common.la libgtop_suid_common.la -libgtop_common_la_SOURCES = xmalloc.c error.c \ - fsusage.c fsusage.h mountlist.c mountlist.h \ +libgtop_common_la_SOURCES = fsusage.c fsusage.h mountlist.c mountlist.h \ $(inodedb_SRCLIST) libgtop_common_la_LDFLAGS = $(LT_VERSION_INFO) $(dynamic_ldflags) diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c index b89c5fda..4c2721da 100644 --- a/sysdeps/common/fsusage.c +++ b/sysdeps/common/fsusage.c @@ -291,12 +291,12 @@ statfs (path, fsb) #endif /* _AIX && _I386 */ int -glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, +glibtop_get_fsusage_s (glibtop_server *server, glibtop_fsusage *buf, const char *disk) { struct fs_usage fsp; - glibtop_init_r (&server, 0, 0); + glibtop_init_s (server, 0, 0); memset (buf, 0, sizeof (glibtop_fsusage)); memset (&fsp, 0, sizeof (struct fs_usage)); diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c index 2127fbb8..55765c57 100644 --- a/sysdeps/common/mountlist.c +++ b/sysdeps/common/mountlist.c @@ -588,13 +588,14 @@ read_filesystem_list (need_fs_type, all_fs) } glibtop_mountentry * -glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs) +glibtop_get_mountlist_s (glibtop_server *server, glibtop_mountlist *buf, + int all_fs) { struct mount_entry *me, *tmp, *next; glibtop_mountentry *mount_list; int count; - glibtop_init_r (&server, 0, 0); + glibtop_init_s (server, 0, 0); memset (buf, 0, sizeof (glibtop_mountlist)); diff --git a/sysdeps/common/xmalloc_suid.c b/sysdeps/common/xmalloc_suid.c index f8b7fe44..516f9143 100644 --- a/sysdeps/common/xmalloc_suid.c +++ b/sysdeps/common/xmalloc_suid.c @@ -28,7 +28,7 @@ /* Wrappers to malloc, calloc, realloc ... */ void * -glibtop_malloc_r (glibtop *server, size_t size) +glibtop_malloc_r (glibtop_server *server, size_t size) { void *buf = malloc (size); @@ -39,7 +39,7 @@ glibtop_malloc_r (glibtop *server, size_t size) } void * -glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size) +glibtop_calloc_r (glibtop_server *server, size_t nmemb, size_t size) { void *buf = calloc (nmemb, size); @@ -51,7 +51,7 @@ glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size) } void * -glibtop_realloc_r (glibtop *server, void *ptr, size_t size) +glibtop_realloc_r (glibtop_server *server, void *ptr, size_t size) { void *buf = realloc (ptr, size); @@ -62,13 +62,13 @@ glibtop_realloc_r (glibtop *server, void *ptr, size_t size) } char * -glibtop_strdup_r (glibtop *server, const char *string) +glibtop_strdup_r (glibtop_server *server, const char *string) { return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string); } void -glibtop_free_r (glibtop *server, const void *ptr) +glibtop_free_r (glibtop_server *server, const void *ptr) { if (ptr) free ((void *) ptr); } diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am index 29f1e593..12bcaf9f 100644 --- a/sysdeps/stub/Makefile.am +++ b/sysdeps/stub/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @INCLUDES@ +INCLUDES = @INCLUDES@ -D_IN_LIBGTOP_SERVER lib_LTLIBRARIES = libgtop_sysdeps.la @@ -13,5 +13,5 @@ libgtop_sysdeps_la_SOURCES = open.c close.c cpu.c mem.c swap.c \ libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) -include_HEADERS = glibtop_server.h +noinst_HEADERS = glibtop_server_private.h diff --git a/sysdeps/stub/close.c b/sysdeps/stub/close.c index 3378b817..defd8fd4 100644 --- a/sysdeps/stub/close.c +++ b/sysdeps/stub/close.c @@ -28,5 +28,5 @@ /* Closes pipe to gtop server. */ void -glibtop_close_s (glibtop *server) +glibtop_close_s (glibtop_server *server) { } diff --git a/sysdeps/stub/cpu.c b/sysdeps/stub/cpu.c index c6b2dee9..266afe49 100644 --- a/sysdeps/stub/cpu.c +++ b/sysdeps/stub/cpu.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_cpu = 0; /* Init function. */ int -glibtop_init_cpu_s (glibtop *server) +glibtop_init_cpu_s (glibtop_server *server) { server->info->sysdeps.cpu = _glibtop_sysdeps_cpu; @@ -41,8 +41,10 @@ glibtop_init_cpu_s (glibtop *server) /* Provides information about cpu usage. */ int -glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_s (glibtop_server *server, glibtop_cpu *buf) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_CPU, 0); + memset (buf, 0, sizeof (glibtop_cpu)); return 0; diff --git a/sysdeps/stub/glibtop_server.h b/sysdeps/stub/glibtop_server_private.h similarity index 95% rename from sysdeps/stub/glibtop_server.h rename to sysdeps/stub/glibtop_server_private.h index ce0acf4f..3ca3737c 100644 --- a/sysdeps/stub/glibtop_server.h +++ b/sysdeps/stub/glibtop_server_private.h @@ -23,8 +23,8 @@ Boston, MA 02111-1307, USA. */ -#ifndef __GLIBTOP_SERVER_H__ -#define __GLIBTOP_SERVER_H__ +#ifndef __GLIBTOP_SERVER_PRIVATE_H__ +#define __GLIBTOP_SERVER_PRIVATE_H__ BEGIN_LIBGTOP_DECLS diff --git a/sysdeps/stub/interfaces.c b/sysdeps/stub/interfaces.c index 319f4ee6..c3dbccf9 100644 --- a/sysdeps/stub/interfaces.c +++ b/sysdeps/stub/interfaces.c @@ -34,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_interface_names = /* Init function. */ int -glibtop_init_interface_names_s (glibtop *server) +glibtop_init_interface_names_s (glibtop_server *server) { server->info->sysdeps.interface_names = _glibtop_sysdeps_interface_names; @@ -45,11 +45,11 @@ glibtop_init_interface_names_s (glibtop *server) glibtop_interface * -glibtop_get_interface_names_s (glibtop *server, glibtop_array *array, +glibtop_get_interface_names_s (glibtop_server *server, glibtop_array *array, u_int64_t interface, u_int64_t number, u_int64_t instance, u_int64_t strategy) { - glibtop_init_s (&server, GLIBTOP_SYSDEPS_INTERFACE_NAMES, 0); + glibtop_init_s (server, GLIBTOP_SYSDEPS_INTERFACE_NAMES, 0); memset (array, 0, sizeof (glibtop_array)); diff --git a/sysdeps/stub/loadavg.c b/sysdeps/stub/loadavg.c index c666d2ca..27fc4bf8 100644 --- a/sysdeps/stub/loadavg.c +++ b/sysdeps/stub/loadavg.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_loadavg = 0; /* Init function. */ int -glibtop_init_loadavg_s (glibtop *server) +glibtop_init_loadavg_s (glibtop_server *server) { server->info->sysdeps.loadavg = _glibtop_sysdeps_loadavg; @@ -41,8 +41,10 @@ glibtop_init_loadavg_s (glibtop *server) /* Provides load averange. */ int -glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_s (glibtop_server *server, glibtop_loadavg *buf) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_LOADAVG, 0); + memset (buf, 0, sizeof (glibtop_loadavg)); return 0; diff --git a/sysdeps/stub/mem.c b/sysdeps/stub/mem.c index 3b16c0a9..0a659dcd 100644 --- a/sysdeps/stub/mem.c +++ b/sysdeps/stub/mem.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_mem = 0; /* Init function. */ int -glibtop_init_mem_s (glibtop *server) +glibtop_init_mem_s (glibtop_server *server) { server->info->sysdeps.mem = _glibtop_sysdeps_mem; @@ -41,8 +41,10 @@ glibtop_init_mem_s (glibtop *server) /* Provides information about memory usage. */ int -glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_s (glibtop_server *server, glibtop_mem *buf) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_MEM, 0); + memset (buf, 0, sizeof (glibtop_mem)); return 0; diff --git a/sysdeps/stub/msg_limits.c b/sysdeps/stub/msg_limits.c index f917678c..d59f0036 100644 --- a/sysdeps/stub/msg_limits.c +++ b/sysdeps/stub/msg_limits.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_msg_limits = 0; /* Init function. */ int -glibtop_init_msg_limits_s (glibtop *server) +glibtop_init_msg_limits_s (glibtop_server *server) { server->info->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; @@ -41,8 +41,10 @@ glibtop_init_msg_limits_s (glibtop *server) /* Provides information about sysv ipc limits. */ int -glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits_s (glibtop_server *server, glibtop_msg_limits *buf) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); + memset (buf, 0, sizeof (glibtop_msg_limits)); return 0; diff --git a/sysdeps/stub/netload.c b/sysdeps/stub/netload.c index e0f974b1..239194fe 100644 --- a/sysdeps/stub/netload.c +++ b/sysdeps/stub/netload.c @@ -32,7 +32,7 @@ static const unsigned long _glibtop_sysdeps_netload = 0; /* Init function. */ int -glibtop_init_netload_s (glibtop *server) +glibtop_init_netload_s (glibtop_server *server) { server->info->sysdeps.netload = _glibtop_sysdeps_netload; @@ -42,10 +42,12 @@ glibtop_init_netload_s (glibtop *server) /* Provides network statistics. */ int -glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, +glibtop_get_netload_s (glibtop_server *server, glibtop_netload *buf, const char *interface, unsigned transport, unsigned protocol) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_NETLOAD, 0); + memset (buf, 0, sizeof (glibtop_netload)); return 0; diff --git a/sysdeps/stub/open.c b/sysdeps/stub/open.c index f269292e..27cf36bb 100644 --- a/sysdeps/stub/open.c +++ b/sysdeps/stub/open.c @@ -29,7 +29,7 @@ /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open_s (glibtop *server, const char *program_name, +glibtop_open_s (glibtop_server *server, const char *program_name, const unsigned long features, const unsigned flags) { server->name = program_name; diff --git a/sysdeps/stub/ppp.c b/sysdeps/stub/ppp.c index 0b177842..6d165881 100644 --- a/sysdeps/stub/ppp.c +++ b/sysdeps/stub/ppp.c @@ -32,7 +32,7 @@ static const unsigned long _glibtop_sysdeps_ppp = 0; /* Init function. */ int -glibtop_init_ppp_s (glibtop *server) +glibtop_init_ppp_s (glibtop_server *server) { server->info->sysdeps.ppp = _glibtop_sysdeps_ppp; @@ -42,9 +42,11 @@ glibtop_init_ppp_s (glibtop *server) /* Provides PPP/ISDN information. */ int -glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device, - unsigned short isdn) +glibtop_get_ppp_s (glibtop_server *server, glibtop_ppp *buf, + unsigned short device, unsigned short isdn) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PPP, 0); + memset (buf, 0, sizeof (glibtop_ppp)); return 0; diff --git a/sysdeps/stub/procargs.c b/sysdeps/stub/procargs.c index 15d2a749..63a57a4d 100644 --- a/sysdeps/stub/procargs.c +++ b/sysdeps/stub/procargs.c @@ -33,7 +33,7 @@ static const unsigned long _glibtop_sysdeps_proc_args = 0; /* Init function. */ int -glibtop_init_proc_args_s (glibtop *server) +glibtop_init_proc_args_s (glibtop_server *server) { server->info->sysdeps.proc_args = _glibtop_sysdeps_proc_args; @@ -43,8 +43,11 @@ glibtop_init_proc_args_s (glibtop *server) /* Provides detailed information about a process. */ char ** -glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid) +glibtop_get_proc_args_s (glibtop_server *server, glibtop_array *array, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_ARGS, 0); + memset (array, 0, sizeof (glibtop_array)); + return NULL; } diff --git a/sysdeps/stub/proccwd.c b/sysdeps/stub/proccwd.c index daca2964..03d99ee4 100644 --- a/sysdeps/stub/proccwd.c +++ b/sysdeps/stub/proccwd.c @@ -33,7 +33,7 @@ static const unsigned long _glibtop_sysdeps_proc_cwd = 0; /* Init function. */ int -glibtop_init_proc_cwd_s (glibtop *server) +glibtop_init_proc_cwd_s (glibtop_server *server) { server->info->sysdeps.proc_cwd = _glibtop_sysdeps_proc_cwd; @@ -43,8 +43,10 @@ glibtop_init_proc_cwd_s (glibtop *server) /* Provides detailed information about a process. */ char * -glibtop_get_proc_cwd_s (glibtop *server, glibtop_proc_cwd *buf, pid_t pid) +glibtop_get_proc_cwd_s (glibtop_server *server, glibtop_proc_cwd *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_CWD, 0); + memset (buf, 0, sizeof (glibtop_proc_cwd)); return NULL; diff --git a/sysdeps/stub/prockernel.c b/sysdeps/stub/prockernel.c index 90ea5d82..4e132d5d 100644 --- a/sysdeps/stub/prockernel.c +++ b/sysdeps/stub/prockernel.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = 0; /* Init function. */ int -glibtop_init_proc_kernel_s (glibtop *server) +glibtop_init_proc_kernel_s (glibtop_server *server) { server->info->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel; @@ -41,9 +41,11 @@ glibtop_init_proc_kernel_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel_s (glibtop_server *server, glibtop_proc_kernel *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); + memset (buf, 0, sizeof (glibtop_proc_kernel)); return 0; diff --git a/sysdeps/stub/proclist.c b/sysdeps/stub/proclist.c index 0cfd699d..a7e8523d 100644 --- a/sysdeps/stub/proclist.c +++ b/sysdeps/stub/proclist.c @@ -33,7 +33,7 @@ static const unsigned long _glibtop_sysdeps_proclist = 0; /* Init function. */ int -glibtop_init_proclist_s (glibtop *server) +glibtop_init_proclist_s (glibtop_server *server) { server->info->sysdeps.proclist = _glibtop_sysdeps_proclist; @@ -48,9 +48,12 @@ glibtop_init_proclist_s (glibtop *server) * each buf->size big. The total size is stored in buf->total. */ unsigned * -glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, +glibtop_get_proclist_s (glibtop_server *server, glibtop_proclist *buf, int64_t which, int64_t arg) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROCLIST, 0); + memset (buf, 0, sizeof (glibtop_proclist)); + return NULL; } diff --git a/sysdeps/stub/procmap.c b/sysdeps/stub/procmap.c index b8c60491..18484cc9 100644 --- a/sysdeps/stub/procmap.c +++ b/sysdeps/stub/procmap.c @@ -34,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_proc_map = 0; /* Init function. */ int -glibtop_init_proc_map_s (glibtop *server) +glibtop_init_proc_map_s (glibtop_server *server) { server->info->sysdeps.proc_map = _glibtop_sysdeps_proc_map; @@ -44,9 +44,10 @@ glibtop_init_proc_map_s (glibtop *server) /* Provides detailed information about a process. */ glibtop_map_entry * -glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) +glibtop_get_proc_map_s (glibtop_server *server, glibtop_proc_map *buf, + pid_t pid) { - glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0); + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_MAP, 0); memset (buf, 0, sizeof (glibtop_proc_map)); diff --git a/sysdeps/stub/procmem.c b/sysdeps/stub/procmem.c index 51b2df11..fe989df6 100644 --- a/sysdeps/stub/procmem.c +++ b/sysdeps/stub/procmem.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_mem = 0; /* Init function. */ int -glibtop_init_proc_mem_s (glibtop *server) +glibtop_init_proc_mem_s (glibtop_server *server) { server->info->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; @@ -41,9 +41,11 @@ glibtop_init_proc_mem_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem_s (glibtop_server *server, glibtop_proc_mem *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_MEM, 0); + memset (buf, 0, sizeof (glibtop_proc_mem)); return 0; diff --git a/sysdeps/stub/procsegment.c b/sysdeps/stub/procsegment.c index 7f20dd9c..4afca8ad 100644 --- a/sysdeps/stub/procsegment.c +++ b/sysdeps/stub/procsegment.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_segment = 0; /* Init function. */ int -glibtop_init_proc_segment_s (glibtop *server) +glibtop_init_proc_segment_s (glibtop_server *server) { server->info->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; @@ -41,9 +41,11 @@ glibtop_init_proc_segment_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment_s (glibtop_server *server, glibtop_proc_segment *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); + memset (buf, 0, sizeof (glibtop_proc_segment)); return 0; diff --git a/sysdeps/stub/procsignal.c b/sysdeps/stub/procsignal.c index e6fdd529..0fce3989 100644 --- a/sysdeps/stub/procsignal.c +++ b/sysdeps/stub/procsignal.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_signal = 0; /* Init function. */ int -glibtop_init_proc_signal_s (glibtop *server) +glibtop_init_proc_signal_s (glibtop_server *server) { server->info->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; @@ -41,9 +41,11 @@ glibtop_init_proc_signal_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal_s (glibtop_server *server, glibtop_proc_signal *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); + memset (buf, 0, sizeof (glibtop_proc_signal)); return 0; diff --git a/sysdeps/stub/procstate.c b/sysdeps/stub/procstate.c index 008517b6..6a9cbab9 100644 --- a/sysdeps/stub/procstate.c +++ b/sysdeps/stub/procstate.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_state = 0; /* Init function. */ int -glibtop_init_proc_state_s (glibtop *server) +glibtop_init_proc_state_s (glibtop_server *server) { server->info->sysdeps.proc_state = _glibtop_sysdeps_proc_state; @@ -41,9 +41,11 @@ glibtop_init_proc_state_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state_s (glibtop_server *server, glibtop_proc_state *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_STATE, 0); + memset (buf, 0, sizeof (glibtop_proc_state)); return 0; diff --git a/sysdeps/stub/proctime.c b/sysdeps/stub/proctime.c index 470c8be4..b8704918 100644 --- a/sysdeps/stub/proctime.c +++ b/sysdeps/stub/proctime.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_time = 0; /* Init function. */ int -glibtop_init_proc_time_s (glibtop *server) +glibtop_init_proc_time_s (glibtop_server *server) { server->info->sysdeps.proc_time = _glibtop_sysdeps_proc_time; @@ -41,9 +41,11 @@ glibtop_init_proc_time_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, +glibtop_get_proc_time_s (glibtop_server *server, glibtop_proc_time *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_TIME, 0); + memset (buf, 0, sizeof (glibtop_proc_time)); return 0; diff --git a/sysdeps/stub/procuid.c b/sysdeps/stub/procuid.c index 652b1be8..53277fbf 100644 --- a/sysdeps/stub/procuid.c +++ b/sysdeps/stub/procuid.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_uid = 0; /* Init function. */ int -glibtop_init_proc_uid_s (glibtop *server) +glibtop_init_proc_uid_s (glibtop_server *server) { server->info->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid; @@ -41,9 +41,11 @@ glibtop_init_proc_uid_s (glibtop *server) /* Provides detailed information about a process. */ int -glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, +glibtop_get_proc_uid_s (glibtop_server *server, glibtop_proc_uid *buf, pid_t pid) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_PROC_UID, 0); + memset (buf, 0, sizeof (glibtop_proc_uid)); return 0; diff --git a/sysdeps/stub/sem_limits.c b/sysdeps/stub/sem_limits.c index f1265180..8f26cbd1 100644 --- a/sysdeps/stub/sem_limits.c +++ b/sysdeps/stub/sem_limits.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_sem_limits = 0; /* Init function. */ int -glibtop_init_sem_limits_s (glibtop *server) +glibtop_init_sem_limits_s (glibtop_server *server) { server->info->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; @@ -41,7 +41,7 @@ glibtop_init_sem_limits_s (glibtop *server) /* Provides information about sysv sem limits. */ int -glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits_s (glibtop_server *server, glibtop_sem_limits *buf) { memset (buf, 0, sizeof (glibtop_sem_limits)); diff --git a/sysdeps/stub/shm_limits.c b/sysdeps/stub/shm_limits.c index 7807faef..6abeeaf3 100644 --- a/sysdeps/stub/shm_limits.c +++ b/sysdeps/stub/shm_limits.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_shm_limits = 0; /* Init function. */ int -glibtop_init_shm_limits_s (glibtop *server) +glibtop_init_shm_limits_s (glibtop_server *server) { server->info->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; @@ -41,7 +41,7 @@ glibtop_init_shm_limits_s (glibtop *server) /* Provides information about sysv ipc limits. */ int -glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits_s (glibtop_server *server, glibtop_shm_limits *buf) { memset (buf, 0, sizeof (glibtop_shm_limits)); diff --git a/sysdeps/stub/swap.c b/sysdeps/stub/swap.c index b3451b67..5ceac8ac 100644 --- a/sysdeps/stub/swap.c +++ b/sysdeps/stub/swap.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_swap = 0; /* Init function. */ int -glibtop_init_swap_s (glibtop *server) +glibtop_init_swap_s (glibtop_server *server) { server->info->sysdeps.swap = _glibtop_sysdeps_swap; @@ -41,8 +41,10 @@ glibtop_init_swap_s (glibtop *server) /* Provides information about swap usage. */ int -glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_s (glibtop_server *server, glibtop_swap *buf) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_SWAP, 0); + memset (buf, 0, sizeof (glibtop_swap)); return 0; diff --git a/sysdeps/stub/uptime.c b/sysdeps/stub/uptime.c index 5829f700..a0e1c489 100644 --- a/sysdeps/stub/uptime.c +++ b/sysdeps/stub/uptime.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_uptime = 0; /* Init function. */ int -glibtop_init_uptime_s (glibtop *server) +glibtop_init_uptime_s (glibtop_server *server) { server->info->sysdeps.uptime = _glibtop_sysdeps_uptime; @@ -41,8 +41,10 @@ glibtop_init_uptime_s (glibtop *server) /* Provides uptime and idle time. */ int -glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_s (glibtop_server *server, glibtop_uptime *buf) { + glibtop_init_s (server, GLIBTOP_SYSDEPS_UPTIME, 0); + memset (buf, 0, sizeof (glibtop_uptime)); return 0;