1: #ifndef lint
   2: static char *sccsid = "@(#)group.c	1.4	(Berkeley) 3/6/86";
   3: #endif
   4: 
   5: #include "common.h"
   6: 
   7: /*
   8:  * GROUP newsgroup
   9:  *
  10:  * Change the current group to the specified newsgroup.
  11:  * We also change our current directory to that newsgroup if
  12:  * a spool directory for it exists.
  13:  * If the newsgroup specified is invalid, the old newsgroup
  14:  * remains selected.
  15:  */
  16: 
  17: group(argc, argv)
  18: int argc;
  19: char    *argv[];
  20: {
  21:     char    temp_dir[256];
  22:     int high_msg, low_msg;
  23:     char    *cp;
  24: 
  25:     if (argc != 2) {
  26:         printf("%d Group requires one argument.\r\n", ERR_CMDSYN);
  27:         (void) fflush(stdout);
  28:         return;
  29:     }
  30: 
  31:     if (!canread) {
  32:         printf("%d You only have permission to transfer, sorry.\r\n",
  33:             ERR_ACCESS);
  34:         (void) fflush(stdout);
  35:         return;
  36:     }
  37: 
  38:     if (index(argv[1], '/') != (char *) NULL) {
  39:         printf("%d Invalid group name.\r\n", ERR_NOGROUP);
  40:         (void) fflush(stdout);
  41:         return;
  42:     }
  43: 
  44:     if (find_group(argv[1], num_groups, &low_msg, &high_msg) < 0) {
  45:         printf("%d Invalid group name.\r\n", ERR_NOGROUP);
  46:         (void) fflush(stdout);
  47:         return;
  48:     }
  49: 
  50:     close_crnt();
  51:     (void) chdir(homedir);
  52: 
  53: #ifdef LOG
  54:     syslog(LOG_INFO, "%s group %s", hostname, argv[1]);
  55: #endif
  56: 
  57:     while ((cp = index(argv[1], '.')) != (char *) NULL)
  58:         *cp = '/';
  59: 
  60:     (void) strcpy(temp_dir, homedir);
  61:     (void) strcat(temp_dir, argv[1]);
  62: 
  63:     /*
  64: 	 * (void) because a group can be in the active file
  65: 	 * but not have a spool directory.  Just leave us
  66: 	 * chdired to homedir if this fails.
  67: 	 */
  68:     (void) chdir(temp_dir);
  69: 
  70: #ifdef LOG
  71:     ++grps_acsd;
  72: #endif
  73: 
  74:     num_arts = scan_dir(low_msg, high_msg);
  75:     art_ptr = 0;
  76: 
  77:     ingroup = 1;
  78: 
  79:     while ((cp = index(argv[1], '/')) != (char *) NULL)
  80:         *cp = '.';
  81: 
  82:     printf("%d %d %d %d %s\n",
  83:         OK_GROUP,
  84:         num_arts,
  85:         (num_arts > 0 ? art_array[0] : 0),
  86:         (num_arts > 0 ? art_array[num_arts-1] : 0),
  87:         argv[1]);
  88:     (void) fflush(stdout);
  89: }

Defined functions

group defined in line 17; used 1 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1986-03-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1080
Valid CSS Valid XHTML 1.0 Strict