Moved the typedef to backend.h.

2000-11-26  Martin Baulig  <martin@home-of-linux.org>

	* 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().
This commit is contained in:
Martin Baulig
2000-11-26 18:07:11 +00:00
committed by Martin Baulig
parent 6e4f80b8e2
commit dfd678599f
18 changed files with 129 additions and 93 deletions
+40
View File
@@ -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);
}
+7 -45
View File
@@ -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;
}
+4 -4
View File
@@ -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);
}
+6 -6
View File
@@ -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);
}
+4 -4
View File
@@ -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);
}
+6 -6
View File
@@ -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);
}
+6 -6
View File
@@ -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);
}
+4 -4
View File
@@ -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);
}
+4 -4
View File
@@ -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);
}
+9 -4
View File
@@ -26,12 +26,15 @@
#include <glibtop.h>
#include <glibtop/backend.h>
#include <glibtop/cpu.h>
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);
}