removed #if's - we now decide at runtime whether to use the server or to
* lib/*.c: removed #if's - we now decide at runtime whether to use the server or to call the appropriate function for the sysdeps directory.
This commit is contained in:
@@ -33,7 +33,7 @@ glibtop_call__l (glibtop *server, unsigned command, size_t send_size, void *send
|
|||||||
glibtop_command *cmnd;
|
glibtop_command *cmnd;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, 0, 0);
|
||||||
|
|
||||||
cmnd = glibtop_calloc__r (server, 1, sizeof (glibtop_command));
|
cmnd = glibtop_calloc__r (server, 1, sizeof (glibtop_command));
|
||||||
|
|
||||||
|
11
lib/cpu.c
11
lib/cpu.c
@@ -23,16 +23,17 @@
|
|||||||
#include <glibtop/cpu.h>
|
#include <glibtop/cpu.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_CPU
|
|
||||||
|
|
||||||
/* Provides information about cpu usage. */
|
/* Provides information about cpu usage. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_cpu__l (glibtop *server, glibtop_cpu *buf)
|
glibtop_get_cpu__l (glibtop *server, glibtop_cpu *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_CPU, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_CPU) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_CPU, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_CPU, 0, NULL,
|
||||||
sizeof (glibtop_cpu), buf);
|
sizeof (glibtop_cpu), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_cpu__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -26,14 +26,16 @@ static glibtop _glibtop_global_server;
|
|||||||
glibtop *glibtop_global_server = NULL;
|
glibtop *glibtop_global_server = NULL;
|
||||||
|
|
||||||
glibtop *
|
glibtop *
|
||||||
glibtop_init__r (glibtop **server)
|
glibtop_init__r (glibtop **server, const unsigned long features,
|
||||||
|
const unsigned flags)
|
||||||
{
|
{
|
||||||
if (*server != NULL)
|
if (*server != NULL)
|
||||||
return *server;
|
return *server;
|
||||||
|
|
||||||
if (glibtop_global_server == NULL) {
|
if (glibtop_global_server == NULL) {
|
||||||
glibtop_global_server = &_glibtop_global_server;
|
glibtop_global_server = &_glibtop_global_server;
|
||||||
glibtop_open (glibtop_global_server, "glibtop");
|
glibtop_open (glibtop_global_server, "glibtop",
|
||||||
|
features, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *server = glibtop_global_server;
|
return *server = glibtop_global_server;
|
||||||
|
@@ -23,16 +23,17 @@
|
|||||||
#include <glibtop/loadavg.h>
|
#include <glibtop/loadavg.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_LOADAVG
|
|
||||||
|
|
||||||
/* Provides load averange. */
|
/* Provides load averange. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_loadavg__l (glibtop *server, glibtop_loadavg *buf)
|
glibtop_get_loadavg__l (glibtop *server, glibtop_loadavg *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_LOADAVG) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_LOADAVG, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_LOADAVG, 0, NULL,
|
||||||
sizeof (glibtop_loadavg), buf);
|
sizeof (glibtop_loadavg), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_loadavg__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
11
lib/mem.c
11
lib/mem.c
@@ -22,16 +22,17 @@
|
|||||||
#include <glibtop/mem.h>
|
#include <glibtop/mem.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_MEM
|
|
||||||
|
|
||||||
/* Provides information about memory usage. */
|
/* Provides information about memory usage. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_mem__l (glibtop *server, glibtop_mem *buf)
|
glibtop_get_mem__l (glibtop *server, glibtop_mem *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_MEM, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_MEM) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_MEM, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_MEM, 0, NULL,
|
||||||
sizeof (glibtop_mem), buf);
|
sizeof (glibtop_mem), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_mem__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -22,16 +22,17 @@
|
|||||||
#include <glibtop/msg_limits.h>
|
#include <glibtop/msg_limits.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_MSG_LIMITS
|
|
||||||
|
|
||||||
/* Provides information about sysv ipc limits. */
|
/* Provides information about sysv ipc limits. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_msg_limits__l (glibtop *server, glibtop_msg_limits *buf)
|
glibtop_get_msg_limits__l (glibtop *server, glibtop_msg_limits *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_MSG_LIMITS) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL,
|
||||||
sizeof (glibtop_msg_limits), buf);
|
sizeof (glibtop_msg_limits), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_msg_limits__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
78
lib/open.c
78
lib/open.c
@@ -19,19 +19,80 @@
|
|||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include <glibtop.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
|
#include <glibtop/xmalloc.h>
|
||||||
|
|
||||||
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
|
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_open (glibtop *server, const char *program_name)
|
glibtop_open (glibtop *server, const char *program_name,
|
||||||
|
const unsigned long features, const unsigned flags)
|
||||||
{
|
{
|
||||||
char version [BUFSIZ], buffer [BUFSIZ];
|
char version [BUFSIZ], buffer [BUFSIZ];
|
||||||
|
char *server_command, *server_rsh, *temp;
|
||||||
|
char *server_host, *server_user;
|
||||||
|
|
||||||
memset (server, 0, sizeof (glibtop));
|
memset (server, 0, sizeof (glibtop));
|
||||||
|
|
||||||
server->name = program_name;
|
server->name = program_name;
|
||||||
|
|
||||||
|
/* Try to get data from environment. */
|
||||||
|
|
||||||
|
temp = getenv ("LIBGTOP_SERVER") ?
|
||||||
|
getenv ("LIBGTOP_SERVER") : GTOP_SERVER;
|
||||||
|
|
||||||
|
server_command = glibtop_malloc__r (server, strlen (temp) + 1);
|
||||||
|
|
||||||
|
strcpy (server_command, temp);
|
||||||
|
|
||||||
|
temp = getenv ("LIBGTOP_RSH") ?
|
||||||
|
getenv ("LIBGTOP_RSH") : "rsh";
|
||||||
|
|
||||||
|
server_rsh = glibtop_malloc__r (server, strlen (temp) + 1);
|
||||||
|
|
||||||
|
strcpy (server_rsh, temp);
|
||||||
|
|
||||||
|
/* Extract host and user information. */
|
||||||
|
|
||||||
|
temp = strstr (server_command, ":");
|
||||||
|
|
||||||
|
if (temp) {
|
||||||
|
*temp = 0;
|
||||||
|
server_host = server_command;
|
||||||
|
server_command = temp+1;
|
||||||
|
|
||||||
|
temp = strstr (server_host, "@");
|
||||||
|
|
||||||
|
if (temp) {
|
||||||
|
*temp = 0;
|
||||||
|
server_user = server_host;
|
||||||
|
server_host = temp+1;
|
||||||
|
} else {
|
||||||
|
server_user = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
server_host = NULL;
|
||||||
|
server_user = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store everything in `server'. */
|
||||||
|
|
||||||
|
server->server_command = server_command;
|
||||||
|
server->server_host = server_host;
|
||||||
|
server->server_user = server_user;
|
||||||
|
server->server_rsh = server_rsh;
|
||||||
|
|
||||||
|
/* Get server features. */
|
||||||
|
|
||||||
|
if (server->server_host)
|
||||||
|
glibtop_error__r (server, _("Remote server not yet supported by library\n"));
|
||||||
|
|
||||||
|
server->features = glibtop_server_features;
|
||||||
|
|
||||||
|
/* Fork and exec server. */
|
||||||
|
|
||||||
if (pipe (server->input) || pipe (server->output))
|
if (pipe (server->input) || pipe (server->output))
|
||||||
glibtop_error__r (server, _("cannot make a pipe: %s\n"), strerror (errno));
|
glibtop_error__r (server, _("cannot make a pipe: %s\n"), strerror (errno));
|
||||||
|
|
||||||
@@ -44,7 +105,20 @@ glibtop_open (glibtop *server, const char *program_name)
|
|||||||
close (server->input [0]); close (server->output [1]);
|
close (server->input [0]); close (server->output [1]);
|
||||||
dup2 (server->input [1], 1); /* dup2 (server->input [1], 2); */
|
dup2 (server->input [1], 1); /* dup2 (server->input [1], 2); */
|
||||||
dup2 (server->output [0], 0);
|
dup2 (server->output [0], 0);
|
||||||
execl (GTOP_SERVER, NULL);
|
|
||||||
|
if (server_host) {
|
||||||
|
if (server_user) {
|
||||||
|
execl (server->server_rsh, "gtop_server", "-l",
|
||||||
|
server->server_user, server->server_host,
|
||||||
|
server->server_command, NULL);
|
||||||
|
} else {
|
||||||
|
execl (server->server_rsh, "gtop_server",
|
||||||
|
server->server_host, server_command, NULL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
execl (server->server_command, "gtop_server", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
_exit (2);
|
_exit (2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,17 +23,18 @@
|
|||||||
#include <glibtop/prockernel.h>
|
#include <glibtop/prockernel.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROC_KERNEL
|
|
||||||
|
|
||||||
/* Provides detailed information about a process. */
|
/* Provides detailed information about a process. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_proc_kernel__l (glibtop *server, glibtop_proc_kernel *buf,
|
glibtop_get_proc_kernel__l (glibtop *server, glibtop_proc_kernel *buf,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROC_KERNEL) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t),
|
glibtop_call__l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t),
|
||||||
&pid, sizeof (glibtop_proc_kernel), buf);
|
&pid, sizeof (glibtop_proc_kernel), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_proc_kernel__r (server, buf, pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -22,16 +22,17 @@
|
|||||||
#include <glibtop/proclist.h>
|
#include <glibtop/proclist.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROCLIST
|
|
||||||
|
|
||||||
/* Fetch list of currently running processes. */
|
/* Fetch list of currently running processes. */
|
||||||
|
|
||||||
unsigned *
|
unsigned *
|
||||||
glibtop_get_proclist__l (glibtop *server, glibtop_proclist *buf)
|
glibtop_get_proclist__l (glibtop *server, glibtop_proclist *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROCLIST, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROCLIST) {
|
||||||
return glibtop_call__l (server, GLIBTOP_CMND_PROCLIST, 0, NULL,
|
return glibtop_call__l (server, GLIBTOP_CMND_PROCLIST, 0, NULL,
|
||||||
sizeof (glibtop_proclist), buf);
|
sizeof (glibtop_proclist), buf);
|
||||||
|
} else {
|
||||||
|
return glibtop_get_proclist__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -23,17 +23,18 @@
|
|||||||
#include <glibtop/procmem.h>
|
#include <glibtop/procmem.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROC_MEM
|
|
||||||
|
|
||||||
/* Provides detailed information about a process. */
|
/* Provides detailed information about a process. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_proc_mem__l (glibtop *server, glibtop_proc_mem *buf,
|
glibtop_get_proc_mem__l (glibtop *server, glibtop_proc_mem *buf,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_MEM, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROC_MEM) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t),
|
glibtop_call__l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t),
|
||||||
&pid, sizeof (glibtop_proc_mem), buf);
|
&pid, sizeof (glibtop_proc_mem), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_proc_mem__r (server, buf, pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -23,17 +23,18 @@
|
|||||||
#include <glibtop/procsegment.h>
|
#include <glibtop/procsegment.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROC_SEGMENT
|
|
||||||
|
|
||||||
/* Provides detailed information about a process. */
|
/* Provides detailed information about a process. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_proc_segment__l (glibtop *server, glibtop_proc_segment *buf,
|
glibtop_get_proc_segment__l (glibtop *server, glibtop_proc_segment *buf,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROC_SEGMENT) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t),
|
glibtop_call__l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t),
|
||||||
&pid, sizeof (glibtop_proc_segment), buf);
|
&pid, sizeof (glibtop_proc_segment), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_proc_segment__r (server, buf, pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -23,17 +23,18 @@
|
|||||||
#include <glibtop/procsignal.h>
|
#include <glibtop/procsignal.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROC_SIGNAL
|
|
||||||
|
|
||||||
/* Provides detailed information about a process. */
|
/* Provides detailed information about a process. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_proc_signal__l (glibtop *server, glibtop_proc_signal *buf,
|
glibtop_get_proc_signal__l (glibtop *server, glibtop_proc_signal *buf,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROC_SIGNAL) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t),
|
glibtop_call__l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t),
|
||||||
&pid, sizeof (glibtop_proc_signal), buf);
|
&pid, sizeof (glibtop_proc_signal), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_proc_signal__r (server, buf, pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -23,17 +23,18 @@
|
|||||||
#include <glibtop/procstate.h>
|
#include <glibtop/procstate.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROC_STATE
|
|
||||||
|
|
||||||
/* Provides detailed information about a process. */
|
/* Provides detailed information about a process. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_proc_state__l (glibtop *server, glibtop_proc_state *buf,
|
glibtop_get_proc_state__l (glibtop *server, glibtop_proc_state *buf,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROC_STATE) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t),
|
glibtop_call__l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t),
|
||||||
&pid, sizeof (glibtop_proc_state), buf);
|
&pid, sizeof (glibtop_proc_state), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_proc_state__r (server, buf, pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -23,17 +23,18 @@
|
|||||||
#include <glibtop/proctime.h>
|
#include <glibtop/proctime.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROC_TIME
|
|
||||||
|
|
||||||
/* Provides detailed information about a process. */
|
/* Provides detailed information about a process. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_proc_time__l (glibtop *server, glibtop_proc_time *buf,
|
glibtop_get_proc_time__l (glibtop *server, glibtop_proc_time *buf,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROC_TIME) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t),
|
glibtop_call__l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t),
|
||||||
&pid, sizeof (glibtop_proc_time), buf);
|
&pid, sizeof (glibtop_proc_time), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_proc_time__r (server, buf, pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -23,17 +23,18 @@
|
|||||||
#include <glibtop/procuid.h>
|
#include <glibtop/procuid.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_PROC_UID
|
|
||||||
|
|
||||||
/* Provides detailed information about a process. */
|
/* Provides detailed information about a process. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_proc_uid__l (glibtop *server, glibtop_proc_uid *buf,
|
glibtop_get_proc_uid__l (glibtop *server, glibtop_proc_uid *buf,
|
||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_UID, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_PROC_UID) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t),
|
glibtop_call__l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t),
|
||||||
&pid, sizeof (glibtop_proc_uid), buf);
|
&pid, sizeof (glibtop_proc_uid), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_proc_uid__r (server, buf, pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -28,7 +28,7 @@ glibtop_read__l (glibtop *server, size_t size, void *buf)
|
|||||||
{
|
{
|
||||||
size_t ssize;
|
size_t ssize;
|
||||||
|
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, 0, 0);
|
||||||
|
|
||||||
if (read (server->input [0], &ssize, sizeof (size_t)) < 0)
|
if (read (server->input [0], &ssize, sizeof (size_t)) < 0)
|
||||||
glibtop_error__r (server, _("read size: %s"), strerror (errno));
|
glibtop_error__r (server, _("read size: %s"), strerror (errno));
|
||||||
|
@@ -30,7 +30,7 @@ glibtop_read_data__l (glibtop *server)
|
|||||||
size_t size;
|
size_t size;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, 0, 0);
|
||||||
|
|
||||||
if (read (server->input [0], &size, sizeof (size_t)) < 0)
|
if (read (server->input [0], &size, sizeof (size_t)) < 0)
|
||||||
glibtop_error__r (server, _("read data size: %s"),
|
glibtop_error__r (server, _("read data size: %s"),
|
||||||
@@ -38,8 +38,6 @@ glibtop_read_data__l (glibtop *server)
|
|||||||
|
|
||||||
if (!size) return NULL;
|
if (!size) return NULL;
|
||||||
|
|
||||||
fprintf (stderr, "Server has %d bytes of data.\n", size);
|
|
||||||
|
|
||||||
ptr = glibtop_malloc__r (server, size);
|
ptr = glibtop_malloc__r (server, size);
|
||||||
|
|
||||||
if (read (server->input [0], ptr, size) < 0)
|
if (read (server->input [0], ptr, size) < 0)
|
||||||
|
@@ -22,16 +22,17 @@
|
|||||||
#include <glibtop/sem_limits.h>
|
#include <glibtop/sem_limits.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_SEM_LIMITS
|
|
||||||
|
|
||||||
/* Provides information about sysv ipc limits. */
|
/* Provides information about sysv ipc limits. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_sem_limits__l (glibtop *server, glibtop_sem_limits *buf)
|
glibtop_get_sem_limits__l (glibtop *server, glibtop_sem_limits *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_SEM_LIMITS) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL,
|
||||||
sizeof (glibtop_sem_limits), buf);
|
sizeof (glibtop_sem_limits), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_sem_limits__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -22,16 +22,17 @@
|
|||||||
#include <glibtop/shm_limits.h>
|
#include <glibtop/shm_limits.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_SHM_LIMITS
|
|
||||||
|
|
||||||
/* Provides information about sysv ipc limits. */
|
/* Provides information about sysv ipc limits. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_shm_limits__l (glibtop *server, glibtop_shm_limits *buf)
|
glibtop_get_shm_limits__l (glibtop *server, glibtop_shm_limits *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_SHM_LIMITS) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL,
|
||||||
sizeof (glibtop_shm_limits), buf);
|
sizeof (glibtop_shm_limits), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_shm_limits__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
11
lib/swap.c
11
lib/swap.c
@@ -22,16 +22,17 @@
|
|||||||
#include <glibtop/swap.h>
|
#include <glibtop/swap.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_SWAP
|
|
||||||
|
|
||||||
/* Provides information about swap usage. */
|
/* Provides information about swap usage. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_swap__l (glibtop *server, glibtop_swap *buf)
|
glibtop_get_swap__l (glibtop *server, glibtop_swap *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_SWAP, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_SWAP) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_SWAP, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_SWAP, 0, NULL,
|
||||||
sizeof (glibtop_swap), buf);
|
sizeof (glibtop_swap), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_swap__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
11
lib/uptime.c
11
lib/uptime.c
@@ -23,16 +23,17 @@
|
|||||||
#include <glibtop/uptime.h>
|
#include <glibtop/uptime.h>
|
||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
|
|
||||||
#if GLIBTOP_SUID_UPTIME
|
|
||||||
|
|
||||||
/* Provides uptime and idle time. */
|
/* Provides uptime and idle time. */
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_get_uptime__l (glibtop *server, glibtop_uptime *buf)
|
glibtop_get_uptime__l (glibtop *server, glibtop_uptime *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, GLIBTOP_SYSDEPS_UPTIME, 0);
|
||||||
|
|
||||||
|
if (server->features & GLIBTOP_SYSDEPS_UPTIME) {
|
||||||
glibtop_call__l (server, GLIBTOP_CMND_UPTIME, 0, NULL,
|
glibtop_call__l (server, GLIBTOP_CMND_UPTIME, 0, NULL,
|
||||||
sizeof (glibtop_uptime), buf);
|
sizeof (glibtop_uptime), buf);
|
||||||
|
} else {
|
||||||
|
glibtop_get_uptime__r (server, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
void
|
void
|
||||||
glibtop_write__l (glibtop *server, size_t size, void *buf)
|
glibtop_write__l (glibtop *server, size_t size, void *buf)
|
||||||
{
|
{
|
||||||
glibtop_init__r (&server);
|
glibtop_init__r (&server, 0, 0);
|
||||||
|
|
||||||
if (write (server->output [1], &size, sizeof (size_t)) < 0)
|
if (write (server->output [1], &size, sizeof (size_t)) < 0)
|
||||||
glibtop_error__r (server, _("write size: %s"), strerror (errno));
|
glibtop_error__r (server, _("write size: %s"), strerror (errno));
|
||||||
|
Reference in New Issue
Block a user