home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MSGDP206.SZH / AREAS.C next >
C/C++ Source or Header  |  1990-08-01  |  3KB  |  114 lines

  1. /*
  2.  
  3. Title:  MsgEd
  4.  
  5. File:   areas.c
  6.  
  7. Author: Jim Nutt
  8.  
  9. Copr:   released into the PUBLIC DOMAIN 30 Jul 1990 by jim nutt
  10.  
  11. Description:
  12.  
  13.     This file contains the routines necessary to select individual
  14.     areas for reading, etc.
  15.  
  16. */
  17.  
  18. #include "msged.h"
  19. #include "menu.h"
  20.  
  21. void _pascal areascan(void);
  22.  
  23. int _pascal selectarea()
  24.  
  25. {
  26.     char  **list;
  27.     char line[50];
  28.     AREA *a;
  29.     int i = 0,j;
  30.  
  31.     cls();
  32.  
  33.     if ((maxx - 50) > 15) {
  34.         gotoxy(2,2); bputs("msged version " VERSION);
  35.         gotoxy(2,4); bputs("Area statistics and");
  36.         gotoxy(2,5); bputs("selection menu");
  37.         gotoxy(2,7); bputs("Use arrow keys or type");
  38.         gotoxy(2,8); bputs("a unique segment of the");
  39.         gotoxy(2,9); bputs("area description to");
  40.         gotoxy(2,10);bputs("select an area, then");
  41.         gotoxy(2,11);bputs("press the return or ");
  42.         gotoxy(2,12);bputs("enter key");
  43.  
  44.     }
  45.     gotoxy(maxx-50,1); bputs("Area                          New  Unread Number");
  46.     gotoxy(maxx-50,2); bputs("Description                   msg   msgs    of");
  47.     gotoxy(maxx-50,3); bputs("                               ?           msgs");
  48.     gotoxy(maxx-50,4); bputs("------------------------------------------------");
  49.  
  50.     list = calloc(areas + 2, sizeof(char *));
  51.  
  52.     if (!scanned) {
  53.  
  54.         list[0] = strdup("Scan for new messages");
  55.  
  56.         for (i = 0; i < areas; i++) {
  57.             memset(line, 0, sizeof line);
  58.             a = arealist + i;
  59.             if (a->messages)
  60.                 sprintf(line, "%-30.30s %c %6d %6d",a->description,
  61.                     ((a->lastread+1) < a->messages)?'y':'n',
  62.                     a->messages - a->lastread - 1,a->messages);
  63.                 else
  64.                 sprintf(line, "%-30.30s %15s",a->description,scanned?"empty":"unscanned");
  65.  
  66.             list[i+1] = strdup(line);
  67.             }
  68.  
  69.         i = menu(maxx-50,5,maxx,maxy,list,co_hilite,co_normal,0);
  70.     
  71.         if (i == 0) {
  72.             areascan();
  73.             gotoxy(1,1); clreol();
  74.             gotoxy(maxx-50,1); bputs("Area                          New  Unread Number");
  75.         }
  76.         
  77.         for (j = 0; j < areas+1; j++)
  78.             free(list[j]);
  79.     }
  80.  
  81.     i--;
  82.  
  83.     if (i == -1) {
  84.  
  85.         memset(list,0, sizeof(char *) * (areas + 2));
  86.  
  87.         for (i = 0; i < areas; i++) {
  88.             memset(line, 0, sizeof line);
  89.             a = arealist + i;
  90.             if (a->messages)
  91.                 sprintf(line, "%-30.30s %c %6d %6d",a->description,
  92.                     ((a->lastread+1) < a->messages)?'y':'n',
  93.                     a->messages - a->lastread - 1,a->messages);
  94.                 else
  95.                 sprintf(line, "%-30.30s %15s",a->description,"empty");
  96.  
  97.             list[i] = strdup(line);
  98.             }
  99.  
  100.         i = menu(maxx-50,5,maxx,maxy,list,co_hilite,co_normal,area);
  101.  
  102.         for (j = 0; j < areas; j++)
  103.             free(list[j]);
  104.     }
  105.  
  106.     gotoxy(2,15); set_color(co_warn); bputs("wait"); set_color(co_normal);
  107.  
  108.     free(list);
  109.  
  110.     set_color(co_normal);
  111.  
  112.     return((i < 0)?area:i);
  113. }
  114.