home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume32 / xbbs / part07 / bbscmsga.c < prev    next >
C/C++ Source or Header  |  1992-09-08  |  9KB  |  404 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 "bbscdef.h"
  10.  
  11.  
  12. int             set_yet_m = FALSE;
  13. extern int      user_priv;
  14.  
  15.  
  16. change_msga( type ) int type;
  17. {
  18.     FILE           *fpt, *fopen();
  19.     char           *fgets(), *getenv();
  20.     char            choice[4];
  21. #ifndef SYSV
  22.     char            dir_priv_ascii[7];
  23. #endif
  24. #ifdef SYSV
  25.     char            dir_priv_ascii[20];
  26. #endif
  27.  
  28.     char           *buf_ptr;
  29.     int             line_cnt, ret, i;
  30.     int             index_value, ptr;
  31.     int             length;
  32.  
  33.     if( type == -1)
  34.         return;
  35.  
  36. do_again:
  37.     strcpy(buf128, MSGS);
  38.  
  39.     if ((fpt = fopen(buf128, "r")) == NULL) {
  40.         portsout("\n\rError Opening File Area List: Notify Sysop!\n\r");
  41.         return (-1);
  42.     }
  43.     if(!type) {
  44.     portsout("\n\r    Directory     Description                                      \n\r");
  45.     portsout("    ============= ========================================== \n\r");
  46.     }
  47.  
  48.     line_cnt = 0;
  49.     while (fpt) {
  50.         zfl(f_lines[line_cnt], 81);
  51.         if ((fgets(f_lines[line_cnt], 80, fpt)) == NULL) {
  52.             if (line_cnt == 0) {
  53.                 portsout("\n\rEOF Unexpected in Message Area List: Notify Sysop!\n\r");
  54.                 return (-1);
  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 -= 57;
  61.             if(length > 6)
  62.                 length = 6;
  63.             substr(f_lines[line_cnt], dir_priv_ascii, 57, 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 += 56;
  70.             for (ptr = 0; ptr < 6; ptr++)
  71.                 *buf_ptr++ = ' ';
  72.             *buf_ptr = '\0';
  73.             sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  74.             if(!type) {
  75.             strip(buf128);
  76.             term_space(buf128);
  77.             portsout(buf128);
  78.             portsout("\n\r");
  79.             }
  80.         }
  81. next_read:
  82.         ++line_cnt;
  83.     }            /* end of while (fpt) */
  84.     if (line_cnt <= 1)
  85.         return;
  86.     if (set_yet_m && !type) {
  87.         portsout(CRLF);
  88.         portsout(" Q) Quit to Previous Menu");
  89.     }
  90.     if(!type)portsout(CRLF);
  91.     fclose(fpt);
  92.     if(!type)portsout(CRLF);
  93.  
  94.     while (1) {
  95.         if(!type) {
  96.         portsout("Enter Selection ===> ");
  97.         portsin_cmp(choice, 2, "Qq");
  98.         portsout(CRLF);
  99.         *choice = toupper(*choice);
  100.  
  101.         if (*choice == 'Q' && set_yet_m)
  102.             return (-1);
  103.  
  104.  
  105.         index_value = atoi(choice);
  106.         }
  107.         else index_value = type;
  108.         if (index_value > 0 && index_value < line_cnt) {
  109.             if (dir_priv[index_value] <= user_priv) {
  110.                 parse_arg(f_lines[index_value]);
  111.                 set_yet_m = TRUE;
  112.                 hdrread();
  113.                 itoa(buf128,index_value);
  114.                 if(index_value > 9)
  115.                     {
  116.                     strcpy(l_m_base, buf128);
  117.                     }
  118.                 else
  119.                     {
  120.                     strcpy(l_m_base, "0");
  121.                     strcat(l_m_base,buf128);
  122.                     }
  123.                 
  124.                 rewritx();
  125.                 return (0);
  126.             }
  127.         }
  128.         if( type != 0 ) {
  129.             type = 0;
  130.             portsout("\n\rInvalid directory request!\n\r");
  131.             goto do_again;
  132.         }
  133.     }
  134. }
  135.  
  136.  
  137.  
  138.  
  139.  
  140. parse_arg(string)
  141.     char           *string;
  142. {
  143.  
  144.     register char  *file_ptr, *xptr;
  145.     register int    i;
  146.  
  147.     strcpy(m_pathname, ORGPATH);
  148.     file_ptr = (m_pathname + strlen(m_pathname));
  149.     xptr = who_am_I;
  150.  
  151.     i = 0;
  152.     while (string[i] != ' ') {
  153.         *file_ptr = string[i];
  154.         *xptr = string[i];
  155.         ++xptr;
  156.         ++file_ptr;
  157.         ++i;
  158.     }
  159.     *file_ptr = '/';
  160.     ++file_ptr;
  161.     *file_ptr = '\0';
  162.     *xptr = '\0';
  163.  
  164. }
  165. check_msga()
  166. {
  167.     FILE           *fpt, *fopen();
  168.     char           *fgets(), *getenv();
  169.     char            choice[4];
  170. #ifndef SYSV
  171.     char            dir_priv_ascii[7];
  172. #endif
  173. #ifdef SYSV
  174.     char            dir_priv_ascii[20];
  175. #endif
  176.     char           *buf_ptr, *file_ptr, *char_ptr;
  177.     int             line_cnt, ret, i;
  178.     int             index_value, ptr;
  179.     int             length, strl, ii;
  180.  
  181.  
  182.     strcpy(buf128, MSGS);
  183.  
  184.     if ((fpt = fopen(buf128, "r")) == NULL) {
  185.         portsout("\n\rError Opening File Area List: Notify Sysop!\n\r");
  186.         return (-1);
  187.     }
  188.     line_cnt = 0;
  189.     while (fpt) {
  190.         zfl(f_lines[line_cnt], 81);
  191.         if ((fgets(f_lines[line_cnt], 80, fpt)) == NULL) {
  192.             if (line_cnt == 0) {
  193.                 portsout("\n\rEOF Unexpected in Message Area List: Notify Sysop!\n\r");
  194.                 return (-1);
  195.             }
  196.             break;    /* if not 1st line */
  197.         }        /* end of if ((fgets)) */
  198.         if (line_cnt > 0) {
  199.             length = strlen(f_lines[line_cnt]);
  200.             length -= 57;
  201.             if(length > 6)
  202.                 length = 6;
  203.             substr(f_lines[line_cnt], dir_priv_ascii, 57, length);
  204.             strl = strlen(dir_priv_ascii);
  205.             if (strl == 0) {
  206.                 portsout("\n\rError reading privilege level\n\r");
  207.                 exit(1);
  208.             }
  209.             char_ptr = strchr(dir_priv_ascii, '*');
  210.             if (char_ptr != NULL) {
  211.                 strcpy(c_pathname, ORGPATH);
  212.                 file_ptr = (c_pathname + strlen(c_pathname));
  213.                 ii = 0;
  214.                 while (f_lines[line_cnt][ii] != ' ') {
  215.                     *file_ptr = f_lines[line_cnt][ii];
  216.                     ++file_ptr;
  217.                     ++ii;
  218.                 }
  219.                 *file_ptr = '/';
  220.                 ++file_ptr;
  221.                 *file_ptr = '\0';
  222.                 *char_ptr = '\0';
  223.             }
  224.             dir_priv[line_cnt] = atoi(dir_priv_ascii);
  225.             if (dir_priv[line_cnt] > user_priv)
  226.                 goto next_read;
  227.             strcpy(who_am_i, f_lines[line_cnt]);
  228.             buf_ptr = who_am_i;
  229.             buf_ptr += 56;
  230.             for (ptr = 0; ptr < 5; ptr++)
  231.                 *buf_ptr++ = ' ';
  232.             sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  233.         }
  234. next_read:
  235.         ++line_cnt;
  236.     }            /* end of while (fpt) */
  237.     fclose(fpt);
  238.  
  239.     if (line_cnt <= 1)
  240.         return;
  241.  
  242.  
  243.     for (index_value = 1; index_value < line_cnt; index_value++) {
  244.         if (dir_priv[index_value] <= user_priv) {
  245.             parse_arg(f_lines[index_value]);
  246.             hdrread();
  247.             portsout("\n\rMail check for area '");
  248.             portsout(who_am_I);
  249.             portsout("'\n\r");
  250.             mail_to_you();
  251.             portsout("\n\r*************************************************\n\r");
  252.         }
  253.     }
  254. /*                      SIG checking                         */
  255.     strcpy(buf128, SIGS);
  256.  
  257.     if ((fpt = fopen(buf128, "r")) == NULL) {
  258.         fclose(fpt);
  259.         return;      /* No sigs */
  260.     }
  261.     line_cnt = 0;
  262.     while (fpt) {
  263.         zfl(f_lines[line_cnt], 83);
  264.         if ((fgets(f_lines[line_cnt], 82, fpt)) == NULL) {
  265.             if (line_cnt == 0) {
  266.                 portsout("\n\rEOF Unexpected in SIG Area List: Notify Sysop!\n\r");
  267.                 return (-1);
  268.             }
  269.             break;    /* if not 1st line */
  270.         }        /* end of if ((fgets)) */
  271.         if (line_cnt > 0) {
  272.             length = strlen(f_lines[line_cnt]);
  273.             length -= 74;
  274.             if(length > 6)
  275.                 length = 6;
  276.             substr(f_lines[line_cnt], dir_priv_ascii, 74, length);
  277.             strl = strlen(dir_priv_ascii);
  278.             if (strl == 0) {
  279.                 portsout("\n\rError reading privilege level\n\r");
  280.                 exit(1);
  281.             }
  282.             char_ptr = strchr(dir_priv_ascii, '*');
  283.             if (char_ptr != NULL) {
  284.                 *char_ptr = '\0';
  285.             }
  286.             dir_priv[line_cnt] = atoi(dir_priv_ascii);
  287.             if (dir_priv[line_cnt] > user_priv)
  288.                 goto next_read_sig;
  289.             strcpy(who_am_i, f_lines[line_cnt]);
  290.             buf_ptr = who_am_i;
  291.             buf_ptr += 73;
  292.             for (ptr = 0; ptr < 5; ptr++)
  293.                 *buf_ptr++ = ' ';
  294.             sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  295.         }
  296. next_read_sig:
  297.         ++line_cnt;
  298.     }            /* end of while (fpt) */
  299.     fclose(fpt);
  300.  
  301.     if (line_cnt <= 1)
  302.         return;
  303.  
  304.  
  305.     for (index_value = 1; index_value < line_cnt; index_value++) {
  306.         if (dir_priv[index_value] <= user_priv) {
  307.             parse_arg(f_lines[index_value]);
  308.             strcat(m_pathname, "msgs/");
  309.             hdrread();
  310.             portsout("\n\rMail check for SIG area '");
  311.             portsout(who_am_I);
  312.             portsout("'\n\r");
  313.             mail_to_you();
  314.             portsout("\n\r*************************************************\n\r");
  315.         }
  316.     }
  317. /*                   End of SIG checking                     */
  318. }
  319. check_msga_n()
  320. {
  321.     FILE           *fpt, *fopen();
  322.     char           *fgets(), *getenv();
  323.     char            choice[4];
  324. #ifndef SYSV
  325.     char            dir_priv_ascii[7];
  326. #endif
  327. #ifdef SYSV
  328.     char            dir_priv_ascii[20];
  329. #endif
  330.     char           *buf_ptr, *file_ptr, *char_ptr;
  331.     int             line_cnt, ret, i;
  332.     int             index_value, ptr;
  333.     int             length, strl, ii;
  334.  
  335.  
  336.     strcpy(buf128, MSGS);
  337.  
  338.     if ((fpt = fopen(buf128, "r")) == NULL) {
  339.         portsout("\n\rError Opening File Area List: Notify Sysop!\n\r");
  340.         return (-1);
  341.     }
  342.     line_cnt = 0;
  343.     while (fpt) {
  344.         zfl(f_lines[line_cnt], 81);
  345.         if ((fgets(f_lines[line_cnt], 80, fpt)) == NULL) {
  346.             if (line_cnt == 0) {
  347.                 portsout("\n\rEOF Unexpected in Message Area List: Notify Sysop!\n\r");
  348.                 return (-1);
  349.             }
  350.             break;    /* if not 1st line */
  351.         }        /* end of if ((fgets)) */
  352.         if (line_cnt > 0) {
  353.             length = strlen(f_lines[line_cnt]);
  354.             length -= 57;
  355.             if(length > 6)
  356.                 length = 6;
  357.             substr(f_lines[line_cnt], dir_priv_ascii, 57, length);
  358.             strl = strlen(dir_priv_ascii);
  359.             if (strl == 0) {
  360.                 portsout("\n\rError reading privilege level\n\r");
  361.                 exit(1);
  362.             }
  363.             char_ptr = strchr(dir_priv_ascii, '*');
  364.             if (char_ptr != NULL) {
  365.                 strcpy(c_pathname, ORGPATH);
  366.                 file_ptr = (c_pathname + strlen(c_pathname));
  367.                 ii = 0;
  368.                 while (f_lines[line_cnt][ii] != ' ') {
  369.                     *file_ptr = f_lines[line_cnt][ii];
  370.                     ++file_ptr;
  371.                     ++ii;
  372.                 }
  373.                 *file_ptr = '/';
  374.                 ++file_ptr;
  375.                 *file_ptr = '\0';
  376.                 *char_ptr = '\0';
  377.             }
  378.             dir_priv[line_cnt] = atoi(dir_priv_ascii);
  379.             if (dir_priv[line_cnt] > user_priv)
  380.                 goto next_read_n;
  381.             strcpy(who_am_i, f_lines[line_cnt]);
  382.             buf_ptr = who_am_i;
  383.             buf_ptr += 56;
  384.             for (ptr = 0; ptr < 5; ptr++)
  385.                 *buf_ptr++ = ' ';
  386.             sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  387.         }
  388. next_read_n:
  389.         ++line_cnt;
  390.     }            /* end of while (fpt) */
  391.     fclose(fpt);
  392.  
  393.     if (line_cnt <= 1)
  394.         return;
  395.  
  396.  
  397.     for (index_value = 1; index_value < line_cnt; index_value++) {
  398.         if (dir_priv[index_value] <= user_priv) {
  399.             parse_arg(f_lines[index_value]);
  400.             hdrread();
  401.         }
  402.     }
  403. }
  404.