]> code.citadel.org Git - citadel.git/blobdiff - citadel/routines.c
* Bug fixes: Fix numerous char array size mismatches, signed/unsigned
[citadel.git] / citadel / routines.c
index fd96cbaeacfff21aa8fc851dc4131b062a1fa6c7..15f954d36802391e3849b52df54459c80a4e171d 100644 (file)
@@ -159,7 +159,7 @@ void edituser(CtdlIPC *ipc)
  * yes or no.  Yes=1 and No=0, unless 'backwards' is set to a nonzero value
  * in which case No=1 and Yes=0.
  */
-int set_attr(CtdlIPC *ipc, int sval, char *prompt, unsigned int sbit, int backwards)
+int set_attr(CtdlIPC *ipc, unsigned int sval, char *prompt, unsigned int sbit, int backwards)
 {
        int a;
        int temp;
@@ -388,28 +388,27 @@ char *strerror(int e)
 #endif
 
 
-void progress(long int curr, long int cmax)
+void progress(unsigned long curr, unsigned long cmax)
 {
-       static long dots_printed;
-       long a;
-
-       if (curr==0) {
-               scr_printf(".......................................");
-               scr_printf(".......................................\r");
-               scr_flush();
-               dots_printed = 0;
-       }
-       else if (curr==cmax) {
-               scr_printf("\r%79s\n","");
-       }
-       else {
-               a=(curr * 100) / cmax;
-               a=a*78; a=a/100;
-               while (dots_printed < a) {
-                       scr_printf("*");
-                       ++dots_printed;
-                       scr_flush();
-               }
+       static char dots[] =
+               "**************************************************";
+       char dots_printed[51];
+       char fmt[42];
+       unsigned long a;
+
+       if (curr >= cmax) {
+               sln_printf("\r%79s\r","");
+               status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
+                       room_name, secure, 0);
+       } else {
+               /* a will be range 0-50 rather than 0-100 */
+               a=(curr * 50) / cmax;
+               sprintf(fmt, "[%%s%%%lds] %%3ld%%%% %%10ld/%%10ld\r", 50 - a);
+               strncpy(dots_printed, dots, a);
+               dots_printed[a] = 0;
+               sln_printf(fmt, dots_printed, "",
+                               curr * 100 / cmax, curr, cmax);
+               sln_flush();
        }
 }