Added file to repository. Provides glibtop_get_proc_argv*() for system
* Makefile.am: * procargs.c: (split_args0), (glibtop_get_proc_argv_l), (glibtop_get_proc_argv_p), (glibtop_get_proc_argv_s): Added file to repository. Provides glibtop_get_proc_argv*() for system dependant glibtop_get_proc_args*().
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2004-07-07 Benoît Dejean <tazforever@dlfp.org>
|
||||
|
||||
* Makefile.am:
|
||||
* procargs.c: (split_args0), (glibtop_get_proc_argv_l),
|
||||
(glibtop_get_proc_argv_p), (glibtop_get_proc_argv_s): Added file to
|
||||
repository. Provides glibtop_get_proc_argv*() for system dependant
|
||||
glibtop_get_proc_args*().
|
||||
|
||||
2004-06-18 Benoît Dejean <tazforever@dlfp.org>
|
||||
|
||||
* error.c: (print_server_name), (glibtop_error_r),
|
||||
|
@@ -16,6 +16,7 @@ noinst_LTLIBRARIES = libgtop_common-2.0.la libgtop_suid_common-2.0.la
|
||||
libgtop_common_2_0_la_SOURCES = error.c gnuslib.c \
|
||||
fsusage.c \
|
||||
mountlist.c mountlist.h \
|
||||
procargs.c \
|
||||
$(inodedb_SRCLIST)
|
||||
|
||||
libgtop_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||
|
66
sysdeps/common/procargs.c
Normal file
66
sysdeps/common/procargs.c
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <glibtop/procargs.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
Splitting args0
|
||||
* args0 [......0.. ....0.........0]
|
||||
* Returned value must be free with g_strfreev
|
||||
* args0 is g_free()d
|
||||
*/
|
||||
static char **
|
||||
split_args0(const char * const args0, size_t size)
|
||||
{
|
||||
GPtrArray *argv = g_ptr_array_new();
|
||||
const char *arg;
|
||||
|
||||
/* remember that if there were no args, args0 == NULL and size == 0 */
|
||||
for (arg = args0; arg < (args0 + size); arg += strlen(arg) + 1) {
|
||||
g_ptr_array_add(argv, g_strdup(arg));
|
||||
}
|
||||
|
||||
g_ptr_array_add(argv, NULL);
|
||||
|
||||
g_free((void* /* remove constness */) args0);
|
||||
|
||||
return (char**) g_ptr_array_free(argv, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* public functions
|
||||
*/
|
||||
|
||||
char **
|
||||
glibtop_get_proc_argv_l (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
const char * const args0 = glibtop_get_proc_args_l(server, buf, pid, max_len);
|
||||
return split_args0(args0, buf->size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if GLIBTOP_SUID_PROC_ARGS
|
||||
|
||||
char **
|
||||
glibtop_get_proc_argv_p (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
const char * const args0 = glibtop_get_proc_args_p(server, buf, pid, max_len);
|
||||
return split_args0(args0, buf->size);
|
||||
}
|
||||
|
||||
#else /* !GLIBTOP_SUID_PROC_ARGS */
|
||||
|
||||
char **
|
||||
glibtop_get_proc_argv_s (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
const char * const args0 = glibtop_get_proc_args_s(server, buf, pid, max_len);
|
||||
return split_args0(args0, buf->size);
|
||||
}
|
||||
#endif /* GLIBTOP_SUID_PROC_ARGS */
|
Reference in New Issue
Block a user