GDXBBS -- A unix bbs gdxbbs/part03 (of 4)

Jay A. Snyder jay at gdx.UUCP
Thu Jan 17 15:34:23 AEST 1991


Submitted-by: root at gdx
Archive-name: gdxbbs/part03

---- Cut Here and unpack ----
#!/bin/sh
# this is gdxbbs.03 (part 3 of gdxbbs)
# do not concatenate these parts, unpack them in order with /bin/sh
# file mail.c continued
#
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
if test ! -r @shar_seq_.tmp; then
	echo "Please unpack part 1 first!"
	exit 1
fi
(read Scheck
 if test "$Scheck" != 3; then
	echo "Please unpack part $Scheck next!"
	exit 1
 else
	exit 0
 fi
) < @shar_seq_.tmp || exit 1
echo "x - Continuing file mail.c"
sed 's/^X//' << 'SHAR_EOF' >> mail.c &&
X	case 'p': /* read mail from current public message area */
X	  if ((msg_area=cur_msg_area)==NULL)
X	    return(-1);
X	  priv_mail=0;
X	  break;
X	case 'a': /* select message area */
X	  strcpy(marea,optarg);
X	  stripquote(marea);
X	  if ((msg_area=(AREA *) find_msg_area(marea))==NULL)
X	    return(-1);
X	  if (!area_priv(msg_area))
X	    return(-1);
X	  priv_mail=0;
X	  break;
X	default: break;
X	}
X    }
X  i=1;ii=0;
X  send_list[0]=0;
X  while (i<argc && ii<80)
X    {
X      if (argv[i][0]!='-')
X	{
X	  strcpy(&send_list[ii],argv[i]);
X	  ii=ii+strlen(argv[i]);
X	  send_list[ii++]=' ';
X	  send_list[ii]=0;
X	}
X      ++i;
X    }
X  while (send_list[0]==0)
X    {
X      portsout("\rTo: ");
X      if (getline(send_list,160)==3) return(1);
X      portout('\n');
X      if (send_list[0]==0)
X	{
X	  if (!priv_mail)
X	    strcpy(send_list,"All");
X	  else
X	    {
X	      portsout("You must specify who to send to.\n");
X	      portsout("or hit Control-C to cancel.\n");
X	    }
X	}
X    }
X  if (subject[0]==0)
X    {
X      portsout("\rSubject: ");
X      if (getline(subject,79)==3) return(1);
X      portout('\n');
X    }
X  sprintf(filename,"/tmp/mtmp.%s",thistty);
X  remove(filename);
X  if ((fp=fopen(filename,"w"))==NULL)
X    return(1);
X  fprintf(fp,"To: %s\n",send_list);
X  fprintf(fp,"Subject: %s\n",subject);
X  fprintf(fp,"==== text follows this line ====\n");
X  fclose(fp);
X  if (terminfo_mode && fsedit[0])
X    {
X      sprintf(str,"%s %s",fsedit,filename);
X      systemx(str);
X    }
X  else
X    {
X      sprintf(str,"cat >>%s",filename);
X      portsout("Enter message, then end with ^D\n");
X      systemx(str);
X    }
X  portsout("\n[sending message]");
X  sendmailfile(filename,msg_area);
X  portsout("\r[message sent]   \n");
X  remove(filename);
X} /* sendmail */
X
X/*
X  process message
X    filename == file where message is stored
X    marea == message area to send it in ("" for private mail)
X*/
Xsendmailfile(filename,msg_area)
X     char *filename;
X     AREA *msg_area;
X{
X  FILE *fp,*fp1;
X  char filename1[60],s[255],*to_ptr,to[160],subject[66];
X  char msg_file[80],*mfptr,c;
X  sprintf(filename1,"/tmp/mtmp2.%s",thistty);
X  remove(filename1);
X  if ((fp=fopen(filename,"r"))==NULL)
X    return(1);
X  if ((fp1=fopen(filename1,"w"))==NULL)
X    return(1);
X  s[0]=0;
X  fscanf(fp,"%[^:\n]",s);
X  c=fgetc(fp);
X  fscanf(fp,"%*[ \n]");
X  if (!strcmp(s,"To") && c==':')
X    {
X      myfgets(to,159,fp);
X    }
X  s[0]=0;
X  fscanf(fp,"%*[ \n]");
X  fscanf(fp,"%[^:\n]",s);
X  c=fgetc(fp);
X  subject[0]=0;
X  if (!strcmp(s,"Subject") && c==':')
X    {
X      myfgets(subject,79,fp);
X    }
X  else if (c==':') fscanf(fp,"%*[^\n]"); /* skip reset of line */
X  mail_header(s,to,subject);
X  fprintf(fp1,"%s\n",s);
X  while(!feof(fp)) /* skip the "==== text.." */
X    {
X      s[0]=0;
X      fscanf(fp,"%[^\n]",s);
X      fgetc(fp);
X      if ((s[0]=='=' && s[1]=='=' && s[2]=='=' && s[3]=='='))
X	break;
X    }
X  while(!feof(fp))
X    {
X      s[0]=0;
X      fgets(s,254,fp);
X      if (!feof(fp))
X      fputs(s,fp1);
X    }
X  fclose(fp);
X  fclose(fp1);
X  if (msg_area!=NULL)
X    {
X      strcpy(to,msg_area->file);
X    }
X  to_ptr=to;
X  while (*to_ptr)
X    {
X      mfptr=msg_file;
X      while(*to_ptr && isspace(*to_ptr)) ++to_ptr; /* skip white space */
X      while(*to_ptr && *to_ptr!=',') /* skip to comma */
X	{
X	  *mfptr++=*to_ptr++;
X	}
X      if (*to_ptr==',') ++to_ptr;
X      *mfptr=0;
X      if (msg_area==NULL)
X	{
X	  kill_trailing_space(msg_file);
X	  if (chk_name(msg_file)==NULL)
X	    {
X	      portsout("\nInvalid username in send list: \"");
X	      portsout(msg_file);
X	      portsout("\"\n");
X	      mfptr=NULL;
X	    }
X	  else
X	    {
X	      cvt_spc(msg_file);
X	      sprintf(s,"%s/%s",mail_dir,msg_file);
X	      mfptr=s;
X	    }
X	}
X      else mfptr=msg_file;
X      if (mfptr!=NULL)
X	if (append_file(filename1,mfptr))
X	  {
X	    return(1);
X	  }
X    } /* end while */
X/*   pause(); */
X  remove(filename1);
X}
X
Xint chk_mail_cmd(str)
Xchar *str;
X{
X  char *s,**p;
X  p=(char **) bsearch(&str,mailcmds,MAILCMDCOUNT,sizeof(char *),str_cmp);
X  if (p==NULL) return(-1);
X  return ((int) (p-mailcmds));
X}
X
X
Xindex_msg_file(fp)
X     FILE *fp;
X{
X  int index;
X  char q;
X  index=0;
X  q=0;
X  while (!feof(fp) && (index<MAXMSG) && !q)
X    {
X      q=mail_seek(fp,1);
X      if (q || feof(fp)) break;
X      msg_ptrs[index]=(long int) ftell(fp);
X      ++index;
X    }
X  msg_count=index;
X  fseek(fp,msg_ptrs[0],SEEK_SET); /* goto beginning of file */
X  cur_msg=0;
X}
X
XFILE *mailopen(filename,access)
X     char *filename,*access;
X{
X  FILE *fp;
X  if (msg_ptrs!=NULL)
X    {
X      errorsout("mailopen: mail file already open\n");
X      return(NULL);
X    }
X  if ((msg_ptrs=(long int *) calloc(MAXMSG,sizeof(long int)))==NULL)
X    {
X      errorsout("! mailopen: calloc failed.\n");
X      fatal_error(MALLOC_ERROR);
X    }
X  if ((fp=fopen(filename,access))==NULL) /* re-write pointer at beginning of file */
X    {
X      free(msg_ptrs);
X      msg_ptrs=NULL;
X      return(NULL);
X    }
X  index_msg_file(fp);
X  return(fp);
X}
X
Xmailclose(fp)
X{
X  fclose(fp);
X  free(msg_ptrs);
X  msg_ptrs=NULL;
X}
X
Xmail(argc,argv)
X     int argc;
X     char **argv;
X{
X  int x;
X  x=22;
X  while (x==22)
X    x=_mail(argc,argv);
X  return(x);
X}
X
X/*
X  mail user --> send private mail to user
X  mail --> read/send private mail
X  mail -w message area --> read/send messages in message area
X  mail -q check for mail
X*/
X_mail(argc,argv)
X     int argc;
X     char **argv;
X{
X  FILE *fp;
X  m_entry_ptr entry;
X  char s[80],q,input[80],marea[80];
X  char *av[20];
X  AREA *msg_area;
X  char msg_file[80],priv_mail;
X  extern char *optarg;
X  extern int optind;
X  char sendmail_flag,hdr_only;
X  int ac,sel,i,tmp;
X
X  cur_msg=0; /* set current message to first message */
X  priv_mail=1;
X  sendmail_flag=0;
X  hdr_only=0;
X  msg_area=NULL;
X  optind=1;
X  while ((i=getopt(argc,argv,"S:shpa:q"))!=EOF)
X    {
X      switch (i)
X	{
X	case 's': /* send mail */
X	  sendmail_flag=1;
X	  break;
X	case 'q': /* check for mail */
X	  if (filesize(priv_mail_file(msg_file))>0)
X	    rprintf("You have mail.\n");
X	  return(0);
X	  break;
X	case 'h': /* list headers only */
X	  hdr_only=1;
X	  break;
X	case 'p': /* read mail from current public message area */
X	  msg_area=cur_msg_area;
X	  if (msg_area==NULL)
X	    {
X	      ac=1;
X	      av[0]="chma";
X	      chma(ac,av);
X	      return(22);
X	    }
X	  priv_mail=0;
X	  break;
X	case 'a': /* select message area */
X	  strcpy(marea,optarg);
X	  stripquote(marea);
X	  msg_area=(AREA *) find_msg_area(marea);
X	  if (msg_area==NULL)
X	    {
X	      portsout("Invalid message area.\n");
X	      return(-1);
X	    }
X	  if (!area_priv(msg_area))
X	    {
X	      portsout("Sorry, you don't have access to message base: ");
X	      boldon();
X	      portsout(msg_area->name);
X	      boldoff();
X	      portout('\n');
X	      return(-1);
X	    }
X	  priv_mail=0;
X	  break;
X	default: break;
X	}
X    }
X  if (sendmail_flag)
X    {
X      sendmail(argc,argv);
X      return(0);
X    }
X  /* else the user is attempting to read his/her private mail */
X  if (priv_mail)
X    {
X      priv_mail_file(msg_file);
X      mdate=&maildate;
X    }
X  else
X    {
X      strcpy(msg_file,msg_area->file);
X      mdate=(&msg_area->tm);
X    }
X  if ((fp=mailopen(msg_file,"r+"))==NULL)
X    {
X      sprintf(s,"! Cannot open mail file:%s\n",msg_file);
X      errorsout(s);
X      return(-1);
X    }
X  if (priv_mail) print_headers(fp,priv_mail,maildate);
X /* don't go into interactive if headers only */
X  if (hdr_only)
X    {
X      mailclose(fp);
X      return(0);
X    }
X  q=0;
X  cur_msg=-1; /* so N)ext will read the first message */
X  while (!q)
X    {
X      print_menu((priv_mail) ? mail_menu_ptr : pubmsg_menu_ptr);
X      boldoff();
X      setcolor(BRWHITE,BLACK);
X      portsout(prompt);
X      boldon();
X      setcolor(YELLOW,BLACK);
X      input[0]=0;
X      while (getline(input,79)==3)
X	{
X	  setcolor(BRWHITE,BLACK);
X	  portsout(prompt);
X	  boldon();
X	  setcolor(YELLOW,BLACK);
X	  input[0]=0;
X	}
X      boldoff();
X      setcolor(LTGREEN,BLACK);
X      if (input[0]==0)
X	strcpy(s,"n"); /* default next */
X      else
X	strcpy(s,input);
X      portout('\n');
X      /*  if (strlen(input)>3 && line_change)
X	  push_line(input); */
X      parse_line(&ac,av,s);
X      if ((entry=chk_entry(av[0][0],((priv_mail) ? mail_menu_ptr : pubmsg_menu_ptr)))!=NULL)
X	/* process menu selection */
X	{
X	  av[0]=entry->cmd;
X	}
X      if (av[0][0]=='!')
X	{
X	  unparse_line(ac,av,input);
X	  run_line(&input[1]);
X	}
X      else
X	{
X	  sel=chk_mail_cmd(av[0]);
X	  switch(sel)
X	    {
X	    case 0: /* '*' reread current message */
X	      if (cur_msg<0) cur_msg=0;
X	      fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X	      disp_msg(fp,priv_mail);
X	      break;
X	    case 1: /* chma, change message area */
X	      mailclose(fp);
X	      chma(ac,av);
X	      return(22); /* 22 is code to reenter read mail */
X	      break;
X	    case 2: /* delete message */
X	      tmp=cur_msg;
X	      if (ac>1)
X		tmp=atoi(av[1])-1;
X	      if (tmp<0)
X		portsout("No current message.\n");
X	      else if (tmp<msg_count)
X		{
X		  if (priv_mail || chk_del_perm(fp,tmp))
X		    /* check if message is to or from user */
X		    {
X		      delmarkmsg(fp,tmp);
X		      rprintf("Message %d deleted.\n",tmp+1);
X		    }
X		  else
X		    {
X		      portsout("Sorry, you cannot delete a message than isn't\n");
X		      portsout("from you or exclusively to you.\n");
X		    }
X		}
X	      else
X		portsout("Invalid message number.\n");
X	      break;
X	    case 3: /* headers */
X	      print_headers(fp,priv_mail,(time_t) 0);
X	      break;
X	    case 4: /* help */
X	      ac=2;
X	      av[0]=("help");
X	      av[1]=("mail");
X	      help(ac,av);
X	      break;
X	    case 5: /* logout */
X	      q=2;
X	      break;
X	    case 6: /* newscan */
X	      print_headers(fp,priv_mail,*mdate);
X	      break;
X	    case 7: /* next */
X	      if (ac<2) /* display next msg */
X		{
X		  if (cur_msg==-1)
X		    {
X		      cur_msg=0;
X		      fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X		      while ((cur_msg<msg_count) && (msg_date(fp) <= *mdate))
X			{
X			  ++cur_msg;
X			  fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X			}
X		      if (cur_msg==msg_count)
X			{
X			  portsout("No new messages.\n");
X			  break;
X			}
X		      else
X			{
X			  fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X			  disp_msg(fp,priv_mail);
X			  break;
X			}
X		    }
X		  if (cur_msg<msg_count-1)
X		    {
X		      ++cur_msg;
X		      fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X		      disp_msg(fp,priv_mail);
X		    }
X		  else
X		    portsout("No more messages.\n");
X		}
X	      else /* take argument as msg # */
X		{
X		  tmp=atoi(av[1]);
X		  if (!(tmp>msg_count) && tmp)
X		    {
X		      cur_msg=tmp;
X		      fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X		      disp_msg(fp,priv_mail);
X		    }
X		  else
X		    portsout("Invalid message number\n");
X		}
X	      break;
X	    case 8: /* prev */
X	      if (cur_msg<1)
X		portsout("No previous message\n");
X	      else
X		{
X		  disp_msg(fp,priv_mail);
X		  --cur_msg;
X		  fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X		  disp_msg(fp,priv_mail);
X		}
X	      break;
X	    case 9: /* quit */
X	      q=1;
X	      break;
X	    case 10: /* reply */
X	      if (cur_msg<0)
X		portsout("No current message.\n");
X	      else
X		{
X		  fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X		  replymail(fp,msg_area);
X		}
X	      break;
X	    case 11: /* send */
X	      if (priv_mail) sendmail(ac,av);
X	      else
X		{
X		  sprintf(str,"mail -s -a%s",msg_area->name);
X		  run_line(str);
X		}
X	      break;
X	    default:
X	      if (ac!=0)
X		{
X		  tmp=atoi(av[0]);
X		  if (tmp<=msg_count && tmp)
X		    {
X		      cur_msg=tmp-1;
X		      fseek(fp,msg_ptrs[cur_msg],SEEK_SET);
X		      disp_msg(fp,priv_mail);
X		    }
X		  else
X		    portsout("Invalid message number\n");
X		}
X	    }
X	} /* else */
X    } /* while */
X  mailclose(fp);
X  if (priv_mail) /* don't pack a public message base */
X    pack_msgfile(msg_file);
X  if (q==2) logout(ac,av);
X}
X
Xchar *priv_mail_file(s) /* return path name of user's mail file */
X     char *s;
X{
X  char tmp[80];
X  strcpy(tmp,MYNAME);
X  cvt_spc(tmp);
X  sprintf(s,"%s/%s",mail_dir,tmp);
X  return(s);
X}
X
Xcvt_spc(sp)
X  char *sp;
X{
X  char q;
X  q=0;
X  strdncase(sp);
X  *sp=toupper(*sp);
X  *sp=(char) toupper((char) *sp);
X  while (*sp)
X    {
X      if (*sp==' ')
X	{
X	  if (!q)
X	    {
X	      *sp='_';
X	      q=1;
X	      if (sp[1]) sp[1]=toupper(sp[1]);
X	    }
X	  else
X	    {
X	      *sp=0;
X	      break;
X	    }
X	}
X      ++sp;
X    }
X}
X
X
Xmscan(argc,argv)
X     int argc;
X     char *argv[];
X{
X}
SHAR_EOF
echo "File mail.c is complete" &&
$TOUCH -am 0107001191 mail.c &&
chmod 0644 mail.c ||
echo "restore of mail.c failed"
set `wc -c mail.c`;Wc_c=$1
if test "$Wc_c" != "20376"; then
	echo original size 20376, current size $Wc_c
