home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / XBBS7200.ZIP / XBBS7200.TAR / msgpack / packmsga.c < prev   
Encoding:
C/C++ Source or Header  |  1989-05-07  |  2.1 KB  |  95 lines

  1. /*------------------------------------------------------------------------
  2.        Name: bbscarea.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 "packdef.h"
  10.  
  11.  
  12. char            f_lines[99][81];
  13. char            foo[99];
  14. int             dir_priv[99];
  15. int             set_yet_m = FALSE;
  16. int             user_priv = 32767;
  17.  
  18.  
  19. int
  20.     change_msga(numx) int numx;
  21. {
  22.     FILE           *fpt, *fopen();
  23.     char           *fgets(), *getenv();
  24.     char            choice[94];
  25.     char            dir_priv_ascii[7];
  26.     char           *buf_ptr;
  27.     int             line_cnt, ret, i;
  28.     int             index_value, ptr;
  29.     int             length;
  30.  
  31.  
  32.     strcpy(buf128, MSGS);
  33.  
  34.     if ((fpt = fopen(buf128, "r")) == NULL) {
  35.         printf("\n\rError Opening File Area List: Notify Sysop!\n\r");
  36.         return (-1);
  37.     }
  38.     line_cnt = 0;
  39.     while (fpt) {
  40.         if ((fgets(f_lines[line_cnt], 80, fpt)) == NULL) {
  41.             if (line_cnt == 0) {
  42.                 printf("\n\rEOF Unexpected in Message Area List: Notify Sysop!\n\r");
  43.                 return (-1);
  44.             }
  45.             break;    /* if not 1st line */
  46.         }        /* end of if ((fgets)) */
  47.         if (line_cnt > 0) {
  48.             length = strlen(f_lines[line_cnt]);
  49.             length -= 57;
  50.             substr(f_lines[line_cnt], dir_priv_ascii, 57, length);
  51.             dir_priv[line_cnt] = atoi(dir_priv_ascii);
  52.             if (dir_priv[line_cnt] > user_priv)
  53.                 goto next_read;
  54.             strcpy(foo, f_lines[line_cnt]);
  55.             buf_ptr = foo;
  56.             buf_ptr += 56;
  57.         }
  58. next_read:
  59.         ++line_cnt;
  60.     }            /* end of while (fpt) */
  61.     fclose(fpt);
  62.  
  63.     index_value = numx;
  64.     if (index_value > 0 && index_value < line_cnt) {
  65.         if (dir_priv[index_value] <= user_priv) {
  66.             parse_arg(f_lines[index_value]);
  67.             set_yet_m = TRUE;
  68.             return (1);
  69.         }
  70.     }
  71.     return (0);
  72. }
  73. parse_arg(string)
  74.     char           *string;
  75. {
  76.  
  77.     register char  *file_ptr;
  78.     register int    i;
  79.  
  80.     strcpy(m_pathname, ORGPATH);
  81.     file_ptr = (m_pathname + strlen(m_pathname));
  82.  
  83.     i = 0;
  84.     while (string[i] != ' ') {
  85.         *file_ptr = string[i];
  86.         ++file_ptr;
  87.         ++i;
  88.     }
  89.     *file_ptr = '/';
  90.     ++file_ptr;
  91.     *file_ptr = '\0';
  92.     printf("Packing %s\n", m_pathname);
  93.  
  94. }
  95.