diff --git a/ChangeLog b/ChangeLog index a8b84c5c..8f78c6a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2000-11-26 Martin Baulig + + * include/glibtop/call-vector.h (glibtop_call_vector): Moved + the typedef to backend.h. + + * include/glibtop/backend.h (glibtop_open_backend_l): Renamed + to glibtop_open_backend(), removed the `glibtop_client *' + argument and made the `GError *' argument non-optional. + + * include/glibtop/glibtop-client.h + (glibtop_client_add_backend, glibtop_client_remove_backend): New + functions to add/remove a glibtop_backend to a glibtop_client. + (glibtop_client_open_backend): New convenient function; calls + glibtop_open_backend() and glibtop_client_add_backend(). + 2000-11-22 Martin Baulig * configure.in (INCLUDES): Added -Werror. diff --git a/backends/common/marshal.pl b/backends/common/marshal.pl index 5ae17238..f9623964 100644 --- a/backends/common/marshal.pl +++ b/backends/common/marshal.pl @@ -32,6 +32,7 @@ print '#include '; print '#include '; print ''; print '#include '; +print '#include '; print ''; print '#include '; print ''; diff --git a/backends/server/marshal.pl b/backends/server/marshal.pl index 8eff2e2b..c1ebc905 100644 --- a/backends/server/marshal.pl +++ b/backends/server/marshal.pl @@ -33,6 +33,7 @@ print '#include '; print ''; print '#include "command.h"'; print '#include '; +print '#include '; print ''; print '#include '; print ''; diff --git a/backends/sysdeps/marshal.pl b/backends/sysdeps/marshal.pl index fec00daa..73557fc0 100644 --- a/backends/sysdeps/marshal.pl +++ b/backends/sysdeps/marshal.pl @@ -32,6 +32,7 @@ print '#include '; print '#include '; print ''; print '#include '; +print '#include '; print ''; print '#include '; print ''; diff --git a/include/glibtop/backend.h b/include/glibtop/backend.h index bb58b91e..6a0ad911 100644 --- a/include/glibtop/backend.h +++ b/include/glibtop/backend.h @@ -29,7 +29,7 @@ #include #include -#include +#include BEGIN_LIBGTOP_DECLS @@ -38,9 +38,9 @@ typedef struct _glibtop_backend_entry glibtop_backend_entry; typedef struct _glibtop_backend_module glibtop_backend_module; typedef struct _glibtop_backend_private glibtop_backend_private; -typedef struct _glibtop_backend glibtop_backend; +typedef struct _glibtop_call_vector glibtop_call_vector; -#include +typedef struct _glibtop_backend glibtop_backend; typedef int (*glibtop_backend_open_func_t) (glibtop_server *, glibtop_backend *, u_int64_t, const char **); @@ -111,9 +111,8 @@ void glibtop_init_backends (void); glibtop_backend * -glibtop_open_backend_l (glibtop_client *client, const char *backend_name, - u_int64_t features, const char **backend_args, - GError **opt_error); +glibtop_open_backend (const char *backend_name, u_int64_t features, + const char **backend_args, GError **error); END_LIBGTOP_DECLS diff --git a/include/glibtop/call-vector.h.in b/include/glibtop/call-vector.h.in index 4ce8a808..b1ab81dd 100644 --- a/include/glibtop/call-vector.h.in +++ b/include/glibtop/call-vector.h.in @@ -31,9 +31,9 @@ #include #include -BEGIN_LIBGTOP_DECLS +#include -typedef struct _glibtop_call_vector glibtop_call_vector; +BEGIN_LIBGTOP_DECLS struct _glibtop_call_vector { diff --git a/include/glibtop/glibtop-client.h b/include/glibtop/glibtop-client.h index c19ebbc3..f07a46be 100644 --- a/include/glibtop/glibtop-client.h +++ b/include/glibtop/glibtop-client.h @@ -29,6 +29,8 @@ #include #include +#include + BEGIN_LIBGTOP_DECLS #define GLIBTOP_TYPE_CLIENT (glibtop_client_get_type ()) @@ -77,6 +79,18 @@ glibtop_client_propagate_error (glibtop_client *client, GError *error); void glibtop_client_propagate_warning (glibtop_client *client, GError *error); +glibtop_backend * +glibtop_client_open_backend (glibtop_client *client, const char *backend_name, + u_int64_t features, const char **backend_args); + +void +glibtop_client_add_backend (glibtop_client *client, + glibtop_backend *backend); + +void +glibtop_client_remove_backend (glibtop_client *client, + glibtop_backend *backend); + END_LIBGTOP_DECLS #endif diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index 120c37ab..65d53bd6 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -94,8 +94,6 @@ struct _glibtop_sysdeps ppp; /* glibtop_ppp */ }; -void glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf); - #ifdef GLIBTOP_NAMES /* You need to link with -lgtop_names to get this stuff here. */ diff --git a/lib/glibtop-client.c b/lib/glibtop-client.c index 2d827193..43f37d87 100644 --- a/lib/glibtop-client.c +++ b/lib/glibtop-client.c @@ -252,3 +252,43 @@ glibtop_client_propagate_warning (glibtop_client *client, GError *error) g_value_unset (params + 1); g_value_unset (params + 0); } + +glibtop_backend * +glibtop_client_open_backend (glibtop_client *client, const char *backend_name, + u_int64_t features, const char **backend_args) +{ + glibtop_backend *backend; + GError *error = NULL; + + g_return_val_if_fail (GLIBTOP_IS_CLIENT (client), NULL); + + backend = glibtop_open_backend (backend_name, features, backend_args, + &error); + if (!backend) { + glibtop_client_propagate_error (client, error); + g_error_free (error); + return NULL; + } + + glibtop_client_add_backend (client, backend); + + return backend; +} + +void +glibtop_client_add_backend (glibtop_client *client, + glibtop_backend *backend) +{ + g_return_if_fail (GLIBTOP_IS_CLIENT (client)); + g_return_if_fail (backend != NULL); + +} + +void +glibtop_client_remove_backend (glibtop_client *client, + glibtop_backend *backend) +{ + g_return_if_fail (GLIBTOP_IS_CLIENT (client)); + g_return_if_fail (backend != NULL); + +} diff --git a/lib/open-backend.c b/lib/open-backend.c index aeb6cffb..a695f72a 100644 --- a/lib/open-backend.c +++ b/lib/open-backend.c @@ -37,8 +37,7 @@ unload_module (gpointer data, gpointer user_data) } static int -load_extra_libs (glibtop_client *client, glibtop_backend_entry *entry, - GError **error) +load_extra_libs (glibtop_backend_entry *entry, GError **error) { GSList *list; GSList *loaded_here = NULL; @@ -67,30 +66,18 @@ load_extra_libs (glibtop_client *client, glibtop_backend_entry *entry, } glibtop_backend * -glibtop_open_backend_l (glibtop_client *client, const char *backend_name, - u_int64_t features, const char **backend_args, - GError **opt_error) +glibtop_open_backend (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; - GError **error, *my_error = NULL; - - g_return_val_if_fail (GLIBTOP_IS_CLIENT (client), NULL); - - if (opt_error == NULL) - error = &my_error; - else - error = opt_error; entry = glibtop_backend_by_name (backend_name); if (!entry) { g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, "No backend with this name"); - if (my_error != NULL) { - glibtop_client_propagate_error (client, my_error); - g_error_free (my_error); - } + return NULL; } if (!entry->_priv) { @@ -99,14 +86,9 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name, if (entry->extra_libs) { int retval; - retval = load_extra_libs (client, entry, error); - if (retval < 0) { - if (my_error != NULL) { - glibtop_client_propagate_error (client, my_error); - g_error_free (my_error); - } + retval = load_extra_libs (entry, error); + if (retval < 0) return NULL; - } } entry->_priv->module = g_module_open (entry->shlib_name, @@ -116,10 +98,6 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name, "Cannot open shared library `%s' " "for backend `%s' (%s)", entry->shlib_name, entry->name, g_module_error ()); - if (my_error != NULL) { - glibtop_client_propagate_error (client, my_error); - g_error_free (my_error); - } return NULL; } @@ -131,11 +109,6 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name, "LibGTop Backend library (start symbol not found)", entry->shlib_name); - if (my_error != NULL) { - glibtop_client_propagate_error (client, my_error); - g_error_free (my_error); - } - g_module_close (entry->_priv->module); g_free (entry->_priv); entry->_priv = NULL; @@ -144,16 +117,10 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name, } } - entry->_priv->refcount++; - info = entry->info; if (!info) { g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, "Can't get backend info"); - if (my_error != NULL) { - glibtop_client_propagate_error (client, my_error); - g_error_free (my_error); - } return NULL; } @@ -170,10 +137,6 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name, if (retval) { g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, "Backend open function return error condition"); - if (my_error != NULL) { - glibtop_client_propagate_error (client, my_error); - g_error_free (my_error); - } glibtop_server_unref (backend->server); g_free (backend->_priv); @@ -182,8 +145,7 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name, } } - if (my_error != NULL) - g_error_free (my_error); + entry->_priv->refcount++; return backend; } diff --git a/lib/sysdeps-init-freebsd.c b/lib/sysdeps-init-freebsd.c index f390542a..0ff69857 100644 --- a/lib/sysdeps-init-freebsd.c +++ b/lib/sysdeps-init-freebsd.c @@ -69,8 +69,8 @@ _glibtop_open_sysdeps (glibtop_client *client, const char *program_name, const u_int64_t features, const char **backend_args, GError **opt_error) { - glibtop_open_backend_l (client, "glibtop-backend-common", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-server", - features, backend_args, opt_error); + glibtop_client_open_backend (client, "glibtop-backend-common", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-server", + features, backend_args); } diff --git a/lib/sysdeps-init-kernel.c b/lib/sysdeps-init-kernel.c index 8697218b..5d35638b 100644 --- a/lib/sysdeps-init-kernel.c +++ b/lib/sysdeps-init-kernel.c @@ -69,10 +69,10 @@ _glibtop_open_sysdeps (glibtop_client *client, const char *program_name, const u_int64_t features, const char **backend_args, GError **opt_error) { - glibtop_open_backend_l (client, "glibtop-backend-kernel", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-common", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-sysdeps", - features, backend_args, opt_error); + glibtop_client_open_backend (client, "glibtop-backend-kernel", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-common", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-sysdeps", + features, backend_args); } diff --git a/lib/sysdeps-init-linux.c b/lib/sysdeps-init-linux.c index 654ade2d..ea87d3ed 100644 --- a/lib/sysdeps-init-linux.c +++ b/lib/sysdeps-init-linux.c @@ -69,8 +69,8 @@ _glibtop_open_sysdeps (glibtop_client *client, const char *program_name, const u_int64_t features, const char **backend_args, GError **opt_error) { - glibtop_open_backend_l (client, "glibtop-backend-common", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-sysdeps", - features, backend_args, opt_error); + glibtop_client_open_backend (client, "glibtop-backend-common", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-sysdeps", + features, backend_args); } diff --git a/lib/sysdeps-init-osf1.c b/lib/sysdeps-init-osf1.c index 436f78c8..07f10544 100644 --- a/lib/sysdeps-init-osf1.c +++ b/lib/sysdeps-init-osf1.c @@ -37,10 +37,10 @@ _glibtop_open_sysdeps (glibtop_client *client, const char *program_name, const u_int64_t features, const char **backend_args, GError **opt_error) { - glibtop_open_backend_l (client, "glibtop-backend-common", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-sysdeps", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-server", - features, backend_args, opt_error); + glibtop_client_open_backend (client, "glibtop-backend-common", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-sysdeps", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-server", + features, backend_args); } diff --git a/lib/sysdeps-init-solaris.c b/lib/sysdeps-init-solaris.c index 436f78c8..07f10544 100644 --- a/lib/sysdeps-init-solaris.c +++ b/lib/sysdeps-init-solaris.c @@ -37,10 +37,10 @@ _glibtop_open_sysdeps (glibtop_client *client, const char *program_name, const u_int64_t features, const char **backend_args, GError **opt_error) { - glibtop_open_backend_l (client, "glibtop-backend-common", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-sysdeps", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-server", - features, backend_args, opt_error); + glibtop_client_open_backend (client, "glibtop-backend-common", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-sysdeps", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-server", + features, backend_args); } diff --git a/lib/sysdeps-init-stub-suid.c b/lib/sysdeps-init-stub-suid.c index 786b7e6f..ac226f27 100644 --- a/lib/sysdeps-init-stub-suid.c +++ b/lib/sysdeps-init-stub-suid.c @@ -37,8 +37,8 @@ _glibtop_open_sysdeps (glibtop_client *client, const char *program_name, const u_int64_t features, const char **backend_args, GError **opt_error) { - glibtop_open_backend_l (client, "glibtop-backend-common", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-server", - features, backend_args, opt_error); + glibtop_client_open_backend (client, "glibtop-backend-common", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-server", + features, backend_args); } diff --git a/lib/sysdeps-init-stub.c b/lib/sysdeps-init-stub.c index 3b5b5c04..718d8642 100644 --- a/lib/sysdeps-init-stub.c +++ b/lib/sysdeps-init-stub.c @@ -37,8 +37,8 @@ _glibtop_open_sysdeps (glibtop_client *client, const char *program_name, const u_int64_t features, const char **backend_args, GError **opt_error) { - glibtop_open_backend_l (client, "glibtop-backend-common", - features, backend_args, opt_error); - glibtop_open_backend_l (client, "glibtop-backend-sysdeps", - features, backend_args, opt_error); + glibtop_client_open_backend (client, "glibtop-backend-common", + features, backend_args); + glibtop_client_open_backend (client, "glibtop-backend-sysdeps", + features, backend_args); } diff --git a/lib/test-backends.c b/lib/test-backends.c index b98accc2..036c90cd 100644 --- a/lib/test-backends.c +++ b/lib/test-backends.c @@ -26,12 +26,15 @@ #include #include +#include + int main (int argc, char *argv []) { glibtop_client *client; glibtop_backend *backend_common; glibtop_backend *backend_sysdeps; + /* glibtop_cpu cpu; */ g_type_init (); @@ -39,15 +42,17 @@ main (int argc, char *argv []) client = glibtop_client_new (); - backend_common = glibtop_open_backend_l (client, "glibtop-backend-common", - 0, NULL, NULL); + backend_common = glibtop_client_open_backend + (client, "glibtop-backend-common", 0, NULL); g_message (G_STRLOC ": backend = %p", backend_common); - backend_sysdeps = glibtop_open_backend_l (client, "glibtop-backend-sysdeps", - 0, NULL, NULL); + backend_sysdeps = glibtop_client_open_backend + (client, "glibtop-backend-sysdeps", 0, NULL); g_message (G_STRLOC ": backend = %p", backend_sysdeps); + /* glibtop_get_cpu_l (client, &cpu); */ + exit (0); }