fi
# ============= packmsg.c ==============
echo "x - extracting packmsg.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > packmsg.c &&
X/*
X  GDX-BBS V1.0 Beta
X  (C) 1990
X  Jay A. Snyder
X*/
X
X#ifndef PACKMAIN
X#include "inc.h"
X#endif
X
X_pack_msgfile(fpin,fpout)
X  FILE *fpin, *fpout;
X{
X  char s[255];
X  while (!feof(fpin))
X    {
X      s[0]=0;
X      fgets(s,254,fpin);
X      if (!strcmp(s,"####~~~~\n"))  /* deleted message */
X	{
X	  if (mail_seek(fpin,1)!=EOF)
X	    fseek(fpin,-4L,SEEK_CUR);
X	  else break;
X	}
X      else
X	fputs(s,fpout);
X    }
X}
X
Xpack_msgfile(filename)
X     char *filename;
X{
X  FILE *fpin, *fpout;
X  char tmpfile[50],s[50];
X  /* note that temporary file must be in same directory as
X     mail file, so that they are guarenteed to be on the
X     same filesystem, so that rename() will work properly
X  */
X  sprintf(tmpfile,"%s/mtmp.%s",dirname(filename,s),thistty);
X  if ((fpout=fopen(tmpfile,"w"))==NULL)
X    {
X#ifdef PACKMAIN
X      printf(stderr,"! cannot open temporyary file!\n");
X#else      
X      errorsout("! cannot open temporyary file!\n");
X#endif
X      return(1);
X    }
X  if ((fpin=fopen(filename,"r"))!=NULL)
X    {
X      _pack_msgfile(fpin,fpout);
X      fclose(fpin);
X      fclose(fpout);
X      remove(filename);
X      rename(tmpfile,filename);
X      return(0);
X    }
X  else
X    {
X      sprintf(str1,"! Cannot open mail file %s\n",filename);
X#ifdef PACKMAIN
X      printf(stderr,str1);
X#else
X      errorsout(str1);
X#endif
X      fclose(fpout);
X      return(-1);
X    }
X}
X
X
SHAR_EOF
$TOUCH -am 0507213390 packmsg.c &&
chmod 0644 packmsg.c ||
echo "restore of packmsg.c failed"
set `wc -c packmsg.c`;Wc_c=$1
if test "$Wc_c" != "1355"; then
	echo original size 1355, current size $Wc_c
