New fields error_method',
sysdeps' and `required'. I added an improved
1998-08-07 Martin Baulig <martin@home-of-linux.org> * glibtop.h (_glibtop): New fields `error_method', `sysdeps' and `required'. I added an improved error handling: the client can tell the libraries which fields are absolutely required for each features and if it fails to set one of them, this will create an error which is handled depending upon the `error_method'. * include/glibtop/open.h: Define some constants for `error_method'. * lib/sysdeps.c (glibtop_get_sysdeps_r): No longer actually call any sysdeps function, it now simply copies `server->sysdeps'. (_glibtop_init_hook_s): Added. List of functions to be called during `glibtop_init_s' set to `glibtop_init_<no-suid-feature>_s'. * include/glibtop/sysdeps.h (<glibtop/union.h>): Removed. (glibtop_init_func_t): New typedef. (_glibtop_init_hook_s): Added. * sysdeps/linux/*.c (glibtop_init_<feature>_s): New functions. (glibtop_get_proc_*): Zero is now a valid pid. * sysdeps/kernel/*.c (glibtop_init_<feature>_s): New functions. (glibtop_get_proc_*): Zero is now a valid pid. 1998-08-06 Martin Baulig <martin@home-of-linux.org>
This commit is contained in:
committed by
Martin Baulig
parent
09e1353d0d
commit
4b3fcf149a
44
lib/init.c
44
lib/init.c
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#ifndef DEFAULT_PORT
|
||||
@@ -30,7 +31,6 @@
|
||||
static glibtop _glibtop_global_server;
|
||||
glibtop *glibtop_global_server = &_glibtop_global_server;
|
||||
|
||||
|
||||
void
|
||||
_init_server (glibtop *server, const unsigned features)
|
||||
{
|
||||
@@ -109,7 +109,7 @@ _init_server (glibtop *server, const unsigned features)
|
||||
|
||||
/* Override default. */
|
||||
if (server->server_host)
|
||||
glibtop_free_r (server, (char *) server->server_host);
|
||||
glibtop_free_r (server, server->server_host);
|
||||
|
||||
server->server_host = glibtop_strdup_r
|
||||
(server, temp+1);
|
||||
@@ -193,19 +193,35 @@ glibtop_init_r (glibtop **server_ptr, const unsigned long features,
|
||||
}
|
||||
|
||||
glibtop *
|
||||
glibtop_init_s (glibtop **server, const unsigned long features,
|
||||
glibtop_init_s (glibtop **server_ptr, const unsigned long features,
|
||||
const unsigned flags)
|
||||
{
|
||||
if (*server != NULL)
|
||||
return *server;
|
||||
|
||||
fprintf (stderr, "DEBUG: %s (%d)\n", __FILE__, __LINE__);
|
||||
|
||||
if (glibtop_global_server == NULL) {
|
||||
glibtop_global_server = &_glibtop_global_server;
|
||||
glibtop_open_s (glibtop_global_server, "glibtop",
|
||||
features, flags);
|
||||
}
|
||||
glibtop *server;
|
||||
glibtop_init_func_t *init_fkt;
|
||||
|
||||
return *server = glibtop_global_server;
|
||||
if (server_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (*server_ptr == NULL)
|
||||
*server_ptr = glibtop_global_server;
|
||||
|
||||
server = *server_ptr;
|
||||
|
||||
/* Should we do the initialization? */
|
||||
|
||||
if (flags & GLIBTOP_INIT_NO_INIT)
|
||||
return server;
|
||||
|
||||
/* Do the initialization, but only if not already initialized. */
|
||||
|
||||
if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
|
||||
glibtop_open_s (server, "glibtop", features, flags);
|
||||
|
||||
for (init_fkt = _glibtop_init_hook_s; *init_fkt; init_fkt++)
|
||||
(*init_fkt) (server);
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_INIT;
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
Reference in New Issue
Block a user