]> code.citadel.org Git - citadel.git/commitdiff
* Added pprintf() (paginated version of printf) to the client-side API. Now
authorArt Cancro <ajc@citadel.org>
Sun, 9 Apr 2000 17:51:18 +0000 (17:51 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 9 Apr 2000 17:51:18 +0000 (17:51 +0000)
  any client side function can be paginated simply by changing all of the
  printf's to pprintf's.  I've already done this for the user list and wholist
  (removing the old style pagination) and for "read directory."

citadel/ChangeLog
citadel/citadel.c
citadel/commands.c
citadel/commands.h
citadel/messages.c
citadel/messages.h
citadel/rooms.c
citadel/routines.c

index 87206c8480760b3ab79c6f7afbcc2616170e7a5d..9fee335d8c8063c0c8a5014dfc27200fb059d65e 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 570.17  2000/04/09 17:51:18  ajc
+ * Added pprintf() (paginated version of printf) to the client-side API.  Now
+   any client side function can be paginated simply by changing all of the
+   printf's to pprintf's.  I've already done this for the user list and wholist
+   (removing the old style pagination) and for "read directory."
+
  Revision 570.16  2000/04/08 04:52:48  ajc
  * Another minor stoopid little time display fix
 
@@ -1835,4 +1841,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index 6347293599451ea6e89928312fc695b86fee98af..2072be7deeb08e9b1444bec02e784965806e3901 100644 (file)
@@ -185,43 +185,37 @@ void userlist(char *patn)
        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");
 }
 
 
@@ -754,7 +748,6 @@ void who_is_online(int longlist)
        time_t timenow = 0;
        time_t idletime, idlehours, idlemins, idlesecs;
        int last_session = (-1);
-       int linecount = 2;
 
        if (longlist) {
                serv_puts("TIME");
@@ -766,9 +759,9 @@ void who_is_online(int longlist)
                }
        } 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);
@@ -785,36 +778,31 @@ void who_is_online(int longlist)
                                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);
                }
        }
 }
index 90725565da3e553bc6f41ccc6b9b59516fbead75..9e6719544e96ac8fec223cee99ac1e527492e7c0 100644 (file)
@@ -67,6 +67,9 @@ char rc_url_cmd[256];
 char *gl_string;
 int next_lazy_cmd = 5;
 
+int lines_printed = 0;         /* line count for paginator */
+extern int screenwidth, screenheight;
+
 struct citcmd *cmdlist = NULL;
 
 
@@ -77,6 +80,34 @@ time_t AnsiDetect;                   /* when did we send the detect code? */
 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
  */
@@ -234,6 +265,7 @@ int inkey(void)
        char inbuf[2];
 
        fflush(stdout);
+       lines_printed = 0;
        time(&start_time);
 
        do {
index 2411b04091ae35e6627af9b22cc1ac3de0a4d3ae..6ade37ce7e0b64e4b227bc7d748c96a47275783c 100644 (file)
@@ -50,7 +50,10 @@ void keyopt(char *);
 char keymenu(char *menuprompt, char *menustring);
 void async_ka_start(void);
 void async_ka_end(void);
+void pprintf(const char *format, ...);
+
 
 extern int num_urls;
 extern char urls[MAXURLS][256];
 extern char rc_url_cmd[256];
+extern int lines_printed;
index 648f1199430e386c252a4cbe347d7cb75842ee2d..f8a67bd7dc0699cc5e8b771b6032c2a288585249 100644 (file)
@@ -75,8 +75,6 @@ extern int rc_force_mail_prompts;
 
 extern int editor_pid;
 
-int lines_printed;
-
 void ka_sigcatch(int signum) {
        char buf[256];
        alarm(S_KEEPALIVE);
index 887915ff81cabbdeafaad6fa245b1360796797d9..095dc6f1dbdf84bdb871eec343308c68ee6a9ed0 100644 (file)
@@ -3,7 +3,6 @@ int ka_system(char *shc);
 int entmsg(int is_reply, int c);
 void readmsgs(int c, int rdir, int q);
 void edit_system_message(char *which_message);
-extern int lines_printed;
 pid_t ka_wait(int *kstatus);
 void list_urls(void);
 void check_message_base(void);
index cf317fba1663c0bb9d8e176803d7d1198b906929..dd17496890ffb5e3f2c404666742f17c549f722e 100644 (file)
@@ -716,22 +716,22 @@ void roomdir(void) {
        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);
                }
        }
 
index 6757a59f0d70e47e861b35e1d0cfadc22c14e752..d93fc04a7a7c400abea98a2c76771661cee63683 100644 (file)
@@ -303,7 +303,7 @@ void interr(int errnum)     /* display internal error as defined in errmsgs */
  */
 int checkpagin(int lp, int pagin, int height)
 {
-       if (pagin!=1) return(0);
+       if (!pagin) return(0);
        if (lp>=(height-1)) {
                set_keepalives(KA_NO);
                hit_any_key();