fi
# ============= atout.c ==============
echo "x - extracting atout.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > atout.c &&
X/*
X  GDX-BBS V1.0 Beta
X  (C) 1990
X  Jay A. Snyder
X*/
X
X#include "inc.h"
X
Xint str_cmp();
X
Xchar *colors[]={"black","blue","brown","brwhite","cyan","gray",
X		  "green","ltblue","ltcyan","ltgreen","ltmagenta",
X		  "ltred","magenta","red","white","yellow","\377\377"};
Xchar color_nums[]={0,4,3,15,6,8,2,12,14,10,13,9,5,1,7,11};
X#define COLORCOUNT 17 /* 16 + the \377\377 */
X
Xchar *atcmds[]={
X  "$", /* @$(variable) display value of envinronment variable */
X  "blink", /* @blink(text) display text in blinking type */
X  "bold", /* @bold(text) display text in bold type */
X  "clear", /* clear screen */
X  "color", /* @color(forecolor,backcolor)  set screen color */
X  "curfilearea", /* show current file area */
X  "curmsgarea", /* show current message area */
X  "date", /* show current date and time */
X  "myname", /* show user's name */
X  "normal", /* return to normal vidmode */
X  "pause", /* do a more prompt */
X  "reverse", /* @reverse(text) display text in reverse video */
X  "sysop", /* sysop's name */
X  "version", /* logo and version of program */
X  "\377\377"
X};
X#define ATCMDCOUNT (int) sizeof(atcmds)/sizeof(char *)
X
Xint color_num(str)
X     char *str;
X{
X  char *s,**p;
X  p=(char **) bsearch(&str,colors,COLORCOUNT,sizeof(char *),str_cmp);
X  if (p==NULL) return(-1);
X  return (color_nums[(int) (p-colors)]);
X}
X     
Xat_set_color(s)
X     char *s;
X{
X  int f,b;
X  char fc[20],bc[20];
X  if (!color_mode) return;
X  fc[0]=0;bc[0]=0;
X  sscanf(s,"%[^ ,)]%*[ ,]%[^ )]",fc,bc);
X  if (fc[0]!=0) 
X    f=color_num(fc);
X  else f=cur_forecolor;
X  if (bc[0]!=0) 
X    b=color_num(bc);
X  else b=cur_backcolor;
X  setcolor(f,b);
X}
X
Xchar *scan_arg(s,rs)
X     char *s,*rs;
X{
X  int nest;
X  nest=1;
X  if (*s!='(')
X    {
X      rs[0]=0;
X      return(s);
X    }
X  ++s;
X  while (nest)
X    {
X      if (*s=='(') ++nest;
X      if (*s==')') --nest;
X      if (nest)
X	*rs++=*s++;
X    }
X  *rs=0;
X  ++s;
X  return(s);
X}
X
Xint chk_at_cmd(str)
Xchar *str;
X{
X  char *s,**p;
X  p=(char **) bsearch(&str,atcmds,ATCMDCOUNT,sizeof(char *),str_cmp);
X  if (p==NULL) return(-1);
X  return ((int) (p-atcmds));
X}
X
X
X
X/*
X  output a string to the port, translating @commands
X*/
Xatout(s)
X     char *s;
X{
X  int x;
X  char ss[80];
X  char atcmd[80],*sptr;
X  while (*s)
X    {
X      if (*s !='@') fputc(*s++,stdout);
X      else
X	{
X	  ++s;
X	  if ((*s)=='@') fputc(*s++,stdout);
X	  else
X	    {
X	      sptr=atcmd;
X	      while (*s!='(' && !isspace(*s) && !ispunct(*s) && *s)
X		{
X		  *sptr++=*s++;
X		}
X	      *sptr=0;
X	      x=chk_at_cmd(atcmd);
X	      switch(x)
X		{
X		case 0: /* env var */
X		  if (*s=='(')
X		    {
X		      s=scan_arg(s,ss);
X		      if ((sptr=getenv(ss))!=NULL)
X			atout(sptr);
X		    }
X		  break;
X		case 1: /* blink */
X		  blinkon();
X		  if (*s=='(')
X		    {
X		      s=scan_arg(s,ss);
X		      atout(ss);
X		      blinkoff();
X		    }
X		  break;
X		case 2: /* bold */
X		  xboldon();
X		  if (*s=='(')
X		    {
X		      s=scan_arg(s,ss);
X		      atout(ss);
X		      boldoff();
X		    }
X		  break;
X		case 3: /* clear */
X		  cls();
X		  break;
X		case 4: /* color */
X		  s=scan_arg(s,ss);
X		  at_set_color(ss);
X		  break;
X		case 5: /* cur-file-area */
X		  if (cur_file_area!=NULL)
X		    portsout(cur_file_area->name);
X		  break;
X		case 6: /* cur-msg-area */
X		  if (cur_msg_area!=NULL)
X		    portsout(cur_msg_area->name);
X		  break;
X		case 7: /* date */
X		  portsout((char *) timestr());
X		  break;
X		case 8: /* myname */
X		  portsout(MYNAME);
X		  break;
X		case 9: /* normal */
X		  normattr();
X		  break;
X		case 10: /* pause */
X		  pause();
X		  break;
X		case 11: /* reverse */
X		  reverseon();
X		  if (*s=='(')
X		    {
X		      s=scan_arg(s,ss);
X		      atout(ss);
X		      reverseoff();
X		    }
X		  break;
X		case 12:
X		  portsout(sysop_name);
X		  break;
X		case 13:
X		  ver();
X		  break;
X		default:
X		  portsout("[invalid @command:");
X		  portsout(atcmd);
X		  portsout("]");
X		}
X	    }
X	}
X    }
X}
X
SHAR_EOF
$TOUCH -am 0514161690 atout.c &&
chmod 0644 atout.c ||
echo "restore of atout.c failed"
set `wc -c atout.c`;Wc_c=$1
if test "$Wc_c" != "3833"; then
	echo original size 3833, current size $Wc_c
