Removed. Split into glibtop-backend.h and glibtop-backend-info.h.
2000-11-26 Martin Baulig <martin@home-of-linux.org> * include/glibtop/backend.h: Removed. Split into glibtop-backend.h and glibtop-backend-info.h. * include/glibtop/glibtop-backend.h: New file. Switched glibtop_backend to a GObject. * include/glibtop/glibtop-backend-info.h: New file. * lib/backend.c, lib/init-backends.c, lib/open-backend.c: Removed. * lib/glibtop-backend.c: New file. * lib/glibtop-backend-info.c: New file.
This commit is contained in:
committed by
Martin Baulig
parent
dfd678599f
commit
16b81f0d91
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
|||||||
|
2000-11-26 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
|
* include/glibtop/backend.h: Removed. Split into glibtop-backend.h
|
||||||
|
and glibtop-backend-info.h.
|
||||||
|
|
||||||
|
* include/glibtop/glibtop-backend.h: New file. Switched
|
||||||
|
glibtop_backend to a GObject.
|
||||||
|
|
||||||
|
* include/glibtop/glibtop-backend-info.h: New file.
|
||||||
|
|
||||||
|
* lib/backend.c, lib/init-backends.c, lib/open-backend.c: Removed.
|
||||||
|
|
||||||
|
* lib/glibtop-backend.c: New file.
|
||||||
|
* lib/glibtop-backend-info.c: New file.
|
||||||
|
|
||||||
2000-11-26 Martin Baulig <martin@home-of-linux.org>
|
2000-11-26 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
* include/glibtop/call-vector.h (glibtop_call_vector): Moved
|
* include/glibtop/call-vector.h (glibtop_call_vector): Moved
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
#include <glibtop/xmalloc.h>
|
#include <glibtop/xmalloc.h>
|
||||||
|
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
|
||||||
#include <glibtop-backend-private.h>
|
#include <glibtop-backend-private.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@@ -26,6 +26,10 @@
|
|||||||
#ifndef __GLIBTOP_BACKEND_PRIVATE_H__
|
#ifndef __GLIBTOP_BACKEND_PRIVATE_H__
|
||||||
#define __GLIBTOP_BACKEND_PRIVATE_H__
|
#define __GLIBTOP_BACKEND_PRIVATE_H__
|
||||||
|
|
||||||
|
#include <glibtop/open.h>
|
||||||
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
#include <glibtop/glibtop-backend-info.h>
|
||||||
|
|
||||||
struct _glibtop_backend_private
|
struct _glibtop_backend_private
|
||||||
{
|
{
|
||||||
u_int64_t flags;
|
u_int64_t flags;
|
||||||
|
@@ -31,7 +31,6 @@ print '';
|
|||||||
print '#include <glibtop/sysdeps.h>';
|
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/call-vector.h>';
|
print '#include <glibtop/call-vector.h>';
|
||||||
print '';
|
print '';
|
||||||
print '#include <glibtop-backend-private.h>';
|
print '#include <glibtop-backend-private.h>';
|
||||||
|
@@ -27,8 +27,6 @@
|
|||||||
#include <glibtop/global.h>
|
#include <glibtop/global.h>
|
||||||
#include <glibtop/xmalloc.h>
|
#include <glibtop/xmalloc.h>
|
||||||
|
|
||||||
#include <glibtop/open.h>
|
|
||||||
#include <glibtop/backend.h>
|
|
||||||
#include <glibtop-backend-private.h>
|
#include <glibtop-backend-private.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@@ -26,6 +26,10 @@
|
|||||||
#ifndef __GLIBTOP_BACKEND_PRIVATE_H__
|
#ifndef __GLIBTOP_BACKEND_PRIVATE_H__
|
||||||
#define __GLIBTOP_BACKEND_PRIVATE_H__
|
#define __GLIBTOP_BACKEND_PRIVATE_H__
|
||||||
|
|
||||||
|
#include <glibtop/open.h>
|
||||||
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
#include <glibtop/glibtop-backend-info.h>
|
||||||
|
|
||||||
struct _glibtop_backend_private
|
struct _glibtop_backend_private
|
||||||
{
|
{
|
||||||
u_int64_t flags;
|
u_int64_t flags;
|
||||||
|
@@ -31,7 +31,6 @@ print '';
|
|||||||
print '#include <glibtop/sysdeps.h>';
|
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/call-vector.h>';
|
print '#include <glibtop/call-vector.h>';
|
||||||
print '';
|
print '';
|
||||||
print '#include <glibtop-backend-private.h>';
|
print '#include <glibtop-backend-private.h>';
|
||||||
|
@@ -9,8 +9,9 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.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 \
|
inodedb.h sysinfo.h ppp.h procargs.h netload.h \
|
||||||
netinfo.h interfaces.h limits.h array.h compat_10.h \
|
netinfo.h interfaces.h limits.h array.h compat_10.h \
|
||||||
glib-arrays.h backend.h call-vector.h \
|
glib-arrays.h call-vector.h \
|
||||||
glibtop-client.h glibtop-server.h
|
glibtop-client.h glibtop-server.h glibtop-backend.h \
|
||||||
|
glibtop-backend-info.h
|
||||||
|
|
||||||
BUILT_SOURCES = call-vector.h
|
BUILT_SOURCES = call-vector.h
|
||||||
|
|
||||||
|
@@ -23,8 +23,8 @@
|
|||||||
Boston, MA 02111-1307, USA.
|
Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __GLIBTOP_BACKEND_H__
|
#ifndef __GLIBTOP_BACKEND_INFO_H__
|
||||||
#define __GLIBTOP_BACKEND_H__
|
#define __GLIBTOP_BACKEND_INFO_H__
|
||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/global.h>
|
#include <glibtop/global.h>
|
||||||
@@ -36,12 +36,9 @@ BEGIN_LIBGTOP_DECLS
|
|||||||
typedef struct _glibtop_backend_info glibtop_backend_info;
|
typedef struct _glibtop_backend_info glibtop_backend_info;
|
||||||
typedef struct _glibtop_backend_entry glibtop_backend_entry;
|
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_call_vector glibtop_call_vector;
|
typedef struct _glibtop_call_vector glibtop_call_vector;
|
||||||
|
|
||||||
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 **);
|
||||||
typedef int (*glibtop_backend_close_func_t) (glibtop_server *, glibtop_backend *);
|
typedef int (*glibtop_backend_close_func_t) (glibtop_server *, glibtop_backend *);
|
||||||
@@ -66,8 +63,6 @@ struct _glibtop_backend_module
|
|||||||
GSList *extra_modules;
|
GSList *extra_modules;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _IN_LIBGTOP */
|
|
||||||
|
|
||||||
struct _glibtop_backend_entry
|
struct _glibtop_backend_entry
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
@@ -84,16 +79,7 @@ struct _glibtop_backend_entry
|
|||||||
glibtop_backend_module *_priv;
|
glibtop_backend_module *_priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _glibtop_backend
|
#endif /* _IN_LIBGTOP */
|
||||||
{
|
|
||||||
const glibtop_backend_info *info;
|
|
||||||
|
|
||||||
glibtop_server *server;
|
|
||||||
|
|
||||||
/* private pointers */
|
|
||||||
glibtop_backend_private *_priv;
|
|
||||||
glibtop_backend_module *_priv_module;
|
|
||||||
};
|
|
||||||
|
|
||||||
long
|
long
|
||||||
glibtop_register_backend (glibtop_backend_entry *entry);
|
glibtop_register_backend (glibtop_backend_entry *entry);
|
||||||
@@ -110,10 +96,6 @@ glibtop_backend_by_name (const char *backend_name);
|
|||||||
void
|
void
|
||||||
glibtop_init_backends (void);
|
glibtop_init_backends (void);
|
||||||
|
|
||||||
glibtop_backend *
|
|
||||||
glibtop_open_backend (const char *backend_name, u_int64_t features,
|
|
||||||
const char **backend_args, GError **error);
|
|
||||||
|
|
||||||
END_LIBGTOP_DECLS
|
END_LIBGTOP_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
71
include/glibtop/glibtop-backend.h
Normal file
71
include/glibtop/glibtop-backend.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/* -*- 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_BACKEND_H__
|
||||||
|
#define __GLIBTOP_BACKEND_H__
|
||||||
|
|
||||||
|
#include <glibtop.h>
|
||||||
|
#include <gobject/gobject.h>
|
||||||
|
|
||||||
|
BEGIN_LIBGTOP_DECLS
|
||||||
|
|
||||||
|
#define GLIBTOP_TYPE_BACKEND (glibtop_backend_get_type ())
|
||||||
|
#define GLIBTOP_BACKEND(backend) (G_TYPE_CHECK_INSTANCE_CAST ((backend), GLIBTOP_TYPE_BACKEND, glibtop_backend))
|
||||||
|
#define GLIBTOP_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLIBTOP_TYPE_BACKEND, glibtop_backend_class))
|
||||||
|
#define GLIBTOP_IS_BACKEND(backend) (G_TYPE_CHECK_INSTANCE_TYPE ((backend), GLIBTOP_TYPE_BACKEND))
|
||||||
|
#define GLIBTOP_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLIBTOP_TYPE_BACKEND))
|
||||||
|
#define GLIBTOP_BACKEND_GET_CLASS(backend)(G_TYPE_INSTANCE_GET_CLASS ((backend), GLIBTOP_TYPE_BACKEND, glibtop_backend_class))
|
||||||
|
|
||||||
|
#define GLIBTOP_BACKEND_TYPE(backend) (G_TYPE_FROM_INSTANCE (backend))
|
||||||
|
#define GLIBTOP_BACKEND_TYPE_NAME(backend)(g_type_name (GLIBTOP_BACKEND_TYPE (backend)))
|
||||||
|
|
||||||
|
/* --- typedefs & structures --- */
|
||||||
|
typedef struct _glibtop_backend glibtop_backend;
|
||||||
|
typedef struct _glibtop_backend_class glibtop_backend_class;
|
||||||
|
typedef struct _glibtop_backend_private glibtop_backend_private;
|
||||||
|
|
||||||
|
struct _glibtop_backend
|
||||||
|
{
|
||||||
|
GObject object;
|
||||||
|
|
||||||
|
/* <private> */
|
||||||
|
glibtop_backend_private *_priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _glibtop_backend_class
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType
|
||||||
|
glibtop_backend_get_type (void);
|
||||||
|
|
||||||
|
glibtop_backend *
|
||||||
|
glibtop_backend_open (const char *backend_name, u_int64_t features,
|
||||||
|
const char **backend_args, GError **error);
|
||||||
|
|
||||||
|
END_LIBGTOP_DECLS
|
||||||
|
|
||||||
|
#endif
|
@@ -29,7 +29,7 @@
|
|||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <gobject/gobject.h>
|
#include <gobject/gobject.h>
|
||||||
|
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
BEGIN_LIBGTOP_DECLS
|
BEGIN_LIBGTOP_DECLS
|
||||||
|
|
||||||
|
@@ -8,10 +8,9 @@ lib_LTLIBRARIES = libgtop.la
|
|||||||
|
|
||||||
noinst_LTLIBRARIES = libgtop_server.la
|
noinst_LTLIBRARIES = libgtop_server.la
|
||||||
|
|
||||||
libgtop_la_SOURCES = errors.c backend.c \
|
libgtop_la_SOURCES = errors.c glibtop-backend-info.c \
|
||||||
init-backends.c open-backend.c \
|
|
||||||
glibtop-client.c glibtop-server.c \
|
glibtop-client.c glibtop-server.c \
|
||||||
sysdeps-init.c
|
glibtop-backend.c sysdeps-init.c
|
||||||
|
|
||||||
libgtop_server_la_SOURCES = error.c xmalloc.c
|
libgtop_server_la_SOURCES = error.c xmalloc.c
|
||||||
|
|
||||||
|
@@ -1,93 +0,0 @@
|
|||||||
/* -*- 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 1.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>
|
|
||||||
#include <glibtop/global.h>
|
|
||||||
#include <glibtop/xmalloc.h>
|
|
||||||
|
|
||||||
#include <glibtop/backend.h>
|
|
||||||
|
|
||||||
static GHashTable *_glibtop_backend_list = NULL;
|
|
||||||
static long _glibtop_backend_nr = 0;
|
|
||||||
|
|
||||||
long
|
|
||||||
glibtop_register_backend (glibtop_backend_entry *entry)
|
|
||||||
{
|
|
||||||
long id;
|
|
||||||
|
|
||||||
if (!_glibtop_backend_list)
|
|
||||||
_glibtop_backend_list = g_hash_table_new (NULL, NULL);
|
|
||||||
|
|
||||||
id = ++_glibtop_backend_nr;
|
|
||||||
|
|
||||||
g_hash_table_insert (_glibtop_backend_list,
|
|
||||||
GINT_TO_POINTER (id),
|
|
||||||
entry);
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
glibtop_unregister_backend (long id)
|
|
||||||
{
|
|
||||||
g_hash_table_remove (_glibtop_backend_list,
|
|
||||||
GINT_TO_POINTER (id));
|
|
||||||
}
|
|
||||||
|
|
||||||
glibtop_backend_entry *
|
|
||||||
glibtop_backend_by_id (long id)
|
|
||||||
{
|
|
||||||
return g_hash_table_lookup (_glibtop_backend_list,
|
|
||||||
GINT_TO_POINTER (id));
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char *backend_name;
|
|
||||||
glibtop_backend_entry *entry;
|
|
||||||
} _find_by_name_param_t;
|
|
||||||
|
|
||||||
static void
|
|
||||||
find_by_name (gpointer key, gpointer value, gpointer user_data)
|
|
||||||
{
|
|
||||||
_find_by_name_param_t *param = (_find_by_name_param_t *) user_data;
|
|
||||||
glibtop_backend_entry *entry = (glibtop_backend_entry *) value;
|
|
||||||
|
|
||||||
if (!entry || !entry->name || param->entry)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!strcmp (entry->name, param->backend_name))
|
|
||||||
param->entry = entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
glibtop_backend_entry *
|
|
||||||
glibtop_backend_by_name (const char *backend_name)
|
|
||||||
{
|
|
||||||
_find_by_name_param_t param = { backend_name, NULL };
|
|
||||||
|
|
||||||
g_hash_table_foreach (_glibtop_backend_list,
|
|
||||||
find_by_name, ¶m);
|
|
||||||
|
|
||||||
return param.entry;
|
|
||||||
}
|
|
@@ -25,9 +25,12 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/global.h>
|
#include <glibtop/global.h>
|
||||||
#include <glibtop/xmalloc.h>
|
|
||||||
|
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
#include <glibtop/glibtop-backend-info.h>
|
||||||
|
|
||||||
|
static GHashTable *_glibtop_backend_list = NULL;
|
||||||
|
static long _glibtop_backend_nr = 0;
|
||||||
|
|
||||||
#if HAVE_LIBXML
|
#if HAVE_LIBXML
|
||||||
|
|
||||||
@@ -225,3 +228,63 @@ _glibtop_init_gmodule_backends (const char *directory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LIBXML */
|
#endif /* HAVE_LIBXML */
|
||||||
|
|
||||||
|
long
|
||||||
|
glibtop_register_backend (glibtop_backend_entry *entry)
|
||||||
|
{
|
||||||
|
long id;
|
||||||
|
|
||||||
|
if (!_glibtop_backend_list)
|
||||||
|
_glibtop_backend_list = g_hash_table_new (NULL, NULL);
|
||||||
|
|
||||||
|
id = ++_glibtop_backend_nr;
|
||||||
|
|
||||||
|
g_hash_table_insert (_glibtop_backend_list,
|
||||||
|
GINT_TO_POINTER (id),
|
||||||
|
entry);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
glibtop_unregister_backend (long id)
|
||||||
|
{
|
||||||
|
g_hash_table_remove (_glibtop_backend_list,
|
||||||
|
GINT_TO_POINTER (id));
|
||||||
|
}
|
||||||
|
|
||||||
|
glibtop_backend_entry *
|
||||||
|
glibtop_backend_by_id (long id)
|
||||||
|
{
|
||||||
|
return g_hash_table_lookup (_glibtop_backend_list,
|
||||||
|
GINT_TO_POINTER (id));
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *backend_name;
|
||||||
|
glibtop_backend_entry *entry;
|
||||||
|
} _find_by_name_param_t;
|
||||||
|
|
||||||
|
static void
|
||||||
|
find_by_name (gpointer key, gpointer value, gpointer user_data)
|
||||||
|
{
|
||||||
|
_find_by_name_param_t *param = (_find_by_name_param_t *) user_data;
|
||||||
|
glibtop_backend_entry *entry = (glibtop_backend_entry *) value;
|
||||||
|
|
||||||
|
if (!entry || !entry->name || param->entry)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!strcmp (entry->name, param->backend_name))
|
||||||
|
param->entry = entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
glibtop_backend_entry *
|
||||||
|
glibtop_backend_by_name (const char *backend_name)
|
||||||
|
{
|
||||||
|
_find_by_name_param_t param = { backend_name, NULL };
|
||||||
|
|
||||||
|
g_hash_table_foreach (_glibtop_backend_list,
|
||||||
|
find_by_name, ¶m);
|
||||||
|
|
||||||
|
return param.entry;
|
||||||
|
}
|
@@ -3,7 +3,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/* Copyright (C) 1998-99 Martin Baulig
|
/* Copyright (C) 1998-99 Martin Baulig
|
||||||
This file is part of LibGTop 1.0.
|
This file is part of LibGTop 2.0.
|
||||||
|
|
||||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||||
|
|
||||||
@@ -24,11 +24,90 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/global.h>
|
|
||||||
|
|
||||||
#include <glibtop/backend.h>
|
#include <gobject/gsignal.h>
|
||||||
|
#include <gobject/gvaluetypes.h>
|
||||||
|
|
||||||
#include <gmodule.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
#include <glibtop/glibtop-backend-info.h>
|
||||||
|
|
||||||
|
static void glibtop_backend_class_init (glibtop_backend_class *klass);
|
||||||
|
static void glibtop_backend_init (glibtop_backend *backend);
|
||||||
|
static void glibtop_backend_finalize (GObject *object);
|
||||||
|
|
||||||
|
static gpointer parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/* Internal data */
|
||||||
|
|
||||||
|
struct _glibtop_backend_private
|
||||||
|
{
|
||||||
|
const glibtop_backend_info *info;
|
||||||
|
|
||||||
|
glibtop_server *server;
|
||||||
|
glibtop_backend_module *module;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType
|
||||||
|
glibtop_backend_get_type (void)
|
||||||
|
{
|
||||||
|
static GType glibtop_backend_type = 0;
|
||||||
|
|
||||||
|
if (!glibtop_backend_type) {
|
||||||
|
static const GTypeInfo glibtop_backend_info = {
|
||||||
|
sizeof (glibtop_backend_class),
|
||||||
|
NULL, /* base_class_init */
|
||||||
|
NULL, /* base_class_finalize */
|
||||||
|
(GClassInitFunc) glibtop_backend_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (glibtop_backend),
|
||||||
|
16, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) glibtop_backend_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
glibtop_backend_type = g_type_register_static
|
||||||
|
(G_TYPE_OBJECT, "glibtop_backend", &glibtop_backend_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return glibtop_backend_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
glibtop_backend_class_init (glibtop_backend_class *class)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class;
|
||||||
|
|
||||||
|
gobject_class = (GObjectClass *) class;
|
||||||
|
|
||||||
|
parent_class = g_type_class_ref (G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
gobject_class->finalize = glibtop_backend_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
glibtop_backend_init (glibtop_backend *glibtop)
|
||||||
|
{
|
||||||
|
glibtop_backend_private *priv;
|
||||||
|
|
||||||
|
priv = g_new0 (glibtop_backend_private, 1);
|
||||||
|
glibtop->_priv = priv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
glibtop_backend_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
glibtop_backend *glibtop;
|
||||||
|
glibtop_backend_private *priv = NULL;
|
||||||
|
|
||||||
|
glibtop = GLIBTOP_BACKEND (object);
|
||||||
|
priv = glibtop->_priv;
|
||||||
|
|
||||||
|
g_free (priv);
|
||||||
|
|
||||||
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unload_module (gpointer data, gpointer user_data)
|
unload_module (gpointer data, gpointer user_data)
|
||||||
@@ -66,13 +145,15 @@ load_extra_libs (glibtop_backend_entry *entry, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glibtop_backend *
|
glibtop_backend *
|
||||||
glibtop_open_backend (const char *backend_name, u_int64_t features,
|
glibtop_backend_open (const char *backend_name, u_int64_t features,
|
||||||
const char **backend_args, GError **error)
|
const char **backend_args, GError **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;
|
||||||
|
|
||||||
|
glibtop_init_backends ();
|
||||||
|
|
||||||
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,
|
||||||
@@ -124,23 +205,23 @@ glibtop_open_backend (const char *backend_name, u_int64_t features,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
backend = g_new0 (glibtop_backend, 1);
|
backend = g_object_new (GLIBTOP_TYPE_BACKEND, NULL);
|
||||||
backend->_priv_module = entry->_priv;
|
|
||||||
backend->info = info;
|
|
||||||
|
|
||||||
backend->server = glibtop_server_new ();
|
backend->_priv->module = entry->_priv;
|
||||||
|
backend->_priv->info = info;
|
||||||
|
|
||||||
|
backend->_priv->server = glibtop_server_new ();
|
||||||
|
|
||||||
if (info->open) {
|
if (info->open) {
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = info->open (backend->server, backend, features, backend_args);
|
retval = info->open (backend->_priv->server, backend, features,
|
||||||
|
backend_args);
|
||||||
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");
|
||||||
|
|
||||||
glibtop_server_unref (backend->server);
|
g_object_unref (G_OBJECT (backend));
|
||||||
g_free (backend->_priv);
|
|
||||||
g_free (backend);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,4 +230,3 @@ glibtop_open_backend (const char *backend_name, u_int64_t features,
|
|||||||
|
|
||||||
return backend;
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
@@ -262,7 +262,7 @@ glibtop_client_open_backend (glibtop_client *client, const char *backend_name,
|
|||||||
|
|
||||||
g_return_val_if_fail (GLIBTOP_IS_CLIENT (client), NULL);
|
g_return_val_if_fail (GLIBTOP_IS_CLIENT (client), NULL);
|
||||||
|
|
||||||
backend = glibtop_open_backend (backend_name, features, backend_args,
|
backend = glibtop_backend_open (backend_name, features, backend_args,
|
||||||
&error);
|
&error);
|
||||||
if (!backend) {
|
if (!backend) {
|
||||||
glibtop_client_propagate_error (client, error);
|
glibtop_client_propagate_error (client, error);
|
||||||
@@ -280,7 +280,7 @@ glibtop_client_add_backend (glibtop_client *client,
|
|||||||
glibtop_backend *backend)
|
glibtop_backend *backend)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
||||||
g_return_if_fail (backend != NULL);
|
g_return_if_fail (GLIBTOP_IS_BACKEND (backend));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,6 +289,6 @@ glibtop_client_remove_backend (glibtop_client *client,
|
|||||||
glibtop_backend *backend)
|
glibtop_backend *backend)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
||||||
g_return_if_fail (backend != NULL);
|
g_return_if_fail (GLIBTOP_IS_BACKEND (backend));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/signal.h>
|
#include <glibtop/signal.h>
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/signal.h>
|
#include <glibtop/signal.h>
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/signal.h>
|
#include <glibtop/signal.h>
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/signal.h>
|
#include <glibtop/signal.h>
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/signal.h>
|
#include <glibtop/signal.h>
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/signal.h>
|
#include <glibtop/signal.h>
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/signal.h>
|
#include <glibtop/signal.h>
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/backend.h>
|
#include <glibtop/glibtop-backend.h>
|
||||||
|
|
||||||
#include <glibtop/cpu.h>
|
#include <glibtop/cpu.h>
|
||||||
|
|
||||||
@@ -38,8 +38,6 @@ main (int argc, char *argv [])
|
|||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
glibtop_init_backends ();
|
|
||||||
|
|
||||||
client = glibtop_client_new ();
|
client = glibtop_client_new ();
|
||||||
|
|
||||||
backend_common = glibtop_client_open_backend
|
backend_common = glibtop_client_open_backend
|
||||||
|
Reference in New Issue
Block a user