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

View File

@@ -1,3 +1,18 @@
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().
2000-11-22 Martin Baulig <martin@home-of-linux.org> 2000-11-22 Martin Baulig <martin@home-of-linux.org>
* configure.in (INCLUDES): Added -Werror. * configure.in (INCLUDES): Added -Werror.

View File

@@ -32,6 +32,7 @@ print '#include <glibtop/sysdeps.h>';
print '#include <glibtop/union.h>'; print '#include <glibtop/union.h>';
print ''; print '';
print '#include <glibtop/backend.h>'; print '#include <glibtop/backend.h>';
print '#include <glibtop/call-vector.h>';
print ''; print '';
print '#include <glibtop-backend-private.h>'; print '#include <glibtop-backend-private.h>';
print ''; print '';

View File

@@ -33,6 +33,7 @@ print '#include <glibtop/union.h>';
print ''; print '';
print '#include "command.h"'; print '#include "command.h"';
print '#include <glibtop/backend.h>'; print '#include <glibtop/backend.h>';
print '#include <glibtop/call-vector.h>';
print ''; print '';
print '#include <glibtop-backend-private.h>'; print '#include <glibtop-backend-private.h>';
print ''; print '';

View File

@@ -32,6 +32,7 @@ print '#include <glibtop/sysdeps.h>';
print '#include <glibtop/union.h>'; print '#include <glibtop/union.h>';
print ''; print '';
print '#include <glibtop/backend.h>'; print '#include <glibtop/backend.h>';
print '#include <glibtop/call-vector.h>';
print ''; print '';
print '#include <glibtop-backend-private.h>'; print '#include <glibtop-backend-private.h>';
print ''; print '';

View File

@@ -29,7 +29,7 @@
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/global.h> #include <glibtop/global.h>
#include <glibtop/glibtop-client.h> #include <glibtop/glibtop-server.h>
BEGIN_LIBGTOP_DECLS 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_module glibtop_backend_module;
typedef struct _glibtop_backend_private glibtop_backend_private; typedef struct _glibtop_backend_private glibtop_backend_private;
typedef struct _glibtop_backend glibtop_backend; typedef struct _glibtop_call_vector glibtop_call_vector;
#include <glibtop/call-vector.h> typedef struct _glibtop_backend glibtop_backend;
typedef int (*glibtop_backend_open_func_t) (glibtop_server *, glibtop_backend *, typedef int (*glibtop_backend_open_func_t) (glibtop_server *, glibtop_backend *,
u_int64_t, const char **); u_int64_t, const char **);
@@ -111,9 +111,8 @@ void
glibtop_init_backends (void); glibtop_init_backends (void);
glibtop_backend * glibtop_backend *
glibtop_open_backend_l (glibtop_client *client, const char *backend_name, glibtop_open_backend (const char *backend_name, u_int64_t features,
u_int64_t features, const char **backend_args, const char **backend_args, GError **error);
GError **opt_error);
END_LIBGTOP_DECLS END_LIBGTOP_DECLS

View File

@@ -31,9 +31,9 @@
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/union.h> #include <glibtop/union.h>
BEGIN_LIBGTOP_DECLS #include <glibtop/backend.h>
typedef struct _glibtop_call_vector glibtop_call_vector; BEGIN_LIBGTOP_DECLS
struct _glibtop_call_vector struct _glibtop_call_vector
{ {

View File

@@ -29,6 +29,8 @@
#include <glibtop.h> #include <glibtop.h>
#include <gobject/gobject.h> #include <gobject/gobject.h>
#include <glibtop/backend.h>
BEGIN_LIBGTOP_DECLS BEGIN_LIBGTOP_DECLS
#define GLIBTOP_TYPE_CLIENT (glibtop_client_get_type ()) #define GLIBTOP_TYPE_CLIENT (glibtop_client_get_type ())
@@ -77,6 +79,18 @@ glibtop_client_propagate_error (glibtop_client *client, GError *error);
void void
glibtop_client_propagate_warning (glibtop_client *client, GError *error); 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 END_LIBGTOP_DECLS
#endif #endif

View File

@@ -94,8 +94,6 @@ struct _glibtop_sysdeps
ppp; /* glibtop_ppp */ ppp; /* glibtop_ppp */
}; };
void glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf);
#ifdef GLIBTOP_NAMES #ifdef GLIBTOP_NAMES
/* You need to link with -lgtop_names to get this stuff here. */ /* You need to link with -lgtop_names to get this stuff here. */