fi
# ============= term.c ==============
echo "x - extracting term.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > term.c &&
X/*
X  GDX-BBS V1.0 Beta
X  (C) 1990
X  Jay A. Snyder
X*/
X
X#include "inc.h"
X
Xextern rawortout();
Xshort ospeed;
X
Xrawportout(c)
X     char c;
X{
X  putchar(c);
X  if (monitor_on)
X    fputc(c,monfp);
X}
X
Xrawportsout(s)
X     char *s;
X{
X  while (*s) rawportout(*s++);
X}
X
X
X
Xportsout(s)
X     char *s;
X{
X#ifdef USECURSES
Xif (curses_init)
X  {
X   /* printw("%s",s); */
X    addstr(s);
X    refresh();
X  }
Xelse
X#endif
X  rawportsout(s);
X}
X     
X
Xportout(c)
Xchar c;
X{
X#ifdef USECURSES
X if (curses_init)
X  {
X    addch(c);
X    refresh();
X  }
Xelse
X#endif
X  rawportout(c);
X}
X
Xchar portin()
X{
X  char c;
X  c=-1;
X  idletime=0;
X  alarm_on();
X#ifdef SCO || XENIX
X  while (c<=0)
X#endif
X    {
X#ifdef USECURSES
X      if (curses_init) c=(wgetch(stdscr));
X      else
X#endif
X	c=fgetc(stdin);
X    }
X  alarm_off();
X  return(c);
X}
X
X
X
Xgetcaps()
X{
X  char *area;
X  char err;
X  area=capbuf;
X  termset=1;
X  err=tgetent(tb,term);
X  if (err!=1)
X    {
X      error_message(BAD_TERM);
X      portsout("Terminal cannot support cursor movement.\n");
X      portsout("Full screen options cannot be used.\n");
X      termset=0;
X      return;
X    }
X  AL=tgetstr("al",&area);
X  BC=tgetstr("bc",&area);
X  CD=tgetstr("cd",&area);
X  CE=tgetstr("ce",&area);
X  CL=tgetstr("cl",&area);
X  CO=tgetnum("co");
X  CM=tgetstr("cm",&area);
X  DC=tgetstr("dc",&area);
X  DL=tgetstr("dl",&area);
X  DM=tgetstr("dm",&area);
X  ED=tgetstr("ed",&area);
X  EI=tgetstr("ei",&area);
X  IC=tgetstr("ic",&area);
X  IM=tgetstr("im",&area);
X  IP=tgetstr("ip",&area);
X  LI=tgetnum("li");
X  MB=tgetstr("mb",&area);
X  MD=tgetstr("md",&area);
X  ME=tgetstr("me",&area);
X  MR=tgetstr("mr",&area);
X  PCstr=tgetstr("pc",&area);
X  SE=tgetstr("se",&area);
X  SO=tgetstr("so",&area);
X  TE=tgetstr("te",&area);
X  TI=tgetstr("ti",&area);
X  UP=tgetstr("up",&area);
X  VE=tgetstr("ve",&area);
X  VS=tgetstr("vs",&area);
X  if (PCstr!=NULL)
X    PC=PCstr[0];
X  else
X    PC='\0';
X  if (LI==-1)
X    {
X      portsout("Terminal cannot support cursor movement.\n");
X      portsout("Full screen options cannot be used.\n");
X      termset=0;
X      LI=24;
X      return(1);
X    }
X/* now we fix up for those terminals that do not have specific caps */
X  if (MD[0]==0 && SO[0]!=0) /* make bold=standout */
X    MD=SO;
X  if (MR[0]==0 && SO[0]!=0) /* make reverse=standout */
X    MR=SO;
X  if (MB[0]==0 && SO[0]!=0) /* make blink=standout */
X    MB=SO;
X  if (ME[0]==0 && SE[0]!=0) /* make attrib off=standoff */
X    ME=SE;
X}
X
Xcls()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      clear();
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      tputs(CL,1,rawportout);
X    }
X}
X
Xclreol()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      clrtoeol();
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      tputs(CE,1,rawportout);
X    }
X}
X
X_setcolor(forecolor,backcolor)
Xint forecolor,backcolor;
X{
Xchar s[10];
Xif (!color_mode) return;
Xif (forecolor<0) return;
Xif (backcolor<0) /* no change in background */
X  sprintf(s,"\033[%dm",30+(forecolor & 7));
Xelse
X  sprintf(s,"\033[%d;%dm",30+(forecolor & 7),40+(backcolor & 7));
X_normattr();
Xrawportsout(s);
Xif ((forecolor&8)==8)
X  tputs(MD,1,rawportout);
X}
X
Xsetcolor(forecolor,backcolor)
Xint forecolor,backcolor;
X{
X  cur_forecolor=forecolor;
X  cur_backcolor=backcolor;
X  _setcolor(forecolor,backcolor);
X}
X
Xfixcolor()
X{
X   _setcolor(cur_forecolor,cur_backcolor);
X}
X
Xboldon()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      attron(A_BOLD);
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      tputs(MD,1,rawportout);
X    }
X}
X
Xxboldon() /* use BRWHITE if already a bold color */
X{
X      if (color_mode)
X	{
X	  if ((cur_forecolor && 8)==0)
X	    _setcolor(cur_forecolor|8,cur_backcolor);
X	  else if (cur_forecolor==BRWHITE)
X	    _setcolor(cur_backcolor,cur_forecolor);
X	  else _setcolor(BRWHITE,cur_backcolor);
X	}
X      else
X	boldon();
X}
X
X_normattr()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      attrset(0);
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      tputs(ME,1,rawportout);
X    }
X}
X
X
Xnormattr()
X{
X    if (terminfo_mode)
X    {
X      if (color_mode) fixcolor();
X      else _normattr();
X    }
X}
X
Xboldoff()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      attroff(A_BOLD);
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      tputs(ME,1,rawportout);
X    }
Xfixcolor();
X}
X 
Xreverseon()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      attron(A_REVERSE);
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      if (color_mode)
X	_setcolor(cur_backcolor,cur_forecolor);
X      else
X	tputs(MR,1,rawportout);
X    }
X}
X
Xreverseoff()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      attroff(A_REVERSE);
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      if (color_mode)
X	fixcolor;
X      else
X	tputs(ME,1,rawportout);
X    }
Xfixcolor();
X}
X
Xblinkon()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      attron(A_BLINK);
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      tputs(MB,1,rawportout);
X    }
X}
X
Xblinkoff()
X{
X#ifdef USECURSES
X  if (curses_init)
X    {
X      attroff(A_BLINK);
X      refresh();
X    }
X  else
X#endif
X    if (terminfo_mode)
X    {
X      tputs(ME,1,rawportout);
X    }
Xfixcolor();
X}
X
Xenter_terminfo()
X{
X  setupterm((char *)0,1,(int *)0);
X  terminfo_mode=1;
X}
X
Xexit_terminfo()
X{
X  if (terminfo_mode)
X    {
X      reset_shell_mode();
X      terminfo_mode=0;
X    }
X}
X
X/* setraw()  --> put terminal in raw mode */
Xvoid setraw()
X{
X#ifndef MSDOS
X#ifdef OLDTTY
X  struct sgttyb tbuf;
X#else
X  struct termio tbuf;
X#endif
X  if (now_raw) return;
X#ifdef OLDTTY
X  if (ioctl(0,TIOCGETP, &tbuf) == -1) /* may be pipe */
X    return;
X  if (ioctl(0,TIOCGETP, &tbufsave) == -1)
X    errorsout("setraw - ioctl");
X  ospeed = tbuf.sg_ospeed;
X  tbuf.sg_flags |= RAW | CBREAK;
X  tbuf.sg_flags &= (~(CRMOD | ECHO));
X  if (ioctl(0, TIOCSETP, &tbuf) == 01)
X    errorsout("setraw - ioctl2");
X#else
X  if (ioctl(0, TCGETA, &tbuf) == -1) /* may be pipe */
X    return;
X  tbufsave = tbuf;
X  ospeed = tbuf.c_cflag & CBAUD;
X  tbuf.c_iflag &= ~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT);
X  tbuf.c_oflag |= OPOST;
X  tbuf.c_lflag &= ~(ICANON | ECHO);
X  tbuf.c_lflag |= (ISIG);
X  tbuf.c_cc[VMIN]=20; /* min */
X  tbuf.c_cc[VTIME]=2; /* time */
X  if (ioctl(0, TCSETAF, &tbuf) == -1)
X    errorsout("setraw - ioctl");
X#endif
X  now_raw=TRUE;
X#endif /* MSDOS */
X}
X
X
Xvoid unsetraw() /* restore terminal flags */
X{
X#ifndef MSDOS
X  static char first = TRUE;
X  if (!now_raw)
X    return;
X#ifdef OLDTTY
X  (void) ioctl(0,TIOCSETP,&tbufsave); /* may be pipe */
X#else
X  (void) ioctl(0,TCSETAF,&tbufsave); /* may be pipe */
X#endif
X#ifndef XENIX
X/*  setblock(0,TRUE); */
X#endif
X  now_raw=FALSE;
X#endif /* MSDOS */
X}
X
Xset_isig(isig) /* enable/disable keyboard interrupt */
X     int isig;
X{
X#ifndef MSDOS
X#ifdef OLDTTY
X  struct sgttyb tbuf;
X#else
X  struct termio tbuf;
X#endif
X#ifdef OLDTTY
X  if (ioctl(0,TIOCGETP, &tbuf) == -1) /* may be pipe */
X    return;
X#else
X  if (ioctl(0, TCGETA, &tbuf) == -1) /* may be pipe */
X    return;
X  tbuf.c_lflag &= (~ISIG);
X  if (isig)
X    tbuf.c_lflag |= (ISIG);
X  if (ioctl(0, TCSETAF, &tbuf) == -1)
X    errorsout("set_isig - ioctl");
X#endif
X#endif /* MSDOS */
X}
X
Xset_ctrl_chars()
X{
X#ifndef MSDOS
X#ifdef OLDTTY
X  struct sgttyb tbuf;
X#else
X  struct termio tbuf;
X#endif
X#ifdef OLDTTY
X  if (ioctl(0,TIOCGETP, &tbuf) == -1) /* may be pipe */
X    return;
X#else
X  if (ioctl(0, TCGETA, &tbuf) == -1) /* may be pipe */
X    return;
X  tbuf.c_cc[VINTR]='\003'; /* ^C */
X  tbuf.c_cc[VEOF]='\004'; /* ^D */
X/*  tbuf.c_cc[VERASE]='\010';*/ /* ^H */ 
X  tbuf.c_cc[VKILL]='\025'; /* ^U */
X  if (ioctl(0, TCSETAF, &tbuf) == -1)
X    errorsout("set_ctrl_chars: ioctl error!\n");
X#endif
X#endif /* MSDOS */
X}
X
SHAR_EOF
$TOUCH -am 1215083790 term.c &&
chmod 0644 term.c ||
echo "restore of term.c failed"
set `wc -c term.c`;Wc_c=$1
if test "$Wc_c" != "7639"; then
	echo original size 7639, current size $Wc_c
