char fl[256];
struct tm *tmbuf;
time_t lc;
- int linecount = 2;
serv_puts("LIST");
serv_gets(buf);
if (buf[0] != '1') {
- printf("%s\n", &buf[4]);
+ pprintf("%s\n", &buf[4]);
return;
}
sigcaught = 0;
sttybbs(SB_YES_INTR);
- printf(" User Name Num L LastCall Calls Posts\n");
- printf("------------------------- ----- - ---------- ----- -----\n");
+ pprintf(" User Name Num L LastCall Calls Posts\n");
+ pprintf("------------------------- ----- - ---------- ----- -----\n");
while (serv_gets(buf), strcmp(buf, "000")) {
if (sigcaught == 0) {
extract(fl, buf, 0);
if (pattern(fl, patn) >= 0) {
- printf("%-25s ", fl);
- printf("%5ld %d ", extract_long(buf, 2),
+ pprintf("%-25s ", fl);
+ pprintf("%5ld %d ", extract_long(buf, 2),
extract_int(buf, 1));
lc = extract_long(buf, 3);
tmbuf = (struct tm *) localtime(&lc);
- printf("%02d/%02d/%04d ",
+ pprintf("%02d/%02d/%04d ",
(tmbuf->tm_mon + 1),
tmbuf->tm_mday,
(tmbuf->tm_year + 1900));
- printf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
-
- ++linecount;
- linecount = checkpagin(linecount,
- ((userflags & US_PAGINATOR) ? 1 : 0),
- screenheight);
+ pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
}
}
}
sttybbs(SB_NO_INTR);
- printf("\n");
+ pprintf("\n");
}
time_t timenow = 0;
time_t idletime, idlehours, idlemins, idlesecs;
int last_session = (-1);
- int linecount = 2;
if (longlist) {
serv_puts("TIME");
}
} else {
color(BRIGHT_WHITE);
- printf("FLG ### User Name Room From host\n");
+ pprintf("FLG ### User Name Room From host\n");
color(DIM_WHITE);
- printf("--- --- ------------------------- -------------------- ------------------------\n");
+ pprintf("--- --- ------------------------- -------------------- ------------------------\n");
}
serv_puts("RWHO");
serv_gets(buf);
idlehours = idletime / 3600;
idlemins = (idletime - (idlehours * 3600)) / 60;
idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
- printf("\nFlags: %-3s Sess# %-3d Name: %-25s Room: %s\n",
+ pprintf("\nFlags: %-3s Sess# %-3d Name: %-25s Room: %s\n",
flags, extract_int(buf, 0), username, roomname);
- printf("from <%s> using <%s>, idle %ld:%02ld:%02ld\n",
+ pprintf("from <%s> using <%s>, idle %ld:%02ld:%02ld\n",
fromhost, clientsoft,
(long) idlehours, (long) idlemins, (long) idlesecs);
- linecount += 3;
} else {
if (extract_int(buf, 0) == last_session) {
- printf(" ");
+ pprintf(" ");
} else {
color(BRIGHT_MAGENTA);
- printf("%-3s ", flags);
+ pprintf("%-3s ", flags);
color(DIM_WHITE);
- printf("%-3d ", extract_int(buf, 0));
+ pprintf("%-3d ", extract_int(buf, 0));
}
last_session = extract_int(buf, 0);
color(BRIGHT_CYAN);
- printf("%-25s ", username);
+ pprintf("%-25s ", username);
color(BRIGHT_MAGENTA);
roomname[20] = 0;
- printf("%-20s ", roomname);
+ pprintf("%-20s ", roomname);
color(BRIGHT_CYAN);
- printf("%-24s\n", fromhost);
+ pprintf("%-24s\n", fromhost);
color(DIM_WHITE);
- ++linecount;
}
- linecount = checkpagin(linecount,
- ((userflags & US_PAGINATOR) ? 1 : 0),
- screenheight);
}
}
}
char *gl_string;
int next_lazy_cmd = 5;
+int lines_printed = 0; /* line count for paginator */
+extern int screenwidth, screenheight;
+
struct citcmd *cmdlist = NULL;
int enable_color = 0; /* nonzero for ANSI color */
+
+
+
+/*
+ * pprintf() ... paginated version of printf()
+ */
+void pprintf(const char *format, ...) {
+ va_list arg_ptr;
+ static char buf[4096]; /* static for performance, change if needed */
+ int i;
+
+ va_start(arg_ptr, format);
+ vsprintf(buf, format, arg_ptr);
+ va_end(arg_ptr);
+
+ for (i=0; i<strlen(buf); ++i) {
+ putc(buf[i], stdout);
+ if (buf[i]==10) {
+ ++lines_printed;
+ lines_printed = checkpagin(lines_printed,
+ (userflags & US_PAGINATOR),
+ screenheight);
+ }
+ }
+}
+
+
+
/*
* print_express() - print express messages if there are any
*/
char inbuf[2];
fflush(stdout);
+ lines_printed = 0;
time(&start_time);
do {
serv_puts("RDIR");
serv_gets(buf);
if (buf[0]!='1') {
- printf("%s\n",&buf[4]);
+ pprintf("%s\n",&buf[4]);
return;
}
extract(comment,&buf[4],0);
extract(flnm,&buf[4],1);
- printf("\nDirectory of %s on %s\n",flnm,comment);
- printf("-----------------------\n");
+ pprintf("\nDirectory of %s on %s\n",flnm,comment);
+ pprintf("-----------------------\n");
while (serv_gets(buf), strcmp(buf,"000")) {
extract(flnm,buf,0);
extract(flsz,buf,1);
extract(comment,buf,2);
if (strlen(flnm)<=14)
- printf("%-14s %8s %s\n",flnm,flsz,comment);
+ pprintf("%-14s %8s %s\n",flnm,flsz,comment);
else
- printf("%s\n%14s %8s %s\n",flnm,"",flsz,comment);
+ pprintf("%s\n%14s %8s %s\n",flnm,"",flsz,comment);
}
}