home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume32 / xbbs / part09 / bbsclist.c < prev    next >
C/C++ Source or Header  |  1992-09-08  |  3KB  |  130 lines

  1. /*------------------------------------------------------------------------
  2.        Name: bbsclist.c
  3.    Comments: Display file areas and select one
  4.   ------------------------------------------------------------------------*/
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <ctype.h>
  9. #include <signal.h>
  10. #include "bbscdef.h"
  11.  
  12.  
  13. extern int      user_priv;
  14. extern char     port_id[4];
  15. extern timer(), mon_toggle(), sys_toggle(), chat();
  16.  
  17.  
  18. file_list()
  19. {
  20.     FILE           *fpt, *fopen();
  21.     char           *fgets(), *getenv();
  22.     char            choice[4];
  23. #ifndef SYSV
  24.     char            dir_priv_ascii[7];
  25. #endif
  26. #ifdef SYSV
  27.     char            dir_priv_ascii[20];
  28. #endif
  29.     char           *buf_ptr;
  30.     int             line_cnt, ret, i;
  31.     int             index_value, ptr;
  32.     int             length;
  33.  
  34.     while (1) {
  35.  
  36.     strcpy(buf128, LISTFILES);
  37.  
  38.     if ((fpt = fopen(buf128, "r")) == NULL) {
  39.         portsout("\n\r\n\rThere are no files to read today!\n\r\n\r");
  40.         return ;
  41.     }
  42.     portsout("\n\r\n\r\n\r                  *********************************\n\r");
  43.     portsout("                  * Available Files To Read Today *\n\r");
  44.     portsout("                  *********************************\n\r\n\r");
  45.     portsout("\n\r                      Filename                         Description   \n\r");
  46.     portsout("    ================================================== ================== \n\r");
  47.  
  48.     line_cnt = 0;
  49.     while (fpt) {
  50.         zfl(f_lines[line_cnt], 83);
  51.         if ((fgets(f_lines[line_cnt], 82, fpt)) == NULL) {
  52.             if (line_cnt == 0) {
  53.                 portsout("\n\rEOF Unexpected in File List: Notify Sysop!\n\r");
  54.                 return;
  55.             }
  56.             break;    /* if not 1st line */
  57.         }        /* end of if ((fgets)) */
  58.         if (line_cnt > 0) {
  59.             length = strlen(f_lines[line_cnt]);
  60.             length -= 74;
  61.             if(length > 6)
  62.                 length = 6;
  63.             substr(f_lines[line_cnt], dir_priv_ascii, 74, length);
  64.             dir_priv[line_cnt] = atoi(dir_priv_ascii);
  65.             if (dir_priv[line_cnt] > user_priv)
  66.                 goto next_read;
  67.             strcpy(who_am_i, f_lines[line_cnt]);
  68.             buf_ptr = who_am_i;
  69.             buf_ptr += 73;
  70.             strip(who_am_i);
  71.             for (ptr = 0; ptr < 6; ptr++)
  72.                 *buf_ptr++ = '\0';
  73.             *buf_ptr = '\0';
  74.             sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  75.             strip(buf128);
  76.             term_space(buf128);
  77.             portsout(buf128);
  78.             portsout("\n\r");
  79.         }
  80. next_read:
  81.         ++line_cnt;
  82.     }            /* end of while (fpt) */
  83.     if (line_cnt <= 1)
  84.         {
  85.         portsout("\n\r\n\rThere are no files to read today!\n\r\n\r");
  86.         return;
  87.         }
  88.     portsout(CRLF);
  89.     portsout(" Q) Quit --- exit file read section");
  90.     portsout(CRLF);
  91.     fclose(fpt);
  92.     portsout(CRLF);
  93.  
  94.         portsout("Enter Selection ===> ");
  95.         portsin_cmp(choice, 2, "Qq");
  96.         portsout(CRLF);
  97.         *choice = toupper(*choice);
  98.  
  99.         if (*choice == 'Q')
  100.             return;
  101.  
  102.  
  103.         index_value = atoi(choice);
  104.         if (index_value > 0 && index_value < line_cnt) {
  105.             if (dir_priv[index_value] <= user_priv) {
  106.                 parse_red(f_lines[index_value]);
  107.                 continue;
  108.             }
  109.         }
  110.     }
  111. }
  112.  
  113.  
  114.  
  115.  
  116.  
  117. parse_red(string)
  118.     char           *string;
  119. {
  120.  
  121.     register char  *file_ptr, *xptr;
  122.     register int    i;
  123.  
  124.     file_ptr = buf128;
  125.     substr(string, buf128, 1, 50);
  126.     strip(buf128);
  127.     term_space(buf128);
  128.     cmd_p(buf128);
  129. }
  130.