* GNU Library General Public License for more details.
*/
/* For their contributions to this program, the author wishes to thank:
- * Craig Small, <csmall@small.dropbear.id.au>
* Albert D. Cahalan, <albert@users.sf.net>
+ * Craig Small, <csmall@small.dropbear.id.au>
*/
#include <sys/ioctl.h>
#include <sys/resource.h>
overridden with the local rcfile (old or new-style) values */
static char Rc_name [OURPATHSZ];
static RCF_t Rc = DEF_RCFILE;
-static const RCF_t DefRc = DEF_RCFILE;
/* The run-time acquired page size */
static int Page_size;
* values. Note that 2 of these routines serve double duty --
* 2 columns each.
*/
+
SCB_NUMx(P_PID, pid)
SCB_NUMx(P_PPD, ppid)
-SCB_STRx(P_RUN, ruser)
+SCB_STRx(P_URR, ruser)
SCB_NUMx(P_UID, euid)
-SCB_STRx(P_USR, euser)
+SCB_STRx(P_URE, euser)
SCB_STRx(P_GRP, egroup)
SCB_NUMx(P_TTY, tty)
SCB_NUMx(P_PRI, priority)
// this task wins it's displayable screen row lottery... */
this->pcpu = tics;
strim(1, this->cmd);
-// if (Frams_maxcmdln)
+// if (Frams_maxcmdln) { }
// shout this to the world with the final call (or us the next time in)
Frame_maxtask++;
}
------ ----------- ------- ------ ----- ----- ---------------------- -------- */
{ "AaAa", " PID ", "%5u ", -1, -1, SF(PID), "Process Id", L_NONE },
{ "BbBb", " PPID ", "%5u ", -1, -1, SF(PPD), "Parent Process Pid", L_EITHER },
- { "CcQq", "RUSER ", "%-8.8s ", -1, -1, SF(RUN), "Real user name", L_RUSER },
+ { "CcQq", "RUSER ", "%-8.8s ", -1, -1, SF(URR), "Real user name", L_RUSER },
{ "DdCc", " UID ", "%4u ", -1, -1, SF(UID), "User Id", L_NONE },
- { "EeDd", "USER ", "%-8.8s ", -1, -1, SF(USR), "User Name", L_EUSER },
+ { "EeDd", "USER ", "%-8.8s ", -1, -1, SF(URE), "User Name", L_EUSER },
{ "FfNn", "GROUP ", "%-8.8s ", -1, -1, SF(GRP), "Group Name", L_GROUP },
{ "GgGg", "TTY ", "%-8.8s ", 8, -1, SF(TTY), "Controlling Tty", L_stat },
{ "HhHh", " PR ", "%3d ", -1, -1, SF(PRI), "Priority", L_stat },
if (i < 0) return 0;
if (i >= MAXTBL(Fieldstab)) return 0;
c = Fieldstab[i].keys[fr];
- if (c == '.') c = 0; // '.' marks a bad entry
+ if (c == '.') c = 0; // '.' marks a bad entry
return c;
}
+#if 0
// convert, or -1 for failure
static int ft_get_idx (const int fr, int c) {
int j = -1;
}
return -1;
}
+#endif
// convert, or NULL for failure
}
+#if 0
// convert, or NULL for failure
static const FLD_t *ft_idx_to_ptr (const int i) {
if (i < 0) return NULL;
if (i >= MAXTBL(Fieldstab)) return NULL;
return Fieldstab + i;
}
+#endif
// convert, or -1 for failure
}
-#if 1
+#if 0
static void rc_bugless (const RCF_t *const rc) {
const RCW_t *w;
int i = 0;
unsigned u;
const char *cp;
unsigned c_show = 0;
- int badchar = 0; // allow a limited number of duplicates and junk
+ int badchar = 0; // allow a limited number of duplicates and junk
char scoreboard[256];
memset(scoreboard, '\0', sizeof scoreboard);
if (c == '\0') return -2;
if (c == '\n') break;
if (c & ~0x7f) return -3;
- if (~c & 0x20) c_show |= 1 << (c & 0x1f); // 0x20 means lowercase means hidden
- if (scoreboard[c|0xe0u]) badchar++; // duplicates not allowed
+ if (~c & 0x20) c_show |= 1 << (c & 0x1f); // 0x20 means lowercase means hidden
+ if (scoreboard[c|0xe0u]) badchar++; // duplicates not allowed
scoreboard[c|0xe0u]++;
- if (c == '|') continue; // Rik's top ships with a garbage character
+ if (c == '|') continue; // Rik's top ships with a garbage character
if (c == '[') c = 'Y'; // Rik's top ships with 3x of "#C"
if (c == '{') c = 'y'; // another one... and '}' to please Jim's editor
if (c == 'N') c = 'n'; // usage differs, so turn this off
if (c == 'Q') c = 'q'; // usage differs, so turn this off
if (c == 'R') c = 'r'; // usage differs, so turn this off
c = ft_cvt_char(FT_OLD_fmt, FT_NEW_fmt, c);
- if (!c) return -4; // error value
- if (c == '.') return -5; // error value
- if (scoreboard[c&0x1fu]) badchar++; // duplicates not allowed
+ if (!c) return -4; // error value
+ if (c == '.') return -5; // error value
+ if (scoreboard[c&0x1fu]) badchar++; // duplicates not allowed
scoreboard[c&0x1fu]++;
rc->win[0].fieldscur[u++] = c;
}
break;
}
*cp++ = '\0';
- fprintf(fp, "%s\n\n\n", buf); // important "\n\n" separator!
+ fprintf(fp, "%s\n\n\n", buf); // important "\n\n" separator!
}
}
-// Anything missing won't show as a choice in the field editor,
-// so make sure there is exactly one of each letter.
-//
-// Due to Rik blindly accepting damem's broken patches, procps-2.0.1x
-// has 3 ("three"!!!) instances of "#C", "LC", or "CPU". Fix that too.
-// Some people are maintainers, and others are human patchbots.
-static void add_missing_fields(char *fields){
- unsigned upper[32];
- unsigned lower[32];
+ /*
+ * Config file read *helper* function.
+ * Anything missing won't show as a choice in the field editor,
+ * so make sure there is exactly one of each letter.
+ *
+ * Due to Rik blindly accepting damem's broken patches, procps-2.0.1x
+ * has 3 ("three"!!!) instances of "#C", "LC", or "CPU". Fix that too.
+ * Some people are maintainers, and others are human patchbots.
+ * (thanks, Albert) */
+static void confighlp (char *fields) {
+ unsigned upper[PFLAGSSIZ];
+ unsigned lower[PFLAGSSIZ];
char c;
char *cp;
c = 'a';
while (c <= 'z') {
if (upper[c&0x1f] && lower[c&0x1f]) {
- lower[c&0x1f] = 0; // got both, so wipe out unseen column
+ lower[c&0x1f] = 0; // got both, so wipe out unseen column
for (;;) {
cp = strchr(fields, c);
- if (cp) memmove(cp,cp+1,strlen(cp));
+ if (cp) memmove(cp, cp+1, strlen(cp));
else break;
}
}
- while (lower[c&0x1f] > 1) { // got too many a..z
+ while (lower[c&0x1f] > 1) { // got too many a..z
lower[c&0x1f]--;
cp = strchr(fields, c);
- memmove(cp,cp+1,strlen(cp));
+ memmove(cp, cp+1, strlen(cp));
}
- while (upper[c&0x1f] > 1) { // got too many A..Z
+ while (upper[c&0x1f] > 1) { // got too many A..Z
upper[c&0x1f]--;
cp = strchr(fields, toupper(c));
- memmove(cp,cp+1,strlen(cp));
+ memmove(cp, cp+1, strlen(cp));
}
if (!upper[c&0x1f] && !lower[c&0x1f]) { // both missing
lower[c&0x1f]++;
- memmove(fields+1,fields,strlen(fields)+1);
+ memmove(fields+1, fields, strlen(fields)+1);
fields[0] = c;
}
c++;
}
}
+
/*
* First attempt to read the /etc/rcfile which contains two lines
* consisting of the secure mode switch and an update interval.
* Delay_time will be ignored except for root. */
static void configs_read (void)
{
+ const RCF_t def_rcf = DEF_RCFILE;
char fbuf[MEDBUFSIZ];
int i, fd;
RCF_t rcf;
float delay = Rc.delay_time;
- // Read part of an old-style config in /etc/toprc
+ // read part of an old-style config in /etc/toprc
fd = open(SYS_RCFILESPEC, O_RDONLY);
if (fd > 0) {
ssize_t num;
if (getenv("HOME"))
snprintf(Rc_name, sizeof(Rc_name), "%s/.%src", getenv("HOME"), Myname);
- rcf = DefRc;
+ rcf = def_rcf;
fd = open(Rc_name, O_RDONLY);
if (fd > 0) {
ssize_t num;
fbuf[1] = '\n';
fbuf[num+2] = '\0';
if (rc_read_old(fbuf, &rcf) > 0) Crufty_rcf = 1;
- else rcf = DefRc; // on failure, maybe mangled
+ else rcf = def_rcf; // on failure, maybe mangled
rc_read_new(fbuf, &rcf);
delay = rcf.delay_time;
}
Curwin = &Winstk[rcf.win_index];
for (i = 0; i < GROUPSMAX; i++) {
memcpy(&Winstk[i].rc, &rcf.win[i], sizeof rcf.win[i]);
- add_missing_fields(Winstk[i].rc.fieldscur);
+ confighlp(Winstk[i].rc.fieldscur);
}
// lastly, establish the true runtime secure mode and delay time
{
/* differences between us and the former top:
-C (separate CPU states for SMP) is left to an rcfile
- -p (pid monitoring) allows, not requires, a comma delimited list
+ -p (pid monitoring) allows a comma delimited list
-q (zero delay) eliminated as redundant, incomplete and inappropriate
use: "nice -n-10 top -d0" to achieve what was only claimed
-c,i,S act as toggles (not 'on' switches) for enhanced user flexibility
int i, needpsdb = 0;
// Frams_libflags = 0; // should be called only when it's zero
-// Frams_maxcmdln = 0; // to become the largest from the 4 windows
+// Frams_maxcmdln = 0; // becomes largest from up to 4 windows, if visible
w = Curwin;
do {
if (!Rc.mode_altscr || CHKw(w, VISIBLE_tsk)) {
pad += q->len_rowhigh; \
if (!(CHKw(q, Show_HIROWS) && 'R' == p->state)) pad += q->len_rownorm; \
} } while (0)
- // the format for 'command line' display in absence of same (kernel thread)
-
char rbuf[ROWBUFSIZ], *rp;
int j, x, pad;
case P_RES:
MKCOL(scale_num(PAGES_2K(p->resident), w, s));
break;
- case P_RUN:
- MKCOL(p->ruser);
- break;
case P_SHR:
MKCOL(scale_num(PAGES_2K(p->share), w, s));
break;
case P_UID:
MKCOL((unsigned)p->euid);
break;
- case P_USR:
+ case P_URE:
MKCOL(p->euser);
break;
+ case P_URR:
+ MKCOL(p->ruser);
+ break;
case P_VRT:
MKCOL(scale_num(PAGES_2K(p->size), w, s));
break;
* GNU Library General Public License for more details.
*/
/* For their contributions to this program, the author wishes to thank:
- * Craig Small, <csmall@small.dropbear.id.au>
* Albert D. Cahalan, <albert@users.sf.net>
+ * Craig Small, <csmall@small.dropbear.id.au>
*/
#ifndef _Itop
#define _Itop
/* Flags for each possible field */
enum pflag {
- P_PID, P_PPD, P_RUN, P_UID, P_USR, P_GRP, P_TTY,
+ P_PID, P_PPD, P_URR, P_UID, P_URE, P_GRP, P_TTY,
P_PRI, P_NCE,
P_CPN, P_CPU, P_TME, P_TM2,
P_MEM, P_VRT, P_SWP, P_RES, P_COD, P_DAT, P_SHR,
/* Pre-configured field groupss */
#define JOB_FIELDS "ABXcefgjlrstuvyzMKNHIWOPQD"
#define MEM_FIELDS "ANOPQRSTUVXbcdefgjlmyzWHIK"
-#define USR_FIELDS "DEFGABXchijlopqrstuvyzMKNW"
+#define USR_FIELDS "DECGABXfhijlopqrstuvyzMKNW"
/* Used by fields_sort, placed here for peace-of-mind */
#define NUL_FIELDS "abcdefghijklmnopqrstuvwxyz"
{ P_MEM, DEF_WINFLGS, 0, \
COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLUE, COLOR_MAGENTA, \
"Mem", MEM_FIELDS }, \
- { P_USR, DEF_WINFLGS, 0, \
+ { P_URE, DEF_WINFLGS, 0, \
COLOR_YELLOW, COLOR_YELLOW, COLOR_GREEN, COLOR_YELLOW, \
"Usr", USR_FIELDS } \
} }
//atic const char *rc_write_whatever (void);
/*------ Startup routines ----------------------------------------------*/
//atic void before (char *me);
+//atic void confighlp (char *fields);
//atic void configs_read (void);
//atic void parse_args (char **args);
//atic void whack_terminal (void);