fi
# ============= env.c ==============
echo "x - extracting env.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > env.c &&
X/*
X  GDX-BBS V1.0 Beta
X  (C) 1990
X  Jay A. Snyder
X*/
X
X#include "inc.h"
X
X/*
X  copy current environment into local one.
X*/
Xinit_env()
X{
X  int i;
X
X  i=0;
X  local_env[0]=NULL;
X  while (environ[i]!=NULL)
X    {
X      setenv(environ[i]);
X      ++i;
X    }
X  environ=local_env;
X}
X
Xdisp_env()
X{
X  int i;
X
X  i=0;
X  while (local_env[i]!=NULL)
X    {
X      portsout(local_env[i++]);
X      portout('\n');
X    }
X}
X
Xenvcmp(s1,s2)
X     char *s1,*s2;
X{
X  char i;
X  while (!(i=*s1 - *s2) && *s1 && *s2 && *s1!='=' && *s2!='=') {++s1;++s2;}
X  return(i);
X}
X
Xchar **searchenv(value)
X     char *value;
X{
X  int i;
X  i=0;
X  while (local_env[i]!=NULL)
X    {
X      if (!envcmp(local_env[i],value)) return(&local_env[i]);
X      ++i;
X    }
X  return(NULL);
X}
X
Xsetenv(value)
X     char *value;
X{
X  int i;
X  char **oldvalue;
X  if (strchr(value,'=')==NULL) return;
X
X  if ((oldvalue=searchenv(value))!=NULL)
X    {
X      free(*oldvalue);
X    }
X  else
X    {
X      i=0;
X      while (local_env[i]!=NULL && i<MAXENV-1) ++i; /* get next available
X						       variable pointer */
X      if (i>=MAXENV-1) return(-1);
X      oldvalue=&local_env[i];
X      local_env[i+1]=NULL;
X    }
X  if ((*oldvalue=malloc(strlen(value)+1))==NULL)
X	{
X	  error_message(MALLOC_ERROR);
X	  assert(0);
X	  quit();
X	}
X  strcpy(*oldvalue,value);
X  return(0);
X}
X
Xsub_env(strin,strout)
X     char *strin,*strout;
X{
X  char var[40],*v,*v1;
X  char sstr[LINE_SIZE],*str,brace;
X  int i;
X  i=0;
X  str=sstr;
X  while (*strin && ++i<LINE_SIZE)
X    {
X      if (*strin=='$')
X	{
X	  ++strin;
X	  brace=0;
X	  v=var;
X	  if (*strin=='{')
X	    {
X	      brace=1;
X	      ++strin;
X	    }
X	  while (*strin && !isspace(*strin) && !(*strin=='}' && brace))
X	    {
X	      *v++=*strin++;
X	    }
X	  if (*strin=='}' && brace)
X	    {
X	      brace=0;
X	      ++strin;
X	    }
X	  *v=0;
X	  v1=(char *) getenv(var);
X	  if (v1!=NULL)
X	    {
X	      strcpy(str,v1);
X	      str=&str[strlen(str)];
X	    }
X	}
X      else (*str++=*strin++);
X    }
X  *str=0;
X  strcpy(strout,sstr);
X}
X
Xset(argc,argv)
X     int argc;
X     char *argv[];
X{
X  int i;
X  char s[LINE_SIZE];
X  if (argc==1)
X    {
X      disp_env();
X      return(0);
X    }
X  unparse_line(argc-1,&argv[1],s);
X  setenv(s);
X  return(0);
X}
SHAR_EOF
$TOUCH -am 0507213490 env.c &&
chmod 0644 env.c ||
echo "restore of env.c failed"
set `wc -c env.c`;Wc_c=$1
if test "$Wc_c" != "2171"; then
	echo original size 2171, current size $Wc_c
