renamed all functions that implementing features to '__l'; we only emit
* lib/*.c: renamed all functions that implementing features to '__l'; we only emit code for those functions if the corresponding 'GLIBTOP_SUID_<feature>' has a positive value.
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
void *
|
||||
glibtop_call__r (glibtop *server, unsigned command, size_t send_size, void *send_buf,
|
||||
glibtop_call__l (glibtop *server, unsigned command, size_t send_size, void *send_buf,
|
||||
size_t recv_size, void *recv_buf)
|
||||
{
|
||||
glibtop_command *cmnd;
|
||||
@@ -42,11 +42,11 @@ glibtop_call__r (glibtop *server, unsigned command, size_t send_size, void *send
|
||||
cmnd->command = command;
|
||||
cmnd->size = send_size;
|
||||
|
||||
glibtop_write__r (server, sizeof (glibtop_command), cmnd);
|
||||
glibtop_write__r (server, send_size, send_buf);
|
||||
glibtop_read__r (server, recv_size, recv_buf);
|
||||
glibtop_write__l (server, sizeof (glibtop_command), cmnd);
|
||||
glibtop_write__l (server, send_size, send_buf);
|
||||
glibtop_read__l (server, recv_size, recv_buf);
|
||||
|
||||
ptr = glibtop_read_data__r (server);
|
||||
ptr = glibtop_read_data__l (server);
|
||||
|
||||
glibtop_free__r (server, cmnd);
|
||||
|
||||
|
10
lib/cpu.c
10
lib/cpu.c
@@ -19,14 +19,20 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/cpu.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_CPU
|
||||
|
||||
/* Provides information about cpu usage. */
|
||||
|
||||
void
|
||||
glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf)
|
||||
glibtop_get_cpu__l (glibtop *server, glibtop_cpu *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_CPU, 0, NULL, sizeof (glibtop_cpu), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_CPU, 0, NULL,
|
||||
sizeof (glibtop_cpu), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,11 +23,16 @@
|
||||
#include <glibtop/loadavg.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_LOADAVG
|
||||
|
||||
/* Provides load averange. */
|
||||
|
||||
void
|
||||
glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf)
|
||||
glibtop_get_loadavg__l (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_LOADAVG, 0, NULL, sizeof (glibtop_loadavg), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_LOADAVG, 0, NULL,
|
||||
sizeof (glibtop_loadavg), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -22,11 +22,16 @@
|
||||
#include <glibtop/mem.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_MEM
|
||||
|
||||
/* Provides information about memory usage. */
|
||||
|
||||
void
|
||||
glibtop_get_mem__r (glibtop *server, glibtop_mem *buf)
|
||||
glibtop_get_mem__l (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_MEM, 0, NULL, sizeof (glibtop_mem), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_MEM, 0, NULL,
|
||||
sizeof (glibtop_mem), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -22,11 +22,16 @@
|
||||
#include <glibtop/msg_limits.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_MSG_LIMITS
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf)
|
||||
glibtop_get_msg_limits__l (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, sizeof (glibtop_msg_limits), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL,
|
||||
sizeof (glibtop_msg_limits), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -53,7 +53,7 @@ glibtop_open (glibtop *server, const char *program_name)
|
||||
|
||||
sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION);
|
||||
|
||||
glibtop_read__r (server, strlen (version), buffer);
|
||||
glibtop_read__l (server, strlen (version), buffer);
|
||||
|
||||
if (memcmp (version, buffer, strlen (version)))
|
||||
glibtop_error__r (server, _("server version is not %s"), VERSION);
|
||||
|
@@ -23,13 +23,17 @@
|
||||
#include <glibtop/prockernel.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROC_KERNEL
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf,
|
||||
glibtop_get_proc_kernel__l (glibtop *server, glibtop_proc_kernel *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -22,11 +22,16 @@
|
||||
#include <glibtop/proclist.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
|
||||
/* Fetch list of currently running processes. */
|
||||
|
||||
unsigned *
|
||||
glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf)
|
||||
glibtop_get_proclist__l (glibtop *server, glibtop_proclist *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
return glibtop_call__r (server, GLIBTOP_CMND_PROCLIST, 0, NULL, sizeof (glibtop_proclist), buf);
|
||||
return glibtop_call__l (server, GLIBTOP_CMND_PROCLIST, 0, NULL,
|
||||
sizeof (glibtop_proclist), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,13 +23,17 @@
|
||||
#include <glibtop/procmem.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROC_MEM
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf,
|
||||
glibtop_get_proc_mem__l (glibtop *server, glibtop_proc_mem *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,13 +23,17 @@
|
||||
#include <glibtop/procsegment.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROC_SEGMENT
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf,
|
||||
glibtop_get_proc_segment__l (glibtop *server, glibtop_proc_segment *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,13 +23,17 @@
|
||||
#include <glibtop/procsignal.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROC_SIGNAL
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf,
|
||||
glibtop_get_proc_signal__l (glibtop *server, glibtop_proc_signal *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,13 +23,17 @@
|
||||
#include <glibtop/procstate.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROC_STATE
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf,
|
||||
glibtop_get_proc_state__l (glibtop *server, glibtop_proc_state *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,13 +23,17 @@
|
||||
#include <glibtop/proctime.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROC_TIME
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf,
|
||||
glibtop_get_proc_time__l (glibtop *server, glibtop_proc_time *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,13 +23,17 @@
|
||||
#include <glibtop/procuid.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_PROC_UID
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf,
|
||||
glibtop_get_proc_uid__l (glibtop *server, glibtop_proc_uid *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -24,7 +24,7 @@
|
||||
/* Reads some data from server. */
|
||||
|
||||
void
|
||||
glibtop_read__r (glibtop *server, size_t size, void *buf)
|
||||
glibtop_read__l (glibtop *server, size_t size, void *buf)
|
||||
{
|
||||
size_t ssize;
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
/* Reads some data from server. */
|
||||
|
||||
void *
|
||||
glibtop_read_data__r (glibtop *server)
|
||||
glibtop_read_data__l (glibtop *server)
|
||||
{
|
||||
size_t size;
|
||||
void *ptr;
|
||||
@@ -33,7 +33,8 @@ glibtop_read_data__r (glibtop *server)
|
||||
glibtop_init__r (&server);
|
||||
|
||||
if (read (server->input [0], &size, sizeof (size_t)) < 0)
|
||||
glibtop_error__r (server, _("read data size: %s"), strerror (errno));
|
||||
glibtop_error__r (server, _("read data size: %s"),
|
||||
strerror (errno));
|
||||
|
||||
if (!size) return NULL;
|
||||
|
||||
@@ -42,7 +43,8 @@ glibtop_read_data__r (glibtop *server)
|
||||
ptr = glibtop_malloc__r (server, size);
|
||||
|
||||
if (read (server->input [0], ptr, size) < 0)
|
||||
glibtop_error__r (server, _("read data %d bytes: %s"), size, strerror (errno));
|
||||
glibtop_error__r (server, _("read data %d bytes: %s"),
|
||||
size, strerror (errno));
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
@@ -22,11 +22,16 @@
|
||||
#include <glibtop/sem_limits.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_SEM_LIMITS
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf)
|
||||
glibtop_get_sem_limits__l (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, sizeof (glibtop_sem_limits), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL,
|
||||
sizeof (glibtop_sem_limits), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -22,11 +22,16 @@
|
||||
#include <glibtop/shm_limits.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_SHM_LIMITS
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf)
|
||||
glibtop_get_shm_limits__l (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, sizeof (glibtop_shm_limits), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL,
|
||||
sizeof (glibtop_shm_limits), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -22,11 +22,16 @@
|
||||
#include <glibtop/swap.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_SWAP
|
||||
|
||||
/* Provides information about swap usage. */
|
||||
|
||||
void
|
||||
glibtop_get_swap__r (glibtop *server, glibtop_swap *buf)
|
||||
glibtop_get_swap__l (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_SWAP, 0, NULL, sizeof (glibtop_swap), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_SWAP, 0, NULL,
|
||||
sizeof (glibtop_swap), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -23,11 +23,16 @@
|
||||
#include <glibtop/uptime.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#if GLIBTOP_SUID_UPTIME
|
||||
|
||||
/* Provides uptime and idle time. */
|
||||
|
||||
void
|
||||
glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf)
|
||||
glibtop_get_uptime__l (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_UPTIME, 0, NULL, sizeof (glibtop_uptime), buf);
|
||||
glibtop_call__l (server, GLIBTOP_CMND_UPTIME, 0, NULL,
|
||||
sizeof (glibtop_uptime), buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -24,7 +24,7 @@
|
||||
/* Writes some data to server. */
|
||||
|
||||
void
|
||||
glibtop_write__r (glibtop *server, size_t size, void *buf)
|
||||
glibtop_write__l (glibtop *server, size_t size, void *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
|
||||
|
Reference in New Issue
Block a user