View File

@@ -252,3 +252,43 @@ glibtop_client_propagate_warning (glibtop_client *client, GError *error)
g_value_unset (params + 1); g_value_unset (params + 1);
g_value_unset (params + 0); 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);
}

View File

@@ -37,8 +37,7 @@ unload_module (gpointer data, gpointer user_data)
} }
static int static int
load_extra_libs (glibtop_client *client, glibtop_backend_entry *entry, load_extra_libs (glibtop_backend_entry *entry, GError **error)
GError **error)
{ {
GSList *list; GSList *list;
GSList *loaded_here = NULL; GSList *loaded_here = NULL;
@@ -67,30 +66,18 @@ load_extra_libs (glibtop_client *client, glibtop_backend_entry *entry,
} }
glibtop_backend * glibtop_backend *
glibtop_open_backend_l (glibtop_client *client, const char *backend_name, glibtop_open_backend (const char *backend_name, u_int64_t features,
u_int64_t features, const char **backend_args, const char **backend_args, GError **error)
GError **opt_error)
{ {
const glibtop_backend_info *info; const glibtop_backend_info *info;
glibtop_backend_entry *entry; glibtop_backend_entry *entry;
glibtop_backend *backend; 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); entry = glibtop_backend_by_name (backend_name);
if (!entry) { if (!entry) {
g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND,
"No backend with this name"); "No backend with this name");
if (my_error != NULL) { return NULL;
glibtop_client_propagate_error (client, my_error);
g_error_free (my_error);
}
} }
if (!entry->_priv) { if (!entry->_priv) {
@@ -99,15 +86,10 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name,
if (entry->extra_libs) { if (entry->extra_libs) {
int retval; int retval;
retval = load_extra_libs (client, entry, error); retval = load_extra_libs (entry, error);
if (retval < 0) { if (retval < 0)
if (my_error != NULL) {
glibtop_client_propagate_error (client, my_error);
g_error_free (my_error);
}
return NULL; return NULL;
} }
}
entry->_priv->module = g_module_open (entry->shlib_name, entry->_priv->module = g_module_open (entry->shlib_name,
G_MODULE_BIND_LAZY); G_MODULE_BIND_LAZY);
@@ -116,10 +98,6 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name,
"Cannot open shared library `%s' " "Cannot open shared library `%s' "
"for backend `%s' (%s)", entry->shlib_name, "for backend `%s' (%s)", entry->shlib_name,
entry->name, g_module_error ()); entry->name, g_module_error ());
if (my_error != NULL) {
glibtop_client_propagate_error (client, my_error);
g_error_free (my_error);
}
return NULL; return NULL;
} }
@@ -131,11 +109,6 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name,
"LibGTop Backend library (start symbol not found)", "LibGTop Backend library (start symbol not found)",
entry->shlib_name); 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_module_close (entry->_priv->module);
g_free (entry->_priv); g_free (entry->_priv);
entry->_priv = NULL; entry->_priv = NULL;
@@ -144,16 +117,10 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name,
} }
} }
entry->_priv->refcount++;
info = entry->info; info = entry->info;
if (!info) { if (!info) {
g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND,
"Can't get backend info"); "Can't get backend info");
if (my_error != NULL) {
glibtop_client_propagate_error (client, my_error);
g_error_free (my_error);
}
return NULL; return NULL;
} }
@@ -170,10 +137,6 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name,
if (retval) { if (retval) {
g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND, g_set_error (error, GLIBTOP_ERROR, GLIBTOP_ERROR_NO_SUCH_BACKEND,
"Backend open function return error condition"); "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); glibtop_server_unref (backend->server);
g_free (backend->_priv); g_free (backend->_priv);
@@ -182,8 +145,7 @@ glibtop_open_backend_l (glibtop_client *client, const char *backend_name,
} }
} }
if (my_error != NULL) entry->_priv->refcount++;
g_error_free (my_error);
return backend; return backend;
} }

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, const u_int64_t features, const char **backend_args,
GError **opt_error) GError **opt_error)
{ {
glibtop_open_backend_l (client, "glibtop-backend-common", glibtop_client_open_backend (client, "glibtop-backend-common",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-server", glibtop_client_open_backend (client, "glibtop-backend-server",
features, backend_args, opt_error); features, backend_args);
} }

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, const u_int64_t features, const char **backend_args,
GError **opt_error) GError **opt_error)
{ {
glibtop_open_backend_l (client, "glibtop-backend-kernel", glibtop_client_open_backend (client, "glibtop-backend-kernel",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-common", glibtop_client_open_backend (client, "glibtop-backend-common",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-sysdeps", glibtop_client_open_backend (client, "glibtop-backend-sysdeps",
features, backend_args, opt_error); features, backend_args);
} }

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, const u_int64_t features, const char **backend_args,
GError **opt_error) GError **opt_error)
{ {
glibtop_open_backend_l (client, "glibtop-backend-common", glibtop_client_open_backend (client, "glibtop-backend-common",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-sysdeps", glibtop_client_open_backend (client, "glibtop-backend-sysdeps",
features, backend_args, opt_error); features, backend_args);
} }

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, const u_int64_t features, const char **backend_args,
GError **opt_error) GError **opt_error)
{ {
glibtop_open_backend_l (client, "glibtop-backend-common", glibtop_client_open_backend (client, "glibtop-backend-common",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-sysdeps", glibtop_client_open_backend (client, "glibtop-backend-sysdeps",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-server", glibtop_client_open_backend (client, "glibtop-backend-server",
features, backend_args, opt_error); features, backend_args);
} }

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, const u_int64_t features, const char **backend_args,
GError **opt_error) GError **opt_error)
{ {
glibtop_open_backend_l (client, "glibtop-backend-common", glibtop_client_open_backend (client, "glibtop-backend-common",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-sysdeps", glibtop_client_open_backend (client, "glibtop-backend-sysdeps",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-server", glibtop_client_open_backend (client, "glibtop-backend-server",
features, backend_args, opt_error); features, backend_args);
} }

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, const u_int64_t features, const char **backend_args,
GError **opt_error) GError **opt_error)
{ {
glibtop_open_backend_l (client, "glibtop-backend-common", glibtop_client_open_backend (client, "glibtop-backend-common",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-server", glibtop_client_open_backend (client, "glibtop-backend-server",
features, backend_args, opt_error); features, backend_args);
} }

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, const u_int64_t features, const char **backend_args,
GError **opt_error) GError **opt_error)
{ {
glibtop_open_backend_l (client, "glibtop-backend-common", glibtop_client_open_backend (client, "glibtop-backend-common",
features, backend_args, opt_error); features, backend_args);
glibtop_open_backend_l (client, "glibtop-backend-sysdeps", glibtop_client_open_backend (client, "glibtop-backend-sysdeps",
features, backend_args, opt_error); features, backend_args);
} }

