Added next_token(). Changed skip_token(), i hope it won't break any bad

* glibtop_server.h: Added next_token(). Changed skip_token(),
        i hope it won't break any bad code.
        * procstate.c: (glibtop_get_proc_state_s): Used next_token.
        * proctime.c: (glibtop_get_proc_time_s): Implemented .start_time
        the way it ought to be. Clean ups.
This commit is contained in:
Benoît Dejean
2004-08-03 11:40:37 +00:00
parent 5b39a4831d
commit 808a2d48ac
4 changed files with 52 additions and 7 deletions

View File

@@ -72,16 +72,15 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid)
buf->flags = _glibtop_sysdeps_proc_state_uid;
sprintf (buffer, "/proc/%d", pid);
/* Now we read the remaining fields. */
if (proc_stat_to_buffer (buffer, pid))
return;
p = strrchr (buffer, ')'); *p = '\0';
p = proc_stat_after_cmd(buffer);
p = next_token(p);
switch(p[2])
switch(*p)
{
case 'R':
buf->state = GLIBTOP_PROCESS_RUNNING;
@@ -112,7 +111,7 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid)
break;
}
p = skip_token (buffer); p++; /* pid */
p = skip_token (buffer); /* pid */
if (G_UNLIKELY(*p++ != '('))
glibtop_error_r (server, "Bad data in /proc/%d/stat", pid);