Started with the big rewrite for GNOME 2.0:

2000-11-20  Martin Baulig  <baulig@suse.de>

	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.
This commit is contained in:
Martin Baulig
2000-11-20 22:37:15 +00:00
committed by Martin Baulig
parent c15ff3f342
commit 752d5b47d2
86 changed files with 792 additions and 601 deletions

View File

@@ -1,3 +1,51 @@
2000-11-20 Martin Baulig <baulig@suse.de>
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 <baulig@suse.de>
* glibtop.h (glibtop_server_info): New type.

View File

@@ -32,10 +32,10 @@
#include <glibtop-backend-private.h>
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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -32,10 +32,10 @@
#include <glibtop-backend-private.h>
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;
}

View File

@@ -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);
}

View File

@@ -32,71 +32,33 @@
#include <glibtop/global.h>
#include <glibtop/limits.h>
#include <glibtop_server.h>
#include <glibtop/types.h>
#include <glibtop/glibtop-client.h>
BEGIN_LIBGTOP_DECLS
typedef struct _glibtop glibtop;
typedef struct _glibtop_server_private glibtop_server_private;
typedef struct _glibtop_server_info glibtop_server_info;
#include <glibtop/sysdeps.h>
#include <glibtop/errors.h>
#include <glibtop/parameter.h>
#include <glibtop/glibtop-server.h>
#ifdef _IN_LIBGTOP
#include <glibtop-server-private.h>
#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

View File

@@ -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

View File

@@ -29,7 +29,7 @@
#include <glibtop.h>
#include <glibtop/global.h>
#include <glib.h>
#include <glibtop/glibtop-client.h>
BEGIN_LIBGTOP_DECLS
@@ -42,9 +42,9 @@ typedef struct _glibtop_backend glibtop_backend;
#include <glibtop/call-vector.h>
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

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -28,38 +28,67 @@
#include <glibtop.h>
#include <gerror.h>
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

View File

@@ -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

View File

@@ -29,31 +29,22 @@
#include <glibtop.h>
#include <glibtop/array.h>
#include <glibtop/global.h>
#include <glibtop/xmalloc.h>
#include <glib.h>
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

View File

@@ -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 <martin@home-of-linux.org>, 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 <glibtop.h>
#include <gobject/gobject.h>
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;
/* <public> */
GError *error;
/* <private> */
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

View File

@@ -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 <martin@home-of-linux.org>, 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 <glibtop/global.h>
#include <glibtop/sysdeps.h>
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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -25,7 +25,6 @@
#define __GLIBTOP_OPEN_H__
#include <glibtop.h>
#include <glibtop/error.h>
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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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;

View File

@@ -25,42 +25,132 @@
#include <glibtop.h>
#include <glibtop/global.h>
#include <glibtop/xmalloc.h>
#include <glibtop/errors.h>
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);
}

View File

@@ -29,14 +29,15 @@
#include <glibtop/glib-arrays.h>
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;
}

106
lib/glibtop-client.c Normal file
View File

@@ -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 <martin@home-of-linux.org>, 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 <glibtop.h>
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);
}

View File

@@ -28,104 +28,9 @@
#include <glibtop/sysdeps.h>
#include <glibtop/parameter.h>
#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)

View File

@@ -25,12 +25,9 @@
#include <glibtop.h>
#include <glibtop/global.h>
#include <glibtop/xmalloc.h>
#include <glibtop/backend.h>
#if LIBGTOP_USE_GMODULE
#include <gmodule.h>
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;
}

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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

View File

@@ -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)

View File

@@ -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));

View File

@@ -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));

View File

@@ -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);
}

View File

@@ -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

View File

@@ -28,5 +28,5 @@
/* Closes pipe to gtop server. */
void
glibtop_close_s (glibtop *server)
glibtop_close_s (glibtop_server *server)
{ }

View File

@@ -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;

View File

@@ -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

View File

@@ -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));

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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));

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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));

View File

@@ -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));

View File

@@ -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;

View File

@@ -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;