fi
# ============= areas.c ==============
echo "x - extracting areas.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > areas.c &&
X/*
X  GDX-BBS V1.0 Beta
X  (C) 1990
X  Jay A. Snyder
X*/
X
X/*
X  (C) 1990
X  Jay A. Snyder
X*/
X
X#include "inc.h"
X
Xchar *area_tok[]={"desc","dir","file","group",
X		    "owner","priv","udir","\377\377"};
X#define AREATOKCOUNT (int) sizeof(area_tok)/sizeof(char *)
X
Xint nbsearch();
Xint scmp();
X
X
X/*
X    find_area(name,area) --> find <name> area start searching with <area>
X*/
XAREA *find_area(name,area)
X     char *name;
X     AREA *area;
X{
X  if (area==NULL) return(NULL);
X  while (area!=NULL)
X    {
X      if (!ncstrcmp(name,area->name)) return(area);
X      area=area->next;
X    }
X  return(NULL);
X}
X
X/*
X  find_msg_area() --> find the named message area
X                      return it's pointer if found, NULL if not
X*/
XAREA *find_msg_area(name)
X     char *name;
X{
X  AREA *area;
X  return(find_area(name,first_msg_area));
X}
X
X/*
X  find_file_area() --> find the named file area
X                      return it's pointer if found, NULL if not
X*/
XAREA *find_file_area(name)
X     char *name;
X{
X  AREA *area;
X  return(find_area(name,first_file_area));
X}
X
XAREA *last_area(first)
X     AREA *first;
X{
X  AREA *cur;
X  if (first==NULL) return (NULL);
X  cur=first;
X  while (cur->next!=(AREA *) NULL) cur=(AREA *) cur->next;
X  return(cur);
X}
X
XAREA *malloc_area()
X{
X  AREA *cur;
X  if ((cur=(AREA *) malloc(sizeof(AREA)))==NULL)
X    {
X      error_message(MALLOC_ERROR);
X      assert(0);
X      quit();
X    }
X  return(cur);
X}
X
XAREA *new_area(first)
X     AREA *first;
X{
X  AREA *cur,*last;
X  cur=malloc_area();
X  if (first==(AREA *)NULL)
X    first=cur;
X  else
X    {
X      last=last_area(first);
X      last->next=(AREA *) cur;
X    }
X  cur->next=NULL;
X  cur->name[0]=0;
X  cur->desc[0]=0;
X  cur->dir[0]=0;
X  cur->owner[0]=0;
X  cur->file[0]=0;
X  cur->group[0]=0;
X  cur->priv=0;
X  cur->udir[0]=0;
X  return(cur);
X}
X
X
X/*
X  set_area_values(area) --> set values of area from file
X*/
Xset_area_values(area,fp)
X     AREA *area;
X     FILE *fp;
X{
Xchar *p,c,token[20],value[80];
Xint i;
Xwhile (!feof(fp))
X  {
X  if (read_tokstr(fp,token,value)==-1) return;
X  p=token;
X  i=nbsearch(&p, area_tok, AREATOKCOUNT, sizeof(char *), scmp);
X  if (debug>2) printf("token %d:%s=%s\n",i,token,value);
X  switch (i)
X    {
X    case 0: /* desc */
X      sprintf(area->desc,"%.60s",value);
X      break;
X    case 1: /* dir */
X      sprintf(area->dir,"%.80",value);
X      break;
X    case 2: /* file */
X      sprintf(area->file,"%.80s",value);
X      break;
X    case 3: /* group */
X      sprintf(area->group,"%.20s",value);
X      break;
X    case 4: /* owner */
X      sprintf(area->owner,"%.20s",value);
X      break;
X    case 5: /* priv */
X      area->priv=strtol(value,NULL,16);
X      break;
X    case 6: /* udir */
X      sprintf(area->udir,"%.80",value);
X      break;
X    default:
X      printf("Illegal token in area configuration\n");
X      break;
X    }
X  }
X}
X
X
Xload_areas_file(filename,first_ptr)
X     char *filename;
X     AREA **first_ptr;
X{
X  int i;
X  char c,*p,token[20],value[80];
X  AREA *cur;
X  FILE *fp;
X  char s[254];
X  if ((fp=fopen(filename,"r"))==NULL)
X    {
X      return(-1);
X    }
X  while (!feof(fp))
X    {
X      fscanf(fp,"%*[ \t\n]"); /* skip white space */
X      if (feof(fp)) break;
X      myfgets(s,70,fp); /* get line */
X      if (s[0]!='#')
X	{
X	  if (feof(fp)) break;
X	  cur=new_area(*first_ptr);
X	  if (*first_ptr==NULL) *first_ptr=cur;
X	  fscanf(fp,"%*[ \t\n]"); /* skip white space */
X	  sprintf(cur->name,"%.19s",s);
X	  if ((c=fgetc(fp))=='{')
X	    {
X	      set_area_values(cur,fp);
X	    }
X	  else ungetc(c,fp);
X	  if (debug)
X	    printf("\nname=%s\nfile=%s\nowner=%s\ngroup=%s\ndesc=%s\npriv=%d\n",
X		   cur->name,cur->file,cur->owner,cur->group,cur->desc,cur->priv);
X	  if (cur->dir[0]==0)
X	    dirname(cur->file,cur->dir);
X	}
X    }
X  fclose(fp);
X  return(0);
X}
X
X/*
X  load_areas() --> load file and message areas
X*/
Xload_areas()
X{
X  if (load_areas_file(msgareas_file,&first_msg_area))
X    {
X      error_message(MSGAREA_FILE_ERROR);
X    }
X  if (load_areas_file(filelibs_file,&first_file_lib))
X    {
X      error_message(AREALIB_FILE_ERROR);
X    }
X  if (load_areas_file(areas_file,&first_file_area))
X    {
X      error_message(AREA_FILE_ERROR);
X    }
X}
X
X
X
X/*
X  cha() --> change area:
X            argc, argv are passed directly from chfa, and chma
X	    desc is a char string of the description of what we are choosing
X	    first is an AREA ptr to the first area of linked list
X	    cur is a ptr to the AREA ptr of the current area of that list
X*/
Xint cha(argc,argv,desc,first,cur)
X     int argc;
X     char **argv;
X     char *desc;
X     AREA *first,**cur;
X{
X  AREA *area;
X  char s[LINE_SIZE];
X  int i;
X  area=NULL;
X  if (argc>1)
X    { /* is arg is a number use it */
X      if ((i=atoi(argv[1]))>0)
X	{
X	  area=first;
X	  while((--i)>0 && area!=NULL)
X	    {
X	      area=area->next;
X	    }
X	}
X      /* if arg isn't a number, or out of range, try by name */
X      if (area==NULL)
X	area=find_area(argv[1],first);
X      /* if still no success, then print error message and return */
X      if (area!=NULL)
X	if (area_priv(area))
X	  {
X	    *cur=area;
X	    return(0);
X	  } /* if user doesn't have access, just report invalid msg base */
X      rprintf("%s: Invalid %s base name or number: %s\n",argv[0],desc,argv[1]);
X      rprintf("Type %s alone to list available %ss.\n",argv[0],desc);
X      return(-1);
X    }
X  rprintf("%ss:\n",desc);
X  rprintf("   %-20s %-56.59s\n","Area Name","Description");
X  disp_areas(first);
X  rprintf("Select %s:",desc);
X  str[0]=0;
X  if (getline(str,20)==3) return(-1);
X  portout('\n');
Xif (debug) printf("getline done\n");
X  if (str[0]==0) return(-1);
X  sprintf(s,"%s %s",argv[0],str);
Xif (debug)
X{
Xprintf("sprintf done\n");
Xprintf("s=%s\n",s);
X}
X  i=run_line(s);
Xif (debug) printf("runline done\n");
X  return(i);
X}
X
Xdisp_areas(area)
X     AREA *area;
X{
X  char s[82];
X  int i,page_lines;
X  i=0;page_lines=1;
X  while (area!=NULL && !ctrlc())
X    {
X      ++i;
X      if (area_priv(area))
X	{
X	  rprintf("%2d %-20s %-55.55s\n",i,area->name,area->desc);
X	  if (++page_lines==LI-3 && pagemode)
X	    pause();
X	}
X      area=area->next;
X    }
X}
X
Xchma(argc,argv)
X     char *argv[];
X     int argc;
X{
X  cha(argc,argv,"Message Area",first_msg_area,&cur_msg_area);
X}
X
Xchfa(argc,argv)
X     char *argv[];
X     int argc;
X{
X  cha(argc,argv,"File Area",first_file_area,&cur_file_area);
X}
X
Xchfal(argc,argv)
X     char *argv[];
X     int argc;
X{
X  cha(argc,argv,"File Area Library",first_file_lib,&cur_file_lib);
X}
X
SHAR_EOF
$TOUCH -am 1230235690 areas.c &&
chmod 0644 areas.c ||
echo "restore of areas.c failed"
set `wc -c areas.c`;Wc_c=$1
if test "$Wc_c" != "6355"; then
	echo original size 6355, current size $Wc_c
