Changed format of this file to support multiple arguments to be passed to
1998-08-09 Martin Baulig <martin@home-of-linux.org> * features.def: Changed format of this file to support multiple arguments to be passed to a function. * include/glibtop/proclist.h: `glibtop_get_proclist' now takes two more arguments `method' and `param'.
This commit is contained in:
committed by
Martin Baulig
parent
b4038c9828
commit
fd95ab60a4
@@ -1,3 +1,11 @@
|
||||
1998-08-09 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* features.def: Changed format of this file to support multiple
|
||||
arguments to be passed to a function.
|
||||
|
||||
* include/glibtop/proclist.h: `glibtop_get_proclist' now takes two
|
||||
more arguments `method' and `param'.
|
||||
|
||||
1998-08-07 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/freebsd/ChangeLog: New file.
|
||||
|
@@ -190,7 +190,7 @@ main (int argc, char *argv [])
|
||||
|
||||
printf ("\n");
|
||||
|
||||
ptr = glibtop_get_proclist (&data.proclist);
|
||||
ptr = glibtop_get_proclist (&data.proclist, 0, 0);
|
||||
|
||||
printf ("Proclist (0x%08lx): %lu, %lu, %lu\n",
|
||||
(unsigned long) data.proclist.flags,
|
||||
|
@@ -67,7 +67,7 @@ main (int argc, char *argv [])
|
||||
|
||||
printf ("\n");
|
||||
|
||||
ptr = glibtop_get_proclist (&proclist);
|
||||
ptr = glibtop_get_proclist (&proclist, 0, 0);
|
||||
|
||||
printf ("Proclist (0x%08lx): %lu, %lu, %lu\n",
|
||||
(unsigned long) data.proclist.flags,
|
||||
|
20
features.def
20
features.def
@@ -6,13 +6,13 @@ void|loadavg|double(loadavg[0],loadavg[1],loadavg[2])
|
||||
void|shm_limits|ulong(shmmax,shmmin,shmmni,shmseg,shmall)
|
||||
void|msg_limits|ulong(msgpool,msgmap,msgmax,msgmnb,msgmni,msgssz,msgtql)
|
||||
void|sem_limits|ulong(semmap,semmni,semmns,semmnu,semmsl,semopm,semume,semusz,semvmx,semaem)
|
||||
unsigned *|proclist|ulong(number,size,total)
|
||||
void|proc_state|str(cmd):char(state):ulong(uid,gid)|pid_t|pid
|
||||
void|proc_uid|long(uid,euid,gid,egid,pid,ppid,pgrp,session,tty,tpgid,priority,nice)|pid_t|pid
|
||||
void|proc_mem|long(size,vsize,resident,share,rss,rss_rlim)|pid_t|pid
|
||||
void|proc_time|long(start_time,utime,stime,cutime,cstime,timeout,it_real_value)|pid_t|pid
|
||||
void|proc_signal|ulong(signal,blocked,sigignore,sigcatch)|pid_t|pid
|
||||
void|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,wchan)|pid_t|pid
|
||||
void|proc_segment|long(trs,lrs,drs,dt):ulong(start_code,end_code,start_stack)|pid_t|pid
|
||||
glibtop_mountentry *|@mountlist|ulong(number,size,total)|int|all_fs
|
||||
void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|const char *|mount_dir|strlen (mount_dir) + 1
|
||||
unsigned *|proclist|ulong(number,size,total)|long(method,param)
|
||||
void|proc_state|str(cmd):char(state):ulong(uid,gid)|pid_t(pid)
|
||||
void|proc_uid|long(uid,euid,gid,egid,pid,ppid,pgrp,session,tty,tpgid,priority,nice)|pid_t(pid)
|
||||
void|proc_mem|long(size,vsize,resident,share,rss,rss_rlim)|pid_t(pid)
|
||||
void|proc_time|long(start_time,utime,stime,cutime,cstime,timeout,it_real_value)|pid_t(pid)
|
||||
void|proc_signal|ulong(signal,blocked,sigignore,sigcatch)|pid_t(pid)
|
||||
void|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,wchan)|pid_t(pid)
|
||||
void|proc_segment|long(trs,lrs,drs,dt):ulong(start_code,end_code,start_stack)|pid_t(pid)
|
||||
glibtop_mountentry *|@mountlist|ulong(number,size,total)|pid_t(all_fs)
|
||||
void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir
|
||||
|
@@ -43,7 +43,7 @@ struct _glibtop_proclist
|
||||
size; /* GLIBTOP_PROCLIST_SIZE */
|
||||
};
|
||||
|
||||
#define glibtop_get_proclist(proclist) glibtop_get_proclist_l(glibtop_global_server, proclist)
|
||||
#define glibtop_get_proclist(proclist,method,param) glibtop_get_proclist_l(glibtop_global_server, proclist, method, param)
|
||||
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
#define glibtop_get_proclist_r glibtop_get_proclist_p
|
||||
@@ -51,21 +51,21 @@ struct _glibtop_proclist
|
||||
#define glibtop_get_proclist_r glibtop_get_proclist_s
|
||||
#endif
|
||||
|
||||
extern unsigned *glibtop_get_proclist_l __P((glibtop *, glibtop_proclist *));
|
||||
extern unsigned *glibtop_get_proclist_l __P((glibtop *, glibtop_proclist *, int64_t, int64_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
extern void glibtop_init_proclist_p __P((glibtop *));
|
||||
extern unsigned *glibtop_get_proclist_p __P((glibtop *, glibtop_proclist *));
|
||||
extern unsigned *glibtop_get_proclist_p __P((glibtop *, glibtop_proclist *, int64_t, int64_t));
|
||||
#else
|
||||
extern void glibtop_init_proclist_s __P((glibtop *));
|
||||
extern unsigned *glibtop_get_proclist_s __P((glibtop *, glibtop_proclist *));
|
||||
extern unsigned *glibtop_get_proclist_s __P((glibtop *, glibtop_proclist *, int64_t, int64_t));
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_get_proclist __P((void));
|
||||
extern SCM glibtop_guile_get_proclist __P((SCM, SCM));
|
||||
|
||||
#endif
|
||||
|
||||
|
92
lib/lib.awk
92
lib/lib.awk
@@ -40,28 +40,18 @@ BEGIN {
|
||||
print "";
|
||||
print "/* Library functions. */";
|
||||
print "";
|
||||
|
||||
convert["long"] = "int64_t";
|
||||
convert["ulong"] = "u_int64_t";
|
||||
convert["pid_t"] = "pid_t";
|
||||
convert["int"] = "int";
|
||||
}
|
||||
|
||||
function output(line) {
|
||||
split (line, line_fields, /\|/);
|
||||
retval = line_fields[1];
|
||||
feature = line_fields[2];
|
||||
param_typ = line_fields[4];
|
||||
param = line_fields[5];
|
||||
param_size = line_fields[6];
|
||||
|
||||
if (param_typ == "") {
|
||||
param_size = "0";
|
||||
param_ptr = "NULL";
|
||||
} else {
|
||||
if (param_size == "")
|
||||
param_size = "sizeof ("param_typ")";
|
||||
|
||||
if (param_typ ~ /*/)
|
||||
param_ptr = param;
|
||||
else
|
||||
param_ptr = "&"param;
|
||||
}
|
||||
param_def = line_fields[4];
|
||||
|
||||
orig = feature; sub(/^@/,"",feature);
|
||||
space = feature; gsub(/./," ",space);
|
||||
@@ -75,16 +65,54 @@ function output(line) {
|
||||
prefix_space = "";
|
||||
}
|
||||
|
||||
if (param_typ != "") {
|
||||
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf,";
|
||||
print " "space" "param_typ" "param")";
|
||||
if (param_def == "string") {
|
||||
call_param = ", "line_fields[5];
|
||||
param_decl = ",\n "space" const char *"line_fields[5];
|
||||
send_ptr = "\n\tvoid *send_ptr = "line_fields[5]";";
|
||||
send_size = "\n\tconst size_t send_size =\n\t\tstrlen ("line_fields[5]") + 1;";
|
||||
} else {
|
||||
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf)";
|
||||
call_param = "";
|
||||
param_decl = "";
|
||||
send_size = "";
|
||||
send_ptr = "";
|
||||
nr_params = split (param_def, params, /:/);
|
||||
for (param = 1; param <= nr_params; param++) {
|
||||
list = params[param];
|
||||
type = params[param];
|
||||
sub(/\(.*/, "", type);
|
||||
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
|
||||
count = split (list, fields, /,/);
|
||||
for (field = 1; field <= count; field++) {
|
||||
if (param_decl == "")
|
||||
param_decl = ",\n "space" ";
|
||||
else
|
||||
param_decl = param_decl", ";
|
||||
param_decl = param_decl""convert[type]" "fields[field];
|
||||
call_param = call_param", "fields[field];
|
||||
if (send_ptr == "")
|
||||
send_ptr = "\n\tvoid *send_ptr = &"fields[field]";";
|
||||
if (send_size == "")
|
||||
send_size = "\n\tconst size_t send_size =\n\t\t";
|
||||
else
|
||||
send_size = send_size" + ";
|
||||
send_size = send_size"sizeof ("fields[field]")";
|
||||
}
|
||||
}
|
||||
if (send_size != "")
|
||||
send_size = send_size";";
|
||||
else
|
||||
send_size = "\n\tconst size_t send_size = 0;";
|
||||
if (send_ptr == "")
|
||||
send_ptr = "\n\tvoid *send_ptr = NULL;";
|
||||
}
|
||||
|
||||
print "{";
|
||||
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf"param_decl")";
|
||||
|
||||
print "{"send_ptr""send_size;
|
||||
if (retval !~ /^void$/)
|
||||
print "\t"retval" retval;\n";
|
||||
print "\t"retval" retval;";
|
||||
print "";
|
||||
|
||||
print "\tglibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_"toupper(feature)"), 0);";
|
||||
|
||||
print "";
|
||||
@@ -96,28 +124,16 @@ function output(line) {
|
||||
print "\t (server->features & (1 << GLIBTOP_SYSDEPS_"toupper(feature)")))";
|
||||
print "\t{";
|
||||
|
||||
if (param == "")
|
||||
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", 0, NULL,";
|
||||
else
|
||||
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)",";
|
||||
|
||||
if (param == "") {
|
||||
print "\t\t\t\t"prefix_space"sizeof (glibtop_"feature"), buf);";
|
||||
} else {
|
||||
print "\t\t\t\t"prefix_space""param_size", "param_ptr",";
|
||||
print "\t\t\t\t"prefix_space"sizeof (glibtop_"feature"),";
|
||||
print "\t\t\t\t"prefix_space"buf);";
|
||||
}
|
||||
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)",";
|
||||
print "\t\t\t\t"prefix_space"send_size, send_ptr,";
|
||||
print "\t\t\t\t"prefix_space"sizeof (glibtop_"feature"), buf);";
|
||||
|
||||
print "\t} else {";
|
||||
|
||||
if (orig !~ /^@/)
|
||||
print "#if (!GLIBTOP_SUID_"toupper(feature)")";
|
||||
|
||||
if (param == "")
|
||||
print "\t\t"prefix"glibtop_get_"feature"_s (server, buf);";
|
||||
else
|
||||
print "\t\t"prefix"glibtop_get_"feature"_s (server, buf, "param");";
|
||||
print "\t\t"prefix"glibtop_get_"feature"_s (server, buf"call_param");";
|
||||
|
||||
if (orig !~ /^@/) {
|
||||
print "#else";
|
||||
|
@@ -29,6 +29,7 @@ handle_parent_connection (int s)
|
||||
glibtop_command _cmnd, *cmnd = &_cmnd;
|
||||
glibtop_mountentry *mount_list;
|
||||
char parameter [BUFSIZ];
|
||||
int64_t *param_ptr;
|
||||
int all_fs;
|
||||
pid_t pid;
|
||||
void *ptr;
|
||||
@@ -116,19 +117,26 @@ handle_parent_connection (int s)
|
||||
do_output (s, resp, _offset_data (loadavg), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SHM_LIMITS:
|
||||
glibtop_get_shm_limits_l (server, &resp->u.data.shm_limits);
|
||||
glibtop_get_shm_limits_l
|
||||
(server, &resp->u.data.shm_limits);
|
||||
do_output (s, resp, _offset_data (shm_limits), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MSG_LIMITS:
|
||||
glibtop_get_msg_limits_l (server, &resp->u.data.msg_limits);
|
||||
glibtop_get_msg_limits_l
|
||||
(server, &resp->u.data.msg_limits);
|
||||
do_output (s, resp, _offset_data (msg_limits), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SEM_LIMITS:
|
||||
glibtop_get_sem_limits_l (server, &resp->u.data.sem_limits);
|
||||
glibtop_get_sem_limits_l
|
||||
(server, &resp->u.data.sem_limits);
|
||||
do_output (s, resp, _offset_data (sem_limits), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROCLIST:
|
||||
ptr = glibtop_get_proclist_l (server, &resp->u.data.proclist);
|
||||
param_ptr = (int64_t *) parameter;
|
||||
ptr = glibtop_get_proclist_l (server,
|
||||
&resp->u.data.proclist,
|
||||
param_ptr [0],
|
||||
param_ptr [1]);
|
||||
do_output (s, resp, _offset_data (proclist),
|
||||
resp->u.data.proclist.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
|
@@ -28,6 +28,7 @@ handle_slave_connection (int input, int output)
|
||||
glibtop_response _resp, *resp = &_resp;
|
||||
glibtop_command _cmnd, *cmnd = &_cmnd;
|
||||
char parameter [BUFSIZ];
|
||||
int64_t *param_ptr;
|
||||
void *ptr;
|
||||
|
||||
glibtop_send_version (glibtop_global_server, output);
|
||||
@@ -65,8 +66,10 @@ handle_slave_connection (int input, int output)
|
||||
return;
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
case GLIBTOP_CMND_PROCLIST:
|
||||
param_ptr = (int64_t *) parameter;
|
||||
ptr = glibtop_get_proclist_p
|
||||
(server, &resp->u.data.proclist);
|
||||
(server, &resp->u.data.proclist,
|
||||
param_ptr [0], param_ptr [1]);
|
||||
do_output (output, resp, _offset_data (proclist),
|
||||
resp->u.data.proclist.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
@@ -89,8 +92,6 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
|
||||
|
||||
switch (cmnd->command) {
|
||||
case GLIBTOP_CMND_SYSDEPS:
|
||||
fprintf (stderr, "SYSDEPS: %p - %lx\n",
|
||||
server, server->sysdeps.cpu);
|
||||
memcpy (&resp->u.sysdeps, &server->sysdeps,
|
||||
sizeof (glibtop_sysdeps));
|
||||
resp->u.sysdeps.features = glibtop_server_features;
|
||||
|
@@ -57,7 +57,8 @@ glibtop_init_proclist_p (glibtop *server)
|
||||
}
|
||||
|
||||
unsigned *
|
||||
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf)
|
||||
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
||||
int64_t method, int64_t param)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
unsigned *pids = NULL;
|
||||
|
@@ -20,6 +20,8 @@ BEGIN {
|
||||
|
||||
backconv["int"] = "gh_scm2long";
|
||||
backconv["pid_t"] = "gh_scm2ulong";
|
||||
backconv["long"] = "gh_scm2long";
|
||||
backconv["ulong"] = "gh_scm2ulong";
|
||||
}
|
||||
|
||||
function make_output(line) {
|
||||
@@ -27,17 +29,36 @@ function make_output(line) {
|
||||
retval = line_fields[1];
|
||||
element_def = line_fields[3];
|
||||
feature = line_fields[2];
|
||||
param_typ = line_fields[4];
|
||||
param = line_fields[5];
|
||||
param_size = line_fields[6];
|
||||
param_def = line_fields[4];
|
||||
|
||||
sub(/^@/,"",feature);
|
||||
features[feature] = feature;
|
||||
|
||||
if (param == "")
|
||||
output = "SCM\nglibtop_guile_get_"feature" (void)\n{\n";
|
||||
else
|
||||
output = "SCM\nglibtop_guile_get_"feature" (SCM "param")\n{\n";
|
||||
if (param_def == "string") {
|
||||
call_param = ", gh_scm2newstr( "line_fields[5]", NULL)";
|
||||
param_decl = "SCM "line_fields[5];
|
||||
} else {
|
||||
call_param = "";
|
||||
param_decl = "";
|
||||
nr_params = split (param_def, params, /:/);
|
||||
for (param = 1; param <= nr_params; param++) {
|
||||
list = params[param];
|
||||
type = params[param];
|
||||
sub(/\(.*/, "", type);
|
||||
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
|
||||
count = split (list, fields, /,/);
|
||||
for (field = 1; field <= count; field++) {
|
||||
if (param_decl != "")
|
||||
param_decl = param_decl", ";
|
||||
param_decl = param_decl"SCM "fields[field];
|
||||
call_param = call_param", "backconv[type]" ("fields[field]")";
|
||||
}
|
||||
}
|
||||
if (param_decl == "")
|
||||
param_decl = "void";
|
||||
}
|
||||
|
||||
output = "SCM\nglibtop_guile_get_"feature" ("param_decl")\n{\n";
|
||||
|
||||
output = output"\tglibtop_"feature" "feature";\n";
|
||||
if (retval != "void")
|
||||
@@ -51,15 +72,7 @@ function make_output(line) {
|
||||
else
|
||||
prefix="";
|
||||
|
||||
if (param_typ == "const char *")
|
||||
param_conv = "gh_scm2newstr ("param", NULL)";
|
||||
else if (param_typ != "")
|
||||
param_conv = backconv[param_typ]" ("param")";
|
||||
|
||||
if (param == "")
|
||||
output = output"\t"prefix"glibtop_get_"feature" (&"feature");\n\n";
|
||||
else
|
||||
output = output"\t"prefix"glibtop_get_"feature" (&"feature", "param_conv");\n\n";
|
||||
output = output"\t"prefix"glibtop_get_"feature" (&"feature""call_param");\n\n";
|
||||
|
||||
output = output"\tlist = gh_list (gh_ulong2scm ("feature".flags),\n\t\t\t";
|
||||
|
||||
|
Reference in New Issue
Block a user