View File

@@ -26,12 +26,15 @@
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/backend.h> #include <glibtop/backend.h>
#include <glibtop/cpu.h>
int int
main (int argc, char *argv []) main (int argc, char *argv [])
{ {
glibtop_client *client; glibtop_client *client;
glibtop_backend *backend_common; glibtop_backend *backend_common;
glibtop_backend *backend_sysdeps; glibtop_backend *backend_sysdeps;
/* glibtop_cpu cpu; */
g_type_init (); g_type_init ();
@@ -39,15 +42,17 @@ main (int argc, char *argv [])
client = glibtop_client_new (); client = glibtop_client_new ();
backend_common = glibtop_open_backend_l (client, "glibtop-backend-common", backend_common = glibtop_client_open_backend
0, NULL, NULL); (client, "glibtop-backend-common", 0, NULL);
g_message (G_STRLOC ": backend = %p", backend_common); g_message (G_STRLOC ": backend = %p", backend_common);
backend_sysdeps = glibtop_open_backend_l (client, "glibtop-backend-sysdeps", backend_sysdeps = glibtop_client_open_backend
0, NULL, NULL); (client, "glibtop-backend-sysdeps", 0, NULL);
g_message (G_STRLOC ": backend = %p", backend_sysdeps); g_message (G_STRLOC ": backend = %p", backend_sysdeps);
/* glibtop_get_cpu_l (client, &cpu); */
exit (0); exit (0);
} }