fi
# ============= sig.c ==============
echo "x - extracting sig.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > sig.c &&
X/*
X  GDX-BBS V1.0 Beta
X  (C) 1990
X  Jay A. Snyder
X*/
X
X#include "inc.h"
X
X
Xctrlc()
X{
X  if (!ctrlc_stat) return(0);
X  ctrlc_stat=0;
X  return(1);
X}
X
Xint ctrlc_sig()
X{
X  portout('\n');
X  if (color_mode) _setcolor(BRWHITE,BLUE);
X  else reverseon();
X  portsout(" INTERRUPT ");
X  if (color_mode) fixcolor();
X  else reverseoff();
X  portout('\n');
X  ctrlc_stat=1;
X  signal(SIGINT,ctrlc_sig);
X}
X
Xctrlc_on()
X{
X  signal(SIGINT,ctrlc_sig);
X  set_isig(1);
X  ctrlc_stat=0;
X}     
X
Xctrlc_off()
X{
X  signal(SIGINT,SIG_IGN);
X  set_isig(0);
X  ctrlc_stat=0;
X}
X
Xalarm_sig()
X{
Xchar x[80];
X  ++idletime;
X  if (idletime>=idleout && !sysop)
X    {
X      logout(-1);
X    }
X  if (idletime>=idlewarn && !sysop)
X    {
X      portsout("\nPlease Respond.\007\n");
X    }
X  alarm_on();
X}
X
Xalarm_on()
X{
X  signal(SIGALRM,alarm_sig);
X  alarm(alarm_interval);
X}     
X
Xalarm_off()
X{
X  signal(SIGALRM,SIG_IGN);
X}
X
SHAR_EOF
$TOUCH -am 0507213390 sig.c &&
chmod 0644 sig.c ||
echo "restore of sig.c failed"
set `wc -c sig.c`;Wc_c=$1
if test "$Wc_c" != "871"; then
	echo original size 871, current size $Wc_c
fi
# ============= priv.c ==============
echo "x - extracting priv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > priv.c &&
X#include "inc.h"
X
X/*
X  priveledges:
X  file and message areas, commands, and menu entries can all have a privledge
X  requirement.  Each bit in the priv fields is associated with a privledge.
X  If priv=0, then any user can access the resouce.  If it is non-zero, then the
X  user must have at least one non-zero bit in common with priv.
X*/
X
X/*
X  chk_priv()   return TRUE if user meets privlege specified in priv
X*/
Xchk_priv(priv)
X     PRIV priv;
X{
X  if (sysop) return(TRUE);
X  if (priv==0) return(TRUE);
X  return(priv & logged_user.priv);
X}
X
X/*
X  check user's permission of command.
X  return TRUE is permission granted, FLASE otherwise
X*/
Xchk_cmd_priv(c)
X     COMMAND *c;
X{
X  return(chk_priv(c->priv));
X}
X
X/*
X  area_priv() --> check the user's access of a message base or file area
X*/
Xarea_priv(area)
X     AREA *area;
X{
X  return(chk_priv(area->priv));
X}
X
X
Xchk_menu_priv(ptr)
X     m_entry_ptr ptr;
X{
X  return(chk_priv(ptr->priv));
X}
Xchk_menu_header_priv(ptr)
X     m_header_ptr ptr;
X{
X  return(chk_priv(ptr->priv));
X}
SHAR_EOF
$TOUCH -am 1231001690 priv.c &&
chmod 0644 priv.c ||
echo "restore of priv.c failed"
set `wc -c priv.c`;Wc_c=$1
if test "$Wc_c" != "1013"; then
	echo original size 1013, current size $Wc_c
fi
# ============= config.h ==============
echo "x - extracting config.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > config.h &&
X/* config.h : custom configuration of program */
X
X/* maximum number of password trys */
X#define MAXTRY 3
X
X#define ALARM_INTERVAL 60 /* seconds */
X#define DEF_IDLEWARN 2 /* minutes */
X#define DEF_IDLEOUT 3  /* minutes */
X#define DEF_MAXTIME 60 /* minutes */
X
X/* default sysop name */
X#define SYSOP "sysop"
X
X/* support files */
X#define MENU_FILE menu_file
X#define DEF_MENU_FILE "menu.mcl"
X#define ERRORLOG_FILE errorlog_file
X#define DEF_ERRORLOG_FILE "error.log"
X#define USER_FILE user_file
X#define TMP_USER_FILE "userfile.tmp"
X#define DEF_USER_FILE "users.bbs"
X#define UTMP_FILE utmp_file
X#define DEF_UTMP_FILE "utmp.bbs"
X#define LOG_FILE log_file
X#define DEF_LOG_FILE "callers.bbs"
X#define AREAS_FILE areas_file
X#define DEF_AREAS_FILE "areas.bbs"
X#define FILELIBS_FILE filelibs_file
X#define DEF_FILELIBS_FILE "filelibs.bbs"
X#define MSGAREAS_FILE msgareas_file
X#define DEF_MSGAREAS_FILE "msgareas.bbs"
X#define CONFIG_FILE config_file
X#define DEF_CONFIG_FILE "config.bbs"
X#define QUEST_FILE quest_file
X#define DEF_QUEST_FILE "question.bbs"
X#define QUEST_OUT_FILE quest_out_file
X#define DEF_QUEST_OUT_FILE "answer.bbs"
X#define NEWUSER_FILE newuser_file
X#define DEF_NEWUSER_FILE "newuser.src"
X#define STARTUP_FILE startup_file
X#define DEF_STARTUP_FILE "startup.src"
X#define DEF_BUL_FILE 
X#define BUL_FILE bul_file
X#define DEF_MAIL_DIR "mail"
X#define DEF_HOME_DIR "."
X#define DEF_PROMPT "GDX-BBS>"
X#define	DEF_MONDEV "/dev/null"
X#define DEF_UL_PATH "*/upload"
SHAR_EOF
$TOUCH -am 1228000890 config.h &&
chmod 0600 config.h ||
echo "restore of config.h failed"
set `wc -c config.h`;Wc_c=$1
if test "$Wc_c" != "1455"; then
	echo original size 1455, current size $Wc_c
fi
# ============= defs2.h ==============
echo "x - extracting defs2.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > defs2.h &&
XUSER *chk_name();
Xchar *ttyname();
Xextern int optind;
Xextern char *optarg;
Xextern int errno;
Xextern char **environ;
X
Xchar *eatnl();
Xchar *timestr();
Xchar *myfgets();
Xchar *basename();
Xchar *dirname();
X
X/* external declarations */
X/* extern char *tgetstr(); */
X
X
X#ifdef F_SYSV
Xint rename();
X#define remove unlink
X#endif
X
X#define fatal_error(errnum) {                	\
X		     	errorsout("FATAL: ");  	\
X			error_message(errnum); 	\
X  			assert(0);		\
X		     	exitprog(errnum);	\
X			}
X			     
SHAR_EOF
$TOUCH -am 0324035690 defs2.h &&
chmod 0600 defs2.h ||
echo "restore of defs2.h failed"
set `wc -c defs2.h`;Wc_c=$1
if test "$Wc_c" != "492"; then
	echo original size 492, current size $Wc_c
fi
# ============= inc.h ==============
echo "x - extracting inc.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > inc.h &&
X#include <stdio.h>
X#ifdef HAVE_STDLIB
X#include <stdlib.h>
X#endif
X#include <ctype.h>
X#include <signal.h>
X#include <search.h>
X#include <termio.h>
X/* #include <term.h> */
X#include <string.h>
X#include <fcntl.h>
X#include <time.h>
X#include <malloc.h>
X#include <sys/param.h>
X#include <sys/poll.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#ifdef OLDTTY
X#include <sgtty.h>
X#else
X#ifdef F_BSD
X#include <sys/ioctl.h>
X#endif
X/*   #include <termio.h> */
X#endif
X#include <errno.h>
X#include <assert.h>
X#include "defs.h"
X#include "structs.h"
X#include "defs2.h"
X#include "global.h"
X#include "termdefs.h"
X#include "config.h"
SHAR_EOF
$TOUCH -am 1225234290 inc.h &&
chmod 0644 inc.h ||
echo "restore of inc.h failed"
set `wc -c inc.h`;Wc_c=$1
if test "$Wc_c" != "611"; then
	echo original size 611, current size $Wc_c
