Removed. (glibtop_get_proc_args_*): This now takes a `glibtop_array'

1999-12-12  Martin Baulig  <martin@home-of-linux.org>

	* include/glibtop/procargs.h (glibtop_proc_args): Removed.
	(glibtop_get_proc_args_*): This now takes a `glibtop_array' parameter
	instead of a `glibtop_proc_args one and returns a `char **'.
This commit is contained in:
Martin Baulig
1999-12-19 14:37:49 +00:00
committed by Martin Baulig
parent da42214e86
commit 339e1f4557
8 changed files with 47 additions and 31 deletions

View File

@@ -1,3 +1,9 @@
1999-12-12 Martin Baulig <martin@home-of-linux.org>
* include/glibtop/procargs.h (glibtop_proc_args): Removed.
(glibtop_get_proc_args_*): This now takes a `glibtop_array' parameter
instead of a `glibtop_proc_args one and returns a `char **'.
1999-12-13 Martin Baulig <martin@home-of-linux.org>
* configure.in (LIBGTOP_LIBS): Put `-lgtop' after `-lgtop_common'.

View File

@@ -14,7 +14,7 @@ retval|proc_time|long(start_time,rtime,utime,stime,cutime,cstime,timeout,it_real
retval|proc_signal|ulong(signal[2],blocked[2],sigignore[2],sigcatch[2])|pid_t(pid)
retval|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,nwchan):string(wchan)|pid_t(pid)
retval|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_code,end_code,start_data,end_data,start_brk,end_brk,start_stack,start_mmap,arg_start,arg_end,env_start,env_end)|pid_t(pid)
char *|proc_args|ulong(size)|pid_t(pid):unsigned(max_len)
pointer(string)|proc_args|array|pid_t(pid)
array(glibtop_map_entry)|proc_map|array|pid_t(pid)
array(glibtop_mountentry)|@mountlist|array|int(all_fs)
retval|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string(mount_dir)

View File

@@ -51,6 +51,14 @@ typedef struct _glibtop_array glibtop_proclist;
typedef struct _glibtop_array glibtop_mountlist;
/* glibtop_proc_args */
#define GLIBTOP_PROC_ARGS_SIZE 0
#define GLIBTOP_MAX_PROC_ARGS 1
typedef struct _glibtop_array glibtop_proc_args;
/* glibtop_proc_map */
#define GLIBTOP_PROC_MAP_NUMBER GLIBTOP_ARRAY_NUMBER

View File

@@ -34,7 +34,7 @@
BEGIN_LIBGTOP_DECLS
#define glibtop_get_proc_args(proc_args) glibtop_get_proc_args_l(glibtop_global_server, pid)
#define glibtop_get_proc_args(array,pid) glibtop_get_proc_args_l(glibtop_global_server, array, pid)
#if GLIBTOP_SUID_PROC_ARGS
#define glibtop_get_proc_args_r glibtop_get_proc_args_p

View File

@@ -76,7 +76,7 @@ union _glibtop_union
glibtop_proc_signal proc_signal;
glibtop_proc_kernel proc_kernel;
glibtop_proc_segment proc_segment;
glibtop_proc_args proc_args;
glibtop_array proc_args;
glibtop_array proc_map;
glibtop_array mountlist;
glibtop_fsusage fsusage;

View File

@@ -113,7 +113,7 @@ sub output {
}
if ($retval =~ /^(array|pointer)\((.*)\)$/) {
$retval = "$2 *";
$retval = ($2 eq 'string') ? 'char **' : "$2 *";
}
$check_server_code = "\n";

View File

@@ -164,7 +164,7 @@ handle_parent_connection (int s)
memcpy (&pid, parameter, sizeof (pid_t));
ptr = glibtop_get_proc_args_l (server,
&resp->u.data.proc_args,
pid, 0);
pid);
do_output (s, resp, _offset_data (proc_args),
ptr ? resp->u.data.proc_args.size+1 : 0, ptr,
(ptr != NULL) ? 0 : -1);

View File

@@ -29,7 +29,7 @@
#include <glibtop_private.h>
static const unsigned long _glibtop_sysdeps_proc_args =
(1L << GLIBTOP_PROC_ARGS_SIZE);
(1L << GLIBTOP_ARRAY_NUMBER) + (1L << GLIBTOP_ARRAY_SIZE);
/* Init function. */
@@ -43,44 +43,46 @@ glibtop_init_proc_args_s (glibtop *server)
/* Provides detailed information about a process. */
char *
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len)
char **
glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid)
{
char buffer [BUFSIZ];
char *retval = NULL, *ptr;
size_t total;
int ret;
char *ptr = NULL, *pos, **ptrlist;
size_t count = 0, max_len, total;
int i, ret;
memset (buf, 0, sizeof (glibtop_proc_args));
memset (array, 0, sizeof (glibtop_array));
if (max_len > BUFSIZ)
retval = ptr = glibtop_malloc_r (server, max_len+1);
else
ptr = buffer;
if (!max_len)
max_len = BUFSIZ;
max_len = PAGE_SIZE;
ptr = glibtop_malloc_r (server, max_len + 1);
ret = glibtop_get_proc_data_proc_args_s (server, pid, ptr, max_len);
if (ret < 0) {
if (!retval) glibtop_free_r (server, retval);
glibtop_free_r (server, ptr);
return NULL;
}
total = ret;
ptr [total] = '\0';
if (retval) {
retval = glibtop_realloc_r (server, retval, total+1);
} else {
retval = glibtop_malloc_r (server, total+1);
memcpy (retval, buffer, total);
for (i = 0; i <= total; i++) {
if (ptr [i]) continue;
count++;
}
retval [total] = 0;
ptrlist = glibtop_calloc_r (server, count+1, sizeof (char *));
buf->size = total;
buf->flags = _glibtop_sysdeps_proc_args;
for (i = 0, pos = ptr; i < count; i++) {
ptrlist [i] = glibtop_strdup_r (server, pos);
pos += strlen (pos) + 1;
}
return retval;
ptrlist [count] = NULL;
glibtop_free_r (server, ptr);
array->number = count;
array->size = sizeof (char *);
array->flags = _glibtop_sysdeps_proc_args;
return ptrlist;
}