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:
committed by
Martin Baulig
parent
6e4f80b8e2
commit
dfd678599f
15
ChangeLog
15
ChangeLog
@@ -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>
|
||||
|
||||
* configure.in (INCLUDES): Added -Werror.
|
||||
|
@@ -32,6 +32,7 @@ print '#include <glibtop/sysdeps.h>';
|
||||
print '#include <glibtop/union.h>';
|
||||
print '';
|
||||
print '#include <glibtop/backend.h>';
|
||||
print '#include <glibtop/call-vector.h>';
|
||||
print '';
|
||||
print '#include <glibtop-backend-private.h>';
|
||||
print '';
|
||||
|
@@ -33,6 +33,7 @@ print '#include <glibtop/union.h>';
|
||||
print '';
|
||||
print '#include "command.h"';
|
||||
print '#include <glibtop/backend.h>';
|
||||
print '#include <glibtop/call-vector.h>';
|
||||
print '';
|
||||
print '#include <glibtop-backend-private.h>';
|
||||
print '';
|
||||
|
@@ -32,6 +32,7 @@ print '#include <glibtop/sysdeps.h>';
|
||||
print '#include <glibtop/union.h>';
|
||||
print '';
|
||||
print '#include <glibtop/backend.h>';
|
||||
print '#include <glibtop/call-vector.h>';
|
||||
print '';
|
||||
print '#include <glibtop-backend-private.h>';
|
||||
print '';
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/global.h>
|
||||
|
||||
#include <glibtop/glibtop-client.h>
|
||||
#include <glibtop/glibtop-server.h>
|
||||
|
||||
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 <glibtop/call-vector.h>
|
||||
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
|
||||
|
||||
|
@@ -31,9 +31,9 @@
|
||||
#include <glibtop.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
|
||||
{
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#include <glibtop.h>
|
||||
#include <gobject/gobject.h>
|
||||
|
||||
#include <glibtop/backend.h>
|
||||
|
||||
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
|
||||
|
@@ -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. */
|
||||
|
@@ -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);
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user