static int Msg_row;
/* Global/Non-windows mode stuff that is NOT persistent */
-static int Crufty_rcf = 0, // if we read an old config, write one too
- No_ksyms = -1, // set to '0' if ksym avail, '1' otherwise
+static int No_ksyms = -1, // set to '0' if ksym avail, '1' otherwise
PSDBopen = 0, // set to '1' if psdb opened (now postponed)
Batch = 0, // batch mode, collect no input, dumb output
Loops = -1, // number of iterations, -1 loops forever
and/or that would be too cumbersome managed as parms,
and/or that are simply more efficiently handled as globals
(first 2 persist beyond a single frame, changed infrequently) */
-static int Frams_libflags; // current PROC_FIILxxx flags (0 = need new)
-//atic int Frams_maxcmdln; // the largest from the 4 windows
-static unsigned Frame_maxtask; // last known number of active tasks
- // ie. current 'size' of proc table
-static unsigned Frame_running, // state categories for this frame
+static int Frames_libflags; // PROC_FILLxxx flags (0 = need new)
+//atic int Frames_maxcmdln; // the largest from the 4 windows
+static unsigned Frame_maxtask; // last known number of active tasks
+ // ie. current 'size' of proc table
+static unsigned Frame_running, // state categories for this frame
Frame_sleepin,
Frame_stopped,
Frame_zombied;
-static float Frame_tscale; // so we can '*' vs. '/' WHEN 'pcpu'
-static int Frame_srtflg, // the subject window's sort direction
- Frame_ctimes, // the subject window's ctimes flag
- Frame_cmdlin; // the subject window's cmdlin flag
+static float Frame_tscale; // so we can '*' vs. '/' WHEN 'pcpu'
+static int Frame_srtflg, // the subject window's sort direction
+ Frame_ctimes, // the subject window's ctimes flag
+ Frame_cmdlin; // the subject window's cmdlin flag
/* ////////////////////////////////////////////////////////////// */
\f
// this task wins it's displayable screen row lottery... */
this->pcpu = tics;
strim(1, this->cmd);
-// if (Frams_maxcmdln) { }
+// if (Frames_maxcmdln) { }
// shout this to the world with the final call (or us the next time in)
Frame_maxtask++;
}
if (i >= MAXTBL(Fieldstab)) return NULL;
return Fieldstab + i;
}
-#endif
// convert, or -1 for failure
if (i >= MAXTBL(Fieldstab)) return -1;
return i;
}
+#endif
#if 0
* For each of the 4 windows:
* line a: contains winname, fieldscur
* line b: contains winflags, sortindx, maxtasks
- * line c: contains summclr, msgsclr, headclr, taskclr */
+ * line c: contains summclr, msgsclr, headclr, taskclr
+ * line d: if present, would crash procps-3.1.1
+ */
static int rc_read_new (const char *const buf, RCF_t *rc) {
int i;
int cnt;
if (cnt != 4) return -(11+100*i);
cp = strchr(cp, '\n');
if (!cp++) return -(12+100*i);
+ while (*cp == '\t') { // skip unknown per-window settings
+ cp = strchr(cp, '\n');
+ if (!cp++) return -(13+100*i);
+ }
}
return 13;
}
+
static int rc_read_old (const char *const buf, RCF_t *rc) {
+ const char std[] = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzJj......";
+ const char old[] = "AaBb..CcDd..GgHhIiYyEeWw..FfMmOoTtKkLlPpJjSsVvXxUuZz[{QqNnRr";
unsigned u;
const char *cp;
unsigned c_show = 0;
cp = buf+2; // skip the "\n\n" we stuck at the beginning
u = 0;
for (;;) {
+ const char *tmp;
if (u+1 >= sizeof rc->win[0].fieldscur) return -1;
int c = *cp++;
if (c == '\0') return -2;
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 == '[') 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
+ tmp = strchr(old,c);
+ if (tmp) c = *((tmp-old)+std);
+ else c = '.';
if (scoreboard[c&0x1fu]) badchar++; // duplicates not allowed
scoreboard[c&0x1fu]++;
rc->win[0].fieldscur[u++] = c;
rc->win[0].fieldscur[u++] = '\0';
if (u < 21) return -6; // catch junk, not good files (had 23 chars in one)
if (u > 33) return -7; // catch junk, not good files (had 29 chars in one)
-// fprintf(stderr,"badchar: %d\n",badchar); sleep(2);
- if (badchar > 3) return -8; // too much junk
+// fprintf(stderr, "badchar: %d\n", badchar); sleep(2);
+ if (badchar > 8) return -8; // too much junk
if (!c_show) return -9; // nothing was shown
// rest of file is optional, but better look right if it exists
case ' ':
case '.':
case '0' ... '9':
- return -15; // not supposed to have digits here
+ return -15; // not supposed to have digits here
-// case 's': // mostly for global rcfile
+// case 's': // mostly for global rcfile
// rc->mode_secure = 1;
// break;
case 'S':
case 'i':
rc->win[0].winflags &= ~Show_IDLEPS;
break;
- case 'H': // 'H' = show threads (yea, sure)
+ case 'H': // 'H' = show threads (yea, sure)
//rc->win[0].winflags |= ;
break;
case 'm':
c = 0; // for scoreboard
rc->win[0].sortindx = P_CPU;
break;
- case 'A':
+ case 'A': // supposed to be start_time
c = 0; // for scoreboard
- rc->win[0].sortindx = P_PID; // was by start_time (non-display)
+ rc->win[0].sortindx = P_PID;
break;
case 'T':
c = 0; // for scoreboard
// just ignore it, except for the scoreboard of course
break;
}
- if (scoreboard[c]) return -16; // duplicates not allowed
+ if (scoreboard[c]) return -16; // duplicates not allowed
scoreboard[c] = 1;
}
return 17;
}
}
-
+#if 0
static void rc_write_old (FILE *fp) {
char buf[SMLBUFSIZ];
char *cp = Curwin->rc.fieldscur;
*cp++ = '\0';
fprintf(fp, "%s\n\n\n", buf); // important "\n\n" separator!
}
-
+#endif
static const char *rc_write_whatever (void) {
FILE *fp = fopen(Rc_name, "w");
if (!fp) return strerror(errno);
- if (Crufty_rcf) rc_write_old(fp);
+// if (Crufty_rcf) rc_write_old(fp);
rc_write_new(fp);
fclose(fp);
return NULL;
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));
}
- 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));
}
- if (!upper[c&0x1f] && !lower[c&0x1f]) { // both missing
+ if (!upper[c&0x1f] && !lower[c&0x1f]) { // both missing
lower[c&0x1f]++;
memmove(fields+1, fields, strlen(fields)+1);
fields[0] = c;
fbuf[0] = '\n';
fbuf[1] = '\n';
fbuf[num+2] = '\0';
- if (rc_read_old(fbuf, &rcf) > 0) Crufty_rcf = 1;
- else rcf = def_rcf; // on failure, maybe mangled
- rc_read_new(fbuf, &rcf);
+//fprintf(stderr,"rc_read_old returns %d\n",rc_read_old(fbuf, &rcf));
+//sleep(2);
+ if (rc_read_new(fbuf, &rcf) < 0) {
+ rcf = def_rcf; // on failure, maybe mangled
+ if (rc_read_old(fbuf, &rcf) < 0) rcf = def_rcf;
+ }
delay = rcf.delay_time;
}
close(fd);
case 'S':
TOGw(Curwin, Show_CTIMES);
break;
+// case 'u':
+// if (cp[1]) cp++;
+// else if (*args) cp = *args++;
+// else std_err("-u missing name");
+// cp += snprintf(Curwin->colusrnam, USRNAMSIZ-1, "%s", cp);
+// break;
default :
std_err(fmtmk("unknown argument '%c'\nusage:\t%s%s"
, *cp, Myname, usage));
for (i = 0; fields[i]; ++i) {
const FLD_t *f = ft_get_ptr(FT_NEW_fmt, fields[i]);
int b = isupper(fields[i]);
- if (!f) continue; // hey, should be std_err!
- /* advance past any leading spaces */
- for (p = f->head; ' ' == *p; ++p)
+
+ if (!f) continue; // hey, should be std_err!
+ for (p = f->head; ' ' == *p; ++p) // advance past any leading spaces
;
PUTT("%s%s%c %c: %-10s = %s"
, tg2((i / rmax) * cmax, (i % rmax) + yRSVD)
const char *h;
int i, needpsdb = 0;
-// Frams_libflags = 0; // should be called only when it's zero
-// Frams_maxcmdln = 0; // becomes largest from up to 4 windows, if visible
+// Frames_libflags = 0; // should be called only when it's zero
+// Frames_maxcmdln = 0; // to become largest from up to 4 windows, if visible
w = Curwin;
do {
if (!Rc.mode_altscr || CHKw(w, VISIBLE_tsk)) {
if (P_CMD == w->procflags[i]) {
s = scat(s, fmtmk(Fieldstab[P_CMD].fmts, w->maxcmdln, w->maxcmdln, h));
if (CHKw(w, Show_CMDLIN)) {
- Frams_libflags |= L_CMDLINE;
-// if (w->maxcmdln > Frams_maxcmdln) Frams_maxcmdln = w->maxcmdln;
+ Frames_libflags |= L_CMDLINE;
+// if (w->maxcmdln > Frames_maxcmdln) Frames_maxcmdln = w->maxcmdln;
}
} else
s = scat(s, h);
- Frams_libflags |= Fieldstab[w->procflags[i]].lflg;
+ Frames_libflags |= Fieldstab[w->procflags[i]].lflg;
}
}
if (Rc.mode_altscr) w = w->next;
PSDBopen = 1;
}
}
- if (Frams_libflags & L_EITHER) {
- Frams_libflags &= ~L_EITHER;
- if (!(Frams_libflags & L_stat)) Frams_libflags |= L_status;
+ if (Frames_libflags & L_EITHER) {
+ Frames_libflags &= ~L_EITHER;
+ if (!(Frames_libflags & L_stat)) Frames_libflags |= L_status;
}
- if (!Frams_libflags) Frams_libflags = L_DEFAULT;
+ if (!Frames_libflags) Frames_libflags = L_DEFAULT;
}
Pseudo_scrn = alloc_r(Pseudo_scrn, Pseudo_size);
// force rebuild of column headers AND libproc/readproc requirements
- Frams_libflags = 0;
+ Frames_libflags = 0;
}
( At this point we have a human being involved and so have all the time )
( in the world. We can afford a few extra cpu cycles every now & then! )
*/
- Frams_libflags = 0;
+ Frames_libflags = 0;
}
sleep(1);
} else
putp(Batch ? "\n\n" : Cap_home);
- p_table = procs_refresh(p_table, Frams_libflags);
+ p_table = procs_refresh(p_table, Frames_libflags);
/*
** Display Uptime and Loadavg */
while ( -1 != ppt[i]->pid && *lscr < Max_lines
&& (!q->winlines || (lwin <= q->winlines)) ) {
- if ((CHKw(q, Show_IDLEPS)
- || ('S' != ppt[i]->state && 'Z' != ppt[i]->state))
- && ((!q->colusrnam[0])
- || (!strcmp(q->colusrnam, ppt[i]->euser)) ) ) {
+ if ((CHKw(q, Show_IDLEPS) || ('S' != ppt[i]->state && 'Z' != ppt[i]->state))
+ && ((!q->colusrnam[0]) || (!strcmp(q->colusrnam, ppt[i]->euser)))) {
/*
** Display a process Row */
task_show(q, ppt[i]);
/* note: except for PROC_PID, all libproc flags are managed by
reframewins(), who also builds each window's column headers */
- if (!Frams_libflags) {
+ if (!Frames_libflags) {
reframewins();
memset(Pseudo_scrn, '\0', Pseudo_size);
}
/* clear to end-of-screen (critical if last window is 'idleps off'),
then put the cursor in-its-place, and rid us of any prior frame's msg
(main loop must iterate such that we're always called before sleep) */
- PUTT("%s%s%s"
- , (scrlins < Max_lines) ? Cap_clr_eos : ""
+ PUTT("%s%s%s%s"
+ , scrlins < Max_lines ? "\n" : ""
+ , scrlins < Max_lines ? Cap_clr_eos : ""
, tg2(0, Msg_row)
, Cap_clr_eol);
fflush(stdout);