fi
# ============= termdefs.h ==============
echo "x - extracting termdefs.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > termdefs.h &&
XPUBEXT  int CO,LI; /* columns, lines */
XPUBEXT char
X  *AL, /* insert line */
X  *BC, /* backspace */
X  *CD, /* clear to end of display */
X  *CE, /* clear eol */
X  *CL, /* clear screen */
X  *CM, /* cursor motion */
X  *DC, /* delete character */
X  *DL, /* delete line */
X  *DM, /* enter delete mode */
X  *ED, /* end delete mode */
X  *EI, /* end insert mode */
X  *IC, /* insert character */
X  *IM, /* enter insert mode */
X  *IP, /* post-insert padding */
X  *MB, /* blink attribute */
X  *MD, /* bold attribute */
X  *ME, /* end attribute */
X  *MR, /* reverse attribute */
X  PC, *PCstr, /* pad character and string */
X  *SE, /* end standout mode */
X  *SO, /* enter standout mode */
X  *TE, /* end cursor addressing mode */
X  *TI, /* enter cursor addressing mode */
X  *UP, /* cursor up */
X  *VE, /* end visual mode */
X  *VS /* enter visual mdoe */
X  ;
X
X	       
SHAR_EOF
$TOUCH -am 0314003690 termdefs.h &&
chmod 0600 termdefs.h ||
echo "restore of termdefs.h failed"
set `wc -c termdefs.h`;Wc_c=$1
if test "$Wc_c" != "853"; then
	echo original size 853, current size $Wc_c
fi
# ============= defs.h ==============
echo "x - extracting defs.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > defs.h &&
X#define BLACK 0
X#define RED 1
X#define GREEN 2
X#define BROWN 3
X#define BLUE 4
X#define MAGENTA 5
X#define CYAN 6
X#define WHITE 7
X#define GREY 8
X#define LTRED 9
X#define LTGREEN 10
X#define YELLOW 11
X#define LTBLUE 12
X#define LTMAGENTA 13
X#define LTCYAN 14
X#define BRWHITE 15
X
X
X/* error constants */
X#define MENU_FILE_ERROR	1
X#define UTMP_FILE_ERROR 2
X#define MALLOC_ERROR 3
X#define BAD_TERM 4
X#define BAD_MENU_TAG 5
X#define ERRORLOG_ERROR 6
X#define USER_FILE_ERROR 7
X#define LOG_FILE_ERROR 8
X#define CONFIG_FILE_ERROR 9
X#define PRIV_ERROR 10
X#define QUEST_FILE_ERROR 11
X#define TMP_USER_FILE_ERROR 12
X#define INVALID_USER 13
X#define FORK_ERROR 14
X#define EXEC_ERROR 15
X#define MSGAREA_FILE_ERROR 16
X#define AREA_FILE_ERROR 17
X#define AREALIB_FILE_ERROR 17
X
X#ifdef SCO
X#define cbreak crmode
X#endif
X#define CR 13
X#define BS 8
X#define NL 10
X#define ESC 27
X#define DEL 127
Xtypedef int(*fptr)();
X
X#define MYNAME logged_user.name
X#ifndef ANSI
X/* seek stuff */
X#define SEEK_SET 0
X#define SEEK_CUR 1
X#define SEEK_END 2
X#endif
X
X/* maximum number of messages per base */
X#define MAXMSG 200
X
X/* maximum number of envinronment variables */
X#define MAXENV 200
X
X/* maximum command line size */
X#define LINE_SIZE 1024
X#define BUFSIZE 1024
X
X#define TRUE 1
X#define FALSE 0
X
X/* sysop priv is bit 31 of the priv field */
X#define SYSOP_PRIV 0x80000000
SHAR_EOF
$TOUCH -am 1230230990 defs.h &&
chmod 0600 defs.h ||
echo "restore of defs.h failed"
set `wc -c defs.h`;Wc_c=$1
if test "$Wc_c" != "1327"; then
	echo original size 1327, current size $Wc_c
fi
# ============= global.h ==============
echo "x - extracting global.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > global.h &&
X#ifndef MAIN
X#define PUBEXT extern
X#else
X#define PUBEXT /* */
X#endif
XPUBEXT  m_header_ptr mail_menu_ptr;
XPUBEXT  m_header_ptr pubmsg_menu_ptr;
XPUBEXT  m_header_ptr proto_menu_ptr;
XPUBEXT	char ul_exe[80],dl_exe[80];
XPUBEXT  m_header_ptr first_menu_ptr
X#ifdef MAIN
X	=NULL;
X#else
X	;
X#endif
XPUBEXT  char str[LINE_SIZE], input[LINE_SIZE];
XPUBEXT  char str1[LINE_SIZE],buf[BUFSIZE];
X/* mode flags */
XPUBEXT  char debug,sysop,sysop_login,termset,term[20],
X        capbuf[512],tb[1024],*t,prompt[20],
X	expert_mode,ansi,color_mode,echo_mode;
X/* PUBEXT	 struct sgttyb t_mode, c_mode; */
XPUBEXT  char *cmd_stack,*cmdptr,*rcmdptr;
XPUBEXT  int cmd_stack_size
X#ifdef MAIN
X	=0x800;
X#else
X	;
X#endif
XPUBEXT int line_change;
XPUBEXT m_header_ptr current_menu;
XPUBEXT pagemode;
XPUBEXT USER *first_user_ptr;
XPUBEXT USER *tmp_user;
XPUBEXT USERREC logged_user;
XPUBEXT char chkpriv;
XPUBEXT char doing_source;
XPUBEXT char menu_file[63], errorlog_file[63], user_file[63], config_file[63],
X	     utmp_file[63], log_file[63],areas_file[63],msgareas_file[63],
X             quest_file[63],quest_out_file[63],newuser_file[63],
X             filelibs_file[63],startup_file[63];
XPUBEXT char sysop_name[30];
XPUBEXT int  maxtry;
XPUBEXT int cmdcount;
XPUBEXT char thistty[15];
XPUBEXT utmpentry *first_utmp,*last_utmp;
XPUBEXT int logged_users;
XPUBEXT char who_switch;
XPUBEXT char sys_home_dir[81];
XPUBEXT char mail_dir[81];
XPUBEXT time_t maildate,logdate,*mdate; /* time/date that mail was last read */
XPUBEXT char home_dir[81];
XPUBEXT AREA *cur_msg_area,*first_msg_area;
XPUBEXT AREA *cur_file_area,*first_file_area;
XPUBEXT AREA *cur_file_lib,*first_file_lib;
XPUBEXT char curses_init;
XPUBEXT char terminfo_mode;
X#ifdef OLDTTY
XPUBEXT struct sgttyb tbufsave;
X#else
XPUBEXT struct termio tbufsave;
X#endif
XPUBEXT char now_raw
X#ifdef MAIN
X  =FALSE;
X#else
X  ;
X#endif
XPUBEXT cur_forecolor,cur_backcolor;
XPUBEXT char defterm[12];
XPUBEXT long int *msg_ptrs;
XPUBEXT int cur_msg,msg_count;
XPUBEXT char fsedit[120];
XPUBEXT char *local_env[MAXENV];
XPUBEXT int kbd_pid;
XPUBEXT ctrlc_stat;
XPUBEXT char user_is_logged;
XPUBEXT int alarm_interval, idlewarn, idleout, maxtime, idletime;
XPUBEXT char def_ul_path[81];
X
X/* monitor stuff */
XPUBEXT char mondev[21];
XPUBEXT int monitor_on;
XPUBEXT FILE *monfp;
SHAR_EOF
$TOUCH -am 1228011690 global.h &&
chmod 0600 global.h ||
echo "restore of global.h failed"
set `wc -c global.h`;Wc_c=$1
if test "$Wc_c" != "2245"; then
	echo original size 2245, current size $Wc_c
fi
# ============= structs.h ==============
echo "x - extracting structs.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > structs.h &&
Xtypedef unsigned long PRIV;
X
Xstruct m_entry {
X	char name[19];
X	char actkey;
X	char cmd[60];
X	PRIV priv; /* permission bits */
X	struct m_entry *next;
X	};
X
Xtypedef struct m_entry *m_entry_ptr;
X
Xstruct m_header {
X	char tag[13];
X	char name[40];
X	PRIV priv; /* permission bits */
X	int count;
X	char one_shot;
X	struct m_entry *first_entry;
X	struct m_header *next;
X	};
X
Xtypedef struct m_header *m_header_ptr;
X
Xstruct COMMAND_STRUCT {
X	char *name;
X	fptr func;
X	int fnum;
X	PRIV priv; /* permission bits */
SHAR_EOF
echo "End of gdxbbs part 3"
echo "File structs.h is continued in part 4"
echo "4" > @shar_seq_.tmp
exit 0



More information about the Alt.sources mailing list