From:	CRDGW2::CRDGW2::MRGATE::"SMTP::UBVMSC.CC.BUFFALO.EDU::SYSTEM" 23-JUN-1989 19:43
To:	MRGATE::"ARISIA::EVERHART"
Subj:	DISK$ACSDISK2:[VMSSERV.VAX]VMSSERV.2_OF_4;1

Message-Id:  <8906231652.AA04856@crdgw1.ge.com>
Date: Fri, 23 Jun 89 12:42 EDT
From: SYSTEM@ubvmsc.cc.buffalo.edu
Subject: DISK$ACSDISK2:[VMSSERV.VAX]VMSSERV.2_OF_4;1
To: everhart@arisia.decnet
X-Vms-To: IN%"everhart%arisia.decnet@crdgw1.ge.com"

+-+-+-+ Beginning of part 2 +-+-+-+
X`009
X`009  tim.len = strlen(time_stamp_interval) ;
X`009  tim.addr= time_stamp_interval ;
X`009  if ( sys$bintim(&tim,&bintim) & 1 )
X`009    sys$setimr(0,&bintim,time_stamp,0) ;
X`009  tim.len = strlen(timer_interval) ;
X`009  tim.addr = timer_interval ;
X`009  if ( ((status = sys$bintim(&tim,&bintim)) & 1) == 0 ) `123
X`009    report_error("Sys$bintim failed",status) ;
X`009    return(status) ;
X`009  `125 ;
X`009  sys$setimr(0,&bintim,scan_timerqueue,0) ;
X`009  return(1) ;
X`009`125 ;
X`009 `032
X`009if ( phase == PROCESS_PHASE ) `123
X`009  return( sys$setimr(0,&bintim,scan_timerqueue,0) ) ;
X`009`125 ;
X`125
X
X
Xwatchdog(phase)
Xint phase ;
X`123
X`009if ( phase == PROCESS_PHASE ) `123
X
X`009`125 ;
X`125
X
X
Xtime_stamp()
X`123
X
X`009char msg[80] ;
X`009static struct dsc tim ;
X`009static unsigned int bintim[2], status ;
X
X`009sprintf(msg,"%s time stamp",hook_name.dsc$a_pointer) ;
X`009sendopcom(msg) ;
X`009tim.len = strlen(time_stamp_interval) ;
X`009tim.addr= time_stamp_interval ;
X`009if ( sys$bintim(&tim,&bintim) & 1 )
X`009  sys$setimr(0,&bintim,time_stamp,0) ;
X`009return(1) ;
X`125
X
X`012
X
Xonline(node,user)
Xchar *node,*user ;
X
X`123
V`009if ( strcmp(node,mynode) != 0 `124`124 strcmp(user,postmaster_userid) !=
X 0 )
X`009  sendmsg(node,user,"Restricted command") ;
X`009else create_logical(files_available_logical,"YES") ;
X`009return(1) ;
X`125`009  `032
X
Xoffline(node,user)
Xchar *node,*user ;
X
X`123
V`009if ( strcmp(node,mynode) != 0 `124`124 strcmp(user,postmaster_userid) !=
X 0 )
X`009  sendmsg(node,user,"Restricted command") ;
X`009else create_logical(files_available_logical,"NO") ;
X`009return(1) ;
X`125`009  `032
X`009 `032
X
X`012
X
Xprocess_file(phase)
Xint phase ;
X`123
X`009int status ;
X`009char *cp,*dp, host[10],user[10],name[10],type[10],device[10],class[2];
X`009char complex_address[255],file[255] ;
X`009char *fmt = "F %s  %s  %s %s  %s" ;
X
X`009if ( phase == INIT_PHASE ) `123
X`009  status = jan_adjust(&hook_name) ;
X`009`125 ;
X
X`009list_name = default_listname ;
X`009if ( *process_mail == 'Y' `124`124 *process_mail == 'y' ) `123
X
X`009  if ( *(dp = cp = tranlog(files_available_logical)) == '\0' )
X`009    cp = files_available ;
X
X`009  if ( *cp == 'y' `124`124 *cp == 'Y'  )
X`009    while ( ( status = rou_if_file() ) & 1 ) `123
X`009      status = receive_file(file,host,user,name,type,device,class) ;
V`009      if (( status & 1 ) == 0 ) report_error("Receive file failure",statu
Xs);
X`009      rou_got_file() ;`009  `032
X`009      cp = xmalloc(strlen(file)+strlen(fmt)+strlen(user)+strlen(host)
X`009     `009          +strlen(name)+strlen(type)+1) ;
X`009      sprintf(cp,fmt,host,user,name,type,file) ;
X`009      sendlogfile(cp) ;
X`009      xfree(cp) ;
X`009      status = do_mail(file,host,user,complex_address) ;
X`009    `125 ;
X
X`009  xfree( dp ) ;
X
X`009`125 ;
X
X`009return( status ) ;
X`125
X
X
X`012
X
Xprocess_message(phase)
Xint phase ;
X`123
X
X`009char msg[120],buffer[100],opmsg[160], *cp ;
X`009int msglen,status ;
X`009char node[10],user[10] ;
X`009struct dsc nodedsc = `123 8,&node `125 ;
X`009struct dsc userdsc = `123 8,&user `125 ;
X`009struct dsc msgbuf  = `123 100,&msg `125 ;
X`009struct dsc opdsc   = `123 120,&opmsg `125 ;
X`009$DESCRIPTOR(nulldsc,"\0") ;
X`009int mode ;
X
X`009mode = 2 ;
X`009
X`009list_name = default_listname ;
X`009if ( phase == PROCESS_PHASE )
X`009  while (jan_receive_msg(&mode,&nodedsc,&userdsc,&msgbuf,&msglen) & 1)
X`009    if ( mode != 2 ) `123
X`009`009
X`009      msgbuf.len = msglen&0377 ;
X`009      if ( msgbuf.len > 80 ) msgbuf.len = 80 ;
X`009      str$concat(&opdsc,&nodedsc,&userdsc,&msgbuf,&nulldsc) ;
X`009      *(nodedsc.addr+(nodedsc.len&0377)) = 0 ;
X`009      *(userdsc.addr+(userdsc.len&0377)) = 0 ;
X`009      *(msgbuf.addr+ (msgbuf.len&0377))  = 0 ;
X`009      cp = userdsc.addr ;
X`009      while ( *cp ) `123 if ( *cp == ' ' ) *cp = 0; cp++; `125 ;
X`009      cp = nodedsc.addr ;
X`009      while ( *cp ) `123 if ( *cp == ' ' ) *cp = 0; cp++; `125 ;
X`009      collapse(upcase(msgbuf.addr)) ;`032
X`009      if ( ! ( *userdsc.addr == 0 `124`124 *userdsc.addr == ' ' ) ) `123
X`009        do_command(nodedsc.addr,userdsc.addr,msgbuf.addr) ;
X`009      `125 ;
X`009      msgbuf.len = 100 ;
X`009    `125 ;
X
X`009return(1) ;
X
X`125
X
X
X
X`012
X
X#define`009TEXTFILE 1
X#define`009JNETDUMP 2
X#define`009PUNCHFILE 3
X
X#define USER`0090
X#define MAINT`0091
X
X#define`009SEND`0091
X#define`009HELP`0092
X#define`009DIR`0093
X#define`009SENT`0094
X#define VMSDUMP`0095
X#define PUNCH`0096
X#define INDEX`0097
X#define STATUS`0098
X#define SHOW`0099
X#define OFFLINE`00910
X#define ONLINE`00911
X
X`009char *send_types[] = `123 "","SEND","VMSDUMP","PUNCH" `125 ;
X
X`009struct cmdtype`009`123
X`009`009`009char command[10] ;
X`009`009`009int index ;
X`009`009`009int class ;
X`009`009`009`125 ;
X
X`009static struct cmdtype cmdlist[]
X`009`009`009`009 = `123`009"SEND",SEND,USER,
X`009`009`009`009`009"HELP",HELP,USER,
X`009`009`009`009`009"DIR" ,DIR ,USER,
X`009`009`009`009`009"DIRECTORY",DIR,USER,
X`009`009`009`009`009"INDEX",INDEX,USER,
X`009`009`009`009`009"IND",INDEX,USER,
X`009`009`009`009`009"SENT",SENT,USER,
X`009`009`009`009`009"VMS" ,VMSDUMP,USER,
X`009`009`009`009`009"VMSDUMP",VMSDUMP,USER,
X`009`009`009`009`009"SENDME",SEND,USER,
X`009`009`009`009`009"SEN",SEND,USER,
X`009`009`009`009`009"GET",SEND,USER,
X`009`009`009`009`009"PUNCH",PUNCH,USER,
X`009`009`009`009`009"PUN",PUNCH,USER,
X`009`009`009`009`009"?",HELP,USER,
X`009`009`009`009`009"STATUS",STATUS,USER,
X`009`009`009`009`009"SHOW",SHOW,USER,
X`009`009`009`009`009"SH",SHOW,USER,
X`009`009`009`009`009"OFF",OFFLINE,MAINT,
X`009`009`009`009`009"OFFLINE",OFFLINE,MAINT,
X`009`009`009`009`009"ON",ONLINE,MAINT,
X`009`009`009`009`009"ONLINE",ONLINE,MAINT,
X`009`009`009`009`009""    ,0,USER,
X`009`009`009`009   `125 ;
X
X`012
X
X
Xdo_command(node,user,s)
X
Xchar *node,*user,*s ;
X
X`123
X`009int off_line ;
X`009struct cmdtype *cmdp ;
X`009char *cp, *dp ;
V`009char *down = "The server files are currently unavailable. Please try late
Xr";
X
X        log_request(node,user,s,'I') ;
X`009if ( *(dp = cp = tranlog(files_available_logical)) == '\0' )
X`009  cp = files_available ;
X`009off_line =  ! ( *cp == 'y' `124`124 *cp == 'Y' ) ;
X`009xfree( dp ) ;
X`009dp = ( cp = xmalloc(strlen(s)+10) ) ;
X`009while ( *s != '\0' && *s == ' ' ) s++ ;
X`009while ( *s != '\0' && *s != ' ' ) *dp++ = *s++ ;
X`009*dp = 0 ;
X`009cmdp = &cmdlist[0] ;
X`009while ( cmdp->command[0] != 0 && strcmp(cp,cmdp->command) != 0 )
X`009`009cmdp++ ;
X
X`009if ( off_line && cmdp->class == USER ) `123
X`009  sendmsg(node,user,down) ;
X`009  return(1) ;
X`009`125 ;
X
X`009while ( *s != '\0' && *s == ' ' ) s++ ;
X`009if ( *s ) `123
X`009  if ( cmdp->index != INDEX && strchr(s,'.') == 0 )
X`009    if ( dp = strchr(s,' ')) *dp = '.' ;
X`009  if ( dp = strchr(s,' ') ) `123
X`009    *dp++ = 0 ;
X`009    if ( *dp ) list_name = dp ;
X `009  `125 ;
X`009`125 ;
X
X
X`009switch( cmdp->index ) `123
X`009`009case SEND:
X`009`009`009if ( strncmp(s,"DIR",3) == 0 ) senddir("*.*",node,user) ;
X`009`009`009else
X`009`009`009  if (strncmp(s,"INDEX",5) == 0) sendindex("",node,user);
X/*`009`009`009  if (strncmp(s,"INDEX",5) == 0) `123
X`009`009`009    if (cp = strchr(s,'.')) *cp = ' ' ;
X`009`009`009    do_command(node,user,s);
X`009`009`009  `125 */
X`009`009`009  else sendfile(s,node,user,TEXTFILE) ;
X`009`009`009break ;
X`009`009case VMSDUMP:
X`009`009`009sendfile(s,node,user,JNETDUMP) ;
X`009`009`009break ;
X`009`009case PUNCH:
X`009`009`009sendfile(s,node,user,PUNCHFILE) ;
X`009`009`009break ;
X`009`009case DIR:
X`009`009`009senddir(s,node,user) ;
X`009`009`009break ;
X`009`009case INDEX:
X`009`009`009sendindex(s,node,user) ;
X`009`009`009break ;
X`009`009case HELP:
X`009`009`009sendhelp(s,node,user) ;
X`009`009`009break ;
X`009`009case SENT:`009/* Ignore messages for file forwarding */
X`009`009`009break ;
X`009`009case STATUS:
X`009`009`009sendstatus(s,node,user) ;
X`009`009`009break ;
X`009`009case ONLINE:
X`009`009`009online(node,user) ;
X`009`009`009break ;
X`009`009case OFFLINE:
X`009`009`009offline(node,user) ;
X`009`009`009break ;
X`009`009default:
X`009`009`009sendbad(cp,node,user) ;
X`009`009`009break ;
X`009`009`009`125
X`009xfree( cp ) ;
X`125
X
X
X
X
X`012
X
Xdo_mail_command(s,complex_address)
Xchar *s,*complex_address ;
X
X`123
X`009char *cp,*dp,*cmd_save ;
X`009struct cmdtype *cmdp ;
X`009int status ;
X
X`009status = 1 ;
X`009if ( *s == '\0' ) return(1) ;
X`009log_request("",complex_address,s,'M') ;
X
X`009sprintf((cmd_save=xmalloc(strlen(s)+1)),"%s",s);
X`009dp = ( cp = xmalloc(strlen(s)+10) ) ;
X`009while ( *s != '\0' && *s != ' ' ) *dp++ = *s++ ;
X`009while ( *s != '\0' && *s == ' ' ) s++ ;
X`009*dp = 0 ;
X
X`009cmdp = &cmdlist[0] ;
X`009while ( cmdp->command[0] != 0 && strcmp(cp,cmdp->command) != 0 )
X`009`009cmdp++ ;
X
X`009while ( *s != '\0' && *s == ' ' ) s++ ;
X`009if ( *s ) `123
X`009  if ( cmdp->index != INDEX && strchr(s,'.') == 0 )
X`009    if ( dp = strchr(s,' ')) *dp = '.' ;
X`009  if ( dp = strchr(s,' ') ) `123
X`009    *dp++ = 0 ;
X`009    if ( *dp ) list_name = dp ;
X `009  `125 ;
X`009`125 ;
X
X`009switch( cmdp->index ) `123
X`009`009case SEND:
X`009`009`009send_mail_file(s,complex_address,TEXTFILE) ;
X`009`009`009break ;
X`009`009case VMSDUMP:
X`009`009`009send_mail_file(s,complex_address,JNETDUMP) ;
X`009`009`009break ;
X`009`009case PUNCH:
X`009`009`009send_mail_file(s,complex_address,PUNCHFILE) ;
X`009`009`009break ;
X`009`009case DIR:
X`009`009`009send_mail_dir(s,complex_address) ;
X`009`009`009break ;
X`009`009case INDEX:
X`009`009`009send_mail_index(s,complex_address) ;
X`009`009`009break ;
X`009`009case HELP:
X`009`009`009send_mail_help(complex_address) ;
X`009`009`009break ;
X`009`009default:
X`009`009`009send_mail_bad(cp,cmd_save,complex_address) ;
X`009`009`009status = 0 ;
X`009`009`009break ;
X`009`009`009`125
X`009xfree( cp ) ;
X`009xfree(cmd_save) ;
X`009return( status ) ;
X`125
X
X
X
X`012
X
X
X/*
X
X Send_mail_index will process the INDEX mail command (SENDINDEX does the
Xidentical thing for interactive messages). The operation is as follows:`032
X
X  INDEX
X
X`009 Looks for 'hookname'.FILELIST in the default  search  path,
X`009ie,  VMSSERV_ALL:  unless  redefined  when  the  process  is
X`009started. If  this  filename,  which  as  noted  defaults  to
X`009VMSSERV_ALL:VMSSERV.FILELIST,  does  not  exist,  a  logfile
X`009entry is made and the  DIRECTORY/OUT=  command  is  sent  to
X`009batch instead.`032
X
X  INDEX LIST
X
X`009 In this case, the seach path will be generated from 'LIST',
X`009ie, INDEX KERMIT would generate the filename`032
X
X`009     VMSSERV_FILE_LOCATION_KERMIT:KERMIT.FILELIST
X
X`009 by calling generate_path(). Of course, Generate_path() will
X`009check for the translation of the logical and replace it with
X`009the   default   listname,   normally   VMSSERV_ALL:, if  the
X`009translation fails. If the file does not exist, the action is
X`009identical to that described above.
X
X*/
X
Xsend_mail_index(f,complex_address)
Xchar *f ,*complex_address ;
X`123
X`009char s[256],*cmds[10],msg[256] ;
X`009int i,status ;
X`009char *generate_mail_agent() ;
X
X`009i = 0 ;
X`009if ( *f ) sprintf(s,"%s%s.FILELIST",generate_path(f),f);
X`009else
X`009  sprintf(s,"%s%s.FILELIST",generate_path(default_listname),
X`009`009  hook_name.dsc$a_pointer);
X`009if ( findfile(s,TEXTFILE) & 1 ) `123
X`009  sprintf((cmds[i++] = xmalloc(256)),"$ %s",
X`009`009   generate_mail_agent(s,complex_address)) ;
X`009  cmds[i] = 0 ;
X`009  status = create_batch_job(cmds,0,null_batch_params) ;
X`009  while ( i != 0 ) xfree(cmds[--i]) ;
X`009  return(status) ;
X`009`125
X`009else `123
X`009  sprintf(msg,"W %s not found. DIR batch job created",s) ;
X`009  sendlogfile(msg) ;
X`009  send_mail_dir(f,complex_address) ;
X`009`125 ;
X`125
X
X
X`012
X
X
Xsend_mail_dir(f,complex_address)`032
Xchar *f ,*complex_address ;
X`123
X`009char s[256],*cmds[10],tmpout[100],concat[100] ;
X`009int i,j,status ;
X`009char *generate_mail_agent() ;
X`009
X
X`009i = 0 ;
X`009if ( *strcpy(s,f) == '\0' ) strcpy(s,"*.*") ;
X`009sprintf(concat,"%s%s.LIS",scratch_dir,tmpnam(0)) ;
X`009sprintf(tmpout,"%s%s.LIS",scratch_dir,tmpnam(0)) ;
X`009sprintf((cmds[i++] = xmalloc(160)),"$ DIR/SIZE/DATE/OUT=%s %s%s",
X`009`009 tmpout,generate_path(list_name),s) ;
X`009sprintf((cmds[i++]=xmalloc(160)),"$ if $STATUS then goto sendit") ;
X`009sprintf((cmds[i++]=xmalloc(256)),"$ %s",
X`009`009 generate_mail_agent(not_found,complex_address)) ;
X`009sprintf((cmds[i++]=xmalloc(160)),"$ exit\n$ sendit:") ;
X`009sprintf((cmds[i++]=xmalloc(160)),"$ copy/concat %s,%s %s",
X`009`009 xfer_info,tmpout,concat) ;
X`009sprintf((cmds[i++]=xmalloc(256)),"$ %s",
X`009`009 generate_mail_agent(concat,complex_address)) ;
X`009sprintf((cmds[i++]=xmalloc(160)),"$ delete %s.",concat) ;
X`009sprintf((cmds[i++]=xmalloc(160)),"$ delete %s.",tmpout) ;
X`009cmds[i] = 0 ;
X`009status = create_batch_job(cmds,0,null_batch_params) ;
X`009while ( i != 0 ) xfree(cmds[--i]) ;
X`009return(status) ;
X`125
X
X
Xsend_mail_help(complex_address)
Xchar *complex_address ;
X`123
X`009char *cmds[10] ;
X`009int i,status ;
X
X`009if ( ((status=findfile(internet_helpfile,TEXTFILE)) & 1) == 0 ) `123
X`009  report_error(internet_helpfile,status) ;
X`009  return(status) ;
X`009`125 ;
X`009i = 0 ;
X`009sprintf((cmds[i++]=xmalloc(256)),"$ %s",`009
X`009`009 generate_mail_agent(internet_helpfile,complex_address)) ;
X`009cmds[i] = 0 ;
X`009status = create_batch_job(cmds,0,null_batch_params) ;
X`009while ( i != 0 ) xfree(cmds[--i]) ;
X`009return(status) ;
X`125
X
X`012
X
Xsend_mail_file(f,complex_address,type)
Xchar *f,*complex_address ;
Xint  type ;
X`123
X`009FILE *msg_file ;
X`009char *cp,*cmds[10],tmp[256],tmpfile[256] ;
X`009int i,late,msg_write,que_size,status ;
X`009struct stat *attrs,*getstat() ;
X
X`009if ( do_package(f,"",complex_address,type) == PACKAGE_COMPLETED )
X`009  return(1) ;
X`009late = 0 ;
X`009status = 1 ;
X`009sscanf(defer_send_filesize,"%d",&que_size) ;
X`009sprintf(tmpfile,"%s%s.MSG",scratch_dir,tmpnam(0)) ;
X
X`009if ( (msg_file = fopen(tmpfile,"w")) == NULL )
X`009  sendlogfile("W Failure to open message file") ;
X`009msg_write = 0 ;
X
X`009if ( check_for_directory(f) ) `123
X`009  fprintf(msg_file,"Please do not include directory or logical\n");
X`009  fprintf(msg_file,"names in your file specification for the file\n");
X`009  fprintf(msg_file,"that you request. If the file is present, the\n");
X`009  fprintf(msg_file,"the server will find it.\n");
X`009  msg_write++ ;
X`009`125 ;
X`009if ( strchr(f,'*') `124`124 strchr(f,'%') ) `123
X`009  fprintf(msg_file,"It is not possible to honor wildcarded requests\n");
X`009  fprintf(msg_file,"for internet replies. Please resubmit your mail\n");
X`009  fprintf(msg_file,"with individual SEND commands for each file. Do\n");
X`009  fprintf(msg_file,"keep in mind that files you request may have to\n");
X`009  fprintf(msg_file,"pass through one or more internet gateways.\n");
X`009  fprintf(msg_file,"\n\n") ;
X`009  msg_write++ ;
X`009`125 ;
X
X`009if ( strchr(f,'.') == 0 ) `123
X`009  fprintf(msg_file,"Please include an explicit filetype for your\n");
X`009  fprintf(msg_file,"file request. Resumbit your request.\n");
X`009  fprintf(msg_file,"\n\n") ;
X`009  msg_write++ ;
X`009`125 ;
X
X`009if ( ((status = findfile(f,type)) & 1) == 0 ) `123
X`009  fprintf(msg_file,"%s could not be accessed for the following\n",f);
X`009  fprintf(msg_file,"reason:\n\n    %s\n",getmsg(status));
X`009  fprintf(msg_file,"\n\n") ;
X`009  msg_write++ ;
X`009`125 ;
X
X`009sprintf(tmp,"%s%s",generate_path(list_name),f) ;
X`009attrs = getstat(tmp) ;
X`009if ( attrs ) `123
X`009  late = ( attrs->st_size/512 > que_size ) `124 late ;
X`009  if ( attrs->st_fab_rfm == FAB$C_FIX && attrs->st_fab_mrs == 512 ) `123
X`009    fprintf(msg_file,"It would appear that file %s is a binary\n",f);
X`009    fprintf(msg_file,"and thus can not be transfered using mail.\n") ;
X`009    fprintf(msg_file,"\n\n") ;
X`009    msg_write++ ;
X`009  `125 ;
X`009`125 ;
X
X
X`009if ( msg_write ) `123
X`009  i = 0 ;
X`009  fclose(msg_file) ;
X`009  sprintf((cmds[i++]=xmalloc(256)),"$ %s",
X`009`009   generate_mail_agent(tmpfile,complex_address)) ;
X`009  sprintf((cmds[i++]=xmalloc(120)),"$ delete %s.",tmpfile) ;
X`009  cmds[i] = 0 ;
X`009  status = create_batch_job(cmds,0,null_batch_params) ;
X`009  while ( i != 0 ) xfree(cmds[--i]) ;
X`009  return(status) ;
X`009`125 ;
X
X`009i = 0 ;
X`009sprintf(tmp,"%s%s",generate_path(list_name),f) ;
X`009expand_name(tmp,tmp) ;
X`009switch (type) `123
X
X`009  case JNETDUMP:
X`009  case PUNCHFILE:
X`009  case TEXTFILE:
X`009`009  sprintf((cmds[i++]=xmalloc(256)),"$ %s",
X`009`009`009   generate_mail_agent(tmp,complex_address)) ;
X`009`009  cmds[i] = 0 ;
X`009`009  status = create_batch_job(cmds,late,null_batch_params) ;
X`009`009  while ( i != 0 ) xfree(cmds[--i]) ;
X`009`125 ;
X`009fclose(msg_file) ;
X`009delete(tmpfile) ;
X`009return(status) ;
X
X`125
X
X`012
X
X
Xsend_mail_bad(command,cmd_line,complex_address)
Xchar *command,*cmd_line,*complex_address ;
X`123
X`009FILE *msg_file ;
X`009char *cmds[10],tmpfile[256] ;
X`009int i,status ;
X
X`009sprintf(tmpfile,"%s%s.MSG",scratch_dir,tmpnam(0)) ;
X`009if ( (msg_file = fopen(tmpfile,"w")) == NULL ) `123
X`009  sendlogfile("Failure to open message file in SEND_MAIL_BAD") ;
X`009  return(0) ;
X`009`125 ;
X
X`009fprintf(msg_file,"\nYour request - %s - to %s, on the line\n\n",
X`009`009command,hook_name.dsc$a_pointer) ;
X`009fprintf(msg_file,"    %s\n\n",cmd_line) ;
X`009fprintf(msg_file,"is not a recogniized command. Please resubmit\n");
X`009fprintf(msg_file,"your request with a line reading HELP.\n");
X`009fclose(msg_file) ;
X
X`009i = 0 ;
X`009sprintf((cmds[i++]=xmalloc(256)),"$ %s",
X`009`009 generate_mail_agent(tmpfile,complex_address)) ;
X`009sprintf((cmds[i++]=xmalloc(120)),"$ delete %s.",tmpfile) ;
X`009cmds[i] = 0 ;
X`009status = create_batch_job(cmds,0,null_batch_params) ;
X`009while ( i != 0 ) xfree(cmds[--i]) ;
X`009return(status) ;
X`125 ;
X
X`012
X
X/*`009SENDDIR`009`009send a directory listing to remote`009`009*/
X
X
X
X
Xsenddir(f,node,user)
Xchar *f ;
Xchar *node,*user ;
X`123
X`009char tmpout[100],filnam[100] ;
X`009char s[256],*cp,*dp,*cmds[10] ;
X`009int flags,i,m,status ;
X
X`009status = 1 ;
X`009m = 2 ;
X`009cp = f ;
X`009dp = s ;
X`009for ( i=strlen(f); i > 0; i-- ) if ( (*dp = *cp++) > ' ' ) then dp++ ;
X`009*dp = 0 ;
X`009if ( s[0] == 0 ) then strcpy(s,"*.*") ;
X`009if ( check_for_directory(s) ) `123
X`009  sendmsg(node,user,"Please omit any directory specifications");
X`009  sendmsg(node,user,"from your request");
X`009  return(0) ;
X`009`125
X`009else `123
X`009  if ( ((status = findfile(s,JNETDUMP)) & 1) == 0 )
X`009    sendmsg(node,user,getmsg(status)) ;
X`009    else sendmsg(node,user,"The file will be sent shortly") ;
X
X`009  sprintf(tmpout,"%s%s.LIS",scratch_dir,tmpnam(0)) ;
X`009  sprintf(filnam,"%s.INFO",hook_name.dsc$a_pointer) ;
X`009  i = 0 ;
X`009  sprintf((cmds[i++] = xmalloc(120)),"$ DIR/SIZE/DATE/OUT=%s %s%s",
X`009 `009  tmpout,generate_path(list_name),s) ;
X`009  sprintf((cmds[i++]=xmalloc(120)),"$ if $STATUS then goto sendit") ;
X`009  sprintf((cmds[i++]=xmalloc(120)),"$ SEN/FI/NET %s %s@%s\n",
X`009`009   not_found,user,node);
X`009  sprintf((cmds[i++]=xmalloc(120)),"$ exit\n$ sendit:") ;
X`009  sprintf((cmds[i++]=xmalloc(256)),"$SEND/FI/CON/NAM=%s %s,%s %s@%s",
X`009            filnam,xfer_info,tmpout,user,node);
X`009  sprintf((cmds[i++]=xmalloc(160)),"$ delete %s.",tmpout) ;
X`009  cmds[i] = 0 ;
X`009  status = create_batch_job(cmds,0,null_batch_params) ;
X`009  while ( i != 0 ) xfree(cmds[--i]) ;
X`009`125   `032
X`009return(status) ;
X`125
X
X
Xsendindex(f,node,user)
Xchar *f ,*node,*user ;
X`123
X`009char s[256],*cmds[10],msg[256] ;
X`009int i,status ;
X
X`009i = 0 ;
X`009if ( *f ) sprintf(s,"%s%s.FILELIST",generate_path(f),f);
X`009else
X`009  sprintf(s,"%s%s.FILELIST",generate_path(default_listname),
X`009`009  hook_name.dsc$a_pointer);
X`009if ( findfile(s,TEXTFILE) & 1 ) `123
X`009  sprintf((cmds[i++] = xmalloc(256)),"$ SEND/FI %s %s@%s",
X`009`009   s,user,node) ;
X`009  cmds[i] = 0 ;
X`009  status = create_batch_job(cmds,0,null_batch_params) ;
X`009  while ( i != 0 ) xfree(cmds[--i]) ;
X`009  sprintf(msg,"The file %s will be sent shortly",s);
X`009  sendmsg(node,user,msg) ;
X`009  return(status) ;
X`009`125
X`009else `123
X`009  sprintf(msg,"W %s not found. DIR batch job created",s) ;
X`009  sendlogfile(msg) ;
X`009  senddir(f,node,user) ;
X`009  return(1) ;
X`009`125 ;
X`125
X
X`012
X
Xsendfile(s,node,user,type)
Xchar *s ;
Xchar *node,*user ;
Xint type ;
X`123
X
X`009struct stat *attrs,*getstat() ;
X`009char *cmds[10],tmpcmd[128],*cp,text_com[80],bin_com[80] ;
X`009char *cmd_name,read_header[128],read_header_name[128],*fn;
X`009char msg_buffer[128] ;
X`009int flags,i,status,wild,que_size ;
X
X`009char *punch_com = "$ SEND/FIL/NET/CONC/NAM=%s %s%s.HDR,%s" ;
X`009char *sendsoon  = "The file %s will be sent shortly" ;
X`009char *sendlate  = "Due to size of %s, it will be sent at 23:00";
X
X
X`009if ( do_package(s,node,user,type) == PACKAGE_COMPLETED ) return(1) ;
X
X`009sprintf(text_com,"$ SEND/FILE/NET %s",generate_path(list_name));
X`009sprintf(bin_com,"$ SEND/FILE/VMSD %s",generate_path(list_name));
X`009sscanf(defer_send_filesize,"%d",&que_size) ;
X
X`009if ( check_for_directory(s) ) `123
X`009  sendmsg(node,user,"Please omit any directory specifications");
X`009  sendmsg(node,user,"from your request");
X`009  return(0) ;
X`009`125 ;
X`009wild = 0 ;
X`009if ( strchr(s,'*') != 0 `124`124 strchr(s,'%') != 0 ) `123
X`009  if ( type == PUNCHFILE ) `123
X`009    sendmsg(node,user,"Wildcards are not supported with the PUNCH");
X`009    sendmsg(node,user,"command.  Use the SEND command for this.") ;
X`009    return(0) ;
X`009  `125
X`009  else `123
X`009    sendmsg(node,user,"Your request will not be honored until") ;
X`009    sendmsg(node,user,"23:00 hours EST since your filename is") ;
X`009    sendmsg(node,user,"wildcarded. Please do not abuse policy") ;
X`009    sendmsg(node,user,"by resubmitting individual filenames.") ;
X`009    wild = 1 ;
X`009  `125 ;
X`009`125 ;
X
X`009if ( strchr(s,'.') == 0 ) `123
X`009  sendmsg(node,user,"Please include an explicit filetype") ;
X`009  sendmsg(node,user,"As in: SEND K11*.MAC or SEND AA*.TXT") ;
X`009  return(0) ;
X`009`125 ;
X`009if ( strcmp(s,"*.*") == 0 ) `123
X`009  sendmsg(node,user,"Please wildcard FILENAME or FILETYPE only");
X`009  return(0) ;
X`009`125 ;
X`009if ( ((status = findfile(s,type)) & 1 ) == 0 ) `123
X`009  sendmsg(node,user,getmsg(status)) ;
X`009  sendmsg(node,user,s) ;
X`009  return( status ) ;
X`009`125 ;
X`009sprintf(tmpcmd,"%s%s",generate_path(list_name),s) ;
X`009if ( wild == 0 ) `123
X`009  attrs = getstat(tmpcmd) ;
X`009  if ( attrs && (wild = (attrs->st_size/512 > que_size)) )
X`009    sprintf(msg_buffer,sendlate,s);
X`009  else
X`009    sprintf(msg_buffer,sendsoon,s) ;
X`009  sendmsg(node,user,msg_buffer) ;`032
X        `125 ;
X
X
X`009switch( type ) `123
X`009  case JNETDUMP:
X`009`009cmd_name = bin_com ;
X`009`009break ;
X`009  case TEXTFILE:
X`009`009cmd_name = text_com ;
X`009`009break ;
X`009  case PUNCHFILE:
X`009`009sprintf(read_header_name,"%s%s%s",scratch_dir,
X`009`009`009tmpnam(read_header),".HDR");
X`009`009header_file = fopen(read_header_name,"w") ;
X`009`009fn = s ;
X`009`009cp = read_header_name ;
X`009`009while ( *cp = *fn++ ) `123 if (*cp == '.') *cp = ' '; cp++ ;`125 ;
X`009`009if ( attrs ) sprintf(tmpcmd,":READ %-30.30sA1 %s",
X`009`009`009  `009     read_header_name,ctime(&attrs->st_ctime)) ;
X`009`009  else sprintf(tmpcmd,":READ  %s",read_header_name) ;
X`009`009fputs(tmpcmd,header_file) ;
X`009`009fclose(header_file) ;
X`009`009sprintf(tmpcmd,punch_com,s,scratch_dir,read_header,
X`009`009`009generate_path(list_name)) ;
X`009`009cmd_name = tmpcmd ;
X`009`009break ;
X`009`125 ;
X
X`009i = 0 ;
X`009sprintf((cmds[i++]=xmalloc(160)),"%s%s %s@%s",cmd_name,s,user,node);
X`009sprintf((cmds[i++]=xmalloc(160)),"$ If $STATUS then goto ex") ;
V`009sprintf((cmds[i++]=xmalloc(160)),"$ SEND/FI %s %s@%s",not_found,user,node
X);
X`009sprintf((cmds[i++]=xmalloc(160)),"$ ex:") ;
X`009cmds[i] = 0 ;
X`009status = create_batch_job(cmds,wild,null_batch_params) ;
X`009while ( i != 0 ) xfree(cmds[--i]) ;
X`009return( status ) ;
X`125
X
X`012
Xsendhelp(s,node,user)
Xchar *s ;
Xchar *node,*user ;
X
X`123
X
Xsendmsg(node,user,"The commands are SEND file,  DIR file, PUNCH file and");
Xsendmsg(node,user,"VMSDUMP file. PUNCH adds a :READ header into the file");
Xsendmsg(node,user,"VMSDUMP file  can be used to get executable files in") ;
Xsendmsg(node,user,"jnet VMSDUMP format  (.EXE,.TSK,.SAV files) and will") ;
Xsendmsg(node,user,"provide protection  from nonstandard EBCDIC  tables.") ;
Xsendmsg(node,user,"All filenames must be in FILENAME.TYPE or  FILE TYPE") ;
Xsendmsg(node,user,"format.") ;
X`125
X
X
Xsendbad(s,node,user)
Xchar *s ;
Xchar *node,*user ;
X`123
X`009char msg[133] ;
X
X`009sprintf(msg,"Unknown command %s. Try HELP",s) ;
X`009sendmsg(node,user,msg) ;
X`125
X
X
Xsendstatus(s,node,user)
X
Xchar *s,*node,*user ;
X
X`123
X`009char *cp, buff[256] ;
X
X`009if ( *(cp = tranlog(requests_since_boot_logical)) ) `123
X`009  sprintf(buff,"Requests since restart: %d   Requests since boot: %s",
X`009`009  requests_since_restart,cp) ;
X`009  sendmsg(node,user,buff) ;
X`009`125 ;
X`009xfree(cp) ;
X`125
X
X
X`012
X
X
X
Xsendmsg(node,user,msg)
Xchar *node,*user,*msg ;
X`123
X`009struct dsc nd,ud,md ;
X`009int mode ;
X`009char *cp ;
X
X`009mode = 2 ;
X`009md.addr = cp = xmalloc( 4+strlen(msg)) ;
X`009sprintf(cp,"* %s",msg) ;
X`009md.len  = strlen(cp) ;
X`009nd.addr = node ;
X`009nd.len  = strlen(node) ;
X`009ud.addr = user ;
X`009ud.len  = strlen(user) ;
X`009jan_send_msg(&mode,&nd,&ud,&md) ;
X`009xfree(cp) ;
X`125
X
X
Xcheck_for_directory(s)
Xchar *s ;
X`123
X`009extern char *strchr() ;
X
X`009return( strchr(s,'[') `124`124 strchr(s,':') `124`124 strchr(s,'<') ) ;
X`125
X
X`009
X`012
X
X
X
X
Xfindfile(f,type)
Xchar *f ;
Xint type ;
X`123
X
X/*`009Verify that at least one file will match the filename passed`009*/
X/*`009so that we can have some assurance that the batch job we submit`009*/
X/*`009to do the actual send will succeed.`009`009`009`009*/
X
X`009char fname[256],*cp,*cp1 ;
X`009struct dsc$descriptor_s srcbuf ;
X`009struct dsc$descriptor_d resbuf ;
X`009int context,status ;
X`009char *defspec = "*.*" ;
X
X`009$DESCRIPTOR(def_spec,"VMSSERV:*.*") ;
X`009$DESCRIPTOR(alt_spec,"VMSSERV_ALL:*.*") ;
X
X/*`009For the time being  4-MAR-1988 10:01  */
X
X`009cp1 = generate_path(list_name) ;
X`009sprintf((cp=xmalloc(strlen(cp1)+strlen(defspec)+1)),"%s%s",cp1,defspec);
X`009def_spec.dsc$a_pointer = cp ;
X`009alt_spec.dsc$a_pointer = cp ;
X`009def_spec.dsc$w_length  = strlen(cp) ;
X`009alt_spec.dsc$w_length  = strlen(cp) ;
X
X`009strcpy(fname,f) ;
X`009if ( strchr(fname,'.') == 0 ) then strcat(fname,"*.*") ;
X`009context = 0 ;
X`009srcbuf.dsc$w_length = strlen( fname ) ;
X`009srcbuf.dsc$b_class  = DSC$K_CLASS_S ;
X`009srcbuf.dsc$b_dtype  = DSC$K_DTYPE_T ;
X`009srcbuf.dsc$a_pointer = fname ;
X
X`009resbuf.dsc$w_length = 0 ;
X`009resbuf.dsc$b_class  = DSC$K_CLASS_S ;
X`009resbuf.dsc$b_dtype  = DSC$K_DTYPE_D ;
X`009resbuf.dsc$a_pointer = 0 ;
X`009
X`009switch (type) `123
X`009  case PUNCHFILE:
X`009  case TEXTFILE:
X`009`009status = lib$find_file(&srcbuf,&resbuf,&context,&def_spec) ;
X`009`009break ;
X`009  case JNETDUMP:
X`009`009status = lib$find_file(&srcbuf,&resbuf,&context,&alt_spec) ;
X`009`009break ;
X`009  default:
X`009`009status = lib$find_file(&srcbuf,&resbuf,&context,&alt_spec) ;
X`009`009break ;
X`009`125 ;
X`009lib$find_file_end(&context) ;
X`009xfree( cp ) ;
X`009return( status ) ;
X`009
X`125
X`012
X
X
X/*
X
X Expand_name() exists solely  for the  purpose of  returning the  actual
Xlocation  of a file. The reason for this is that if GMAIL is used as the
Xinternet reply agent, gmail dies when  trying  to  send  a  file  that's
Xdefined  in  a  search  list. GMAIL always tries to find the file on the
Xfirst translation of the logical name. Thus, we want to return the fully
Xtranslated name. This is easily  done  with  a  $SEARCH  for  the  file,
Xreturning the resultant string.`032
X
X  Passed:`009s`009Destination address for the resultant string
X`009`009f`009The name to expand
X
X  Returns:`009The address of s.
X
X*/
X
Xchar *expand_name(s,f)
Xchar *s,*f ;
X`123
X
X`009int esalen,status ;
X`009struct FAB fab ;
X`009struct NAM nam ;
X
X`009fab = cc$rms_fab ;
X`009nam = cc$rms_nam ;
X`009fab.fab$l_nam = &nam ;
X`009fab.fab$l_fna = f ;
X`009fab.fab$b_fns = strlen(f) ;
X`009nam.nam$l_esa = s ;
X`009nam.nam$b_ess = 255 ;
X`009if ( ((status = sys$parse(&fab)) & 1) == 0 ) `123
X`009  *s = '\0' ;
X`009  return(s) ;
X`009`125 ;
X`009nam.nam$l_rsa = s ;
X`009nam.nam$b_rss = 255 ;
X`009if ( ((status = sys$search(&fab)) & 1) == 0 ) `123
X`009  *s = '\0' ;
X`009  return(s) ;
X`009`125 ;
X`009*(s+(nam.nam$b_rsl&0xFF)) = '\0' ;
X`009return(s) ;
X`125
X`009
X`009
X
X`012
X
X
Xsendopcom_dsc(s)
Xstruct dsc *s ;
X`123
X`009char *m ;
X`009int slen ;
X
X`009slen = s->len & 0xFFFF ;
X`009if ( (m=xmalloc(slen + 1)) != 0 )
X`009  then`009`123
X`009`009strncpy(m,s->addr,slen) ;
X`009`009m[slen] = 0 ;
X`009`009sendopcom(m) ;
X`009`009xfree(m) ;
X`009`009`125 ;
X`125
X
Xsendopcom(s)
Xchar *s ;
X
X/*`009Send a asciz message to opcom`009`009`009`009`009*/
X`123
X
X`009struct opcfmt `123
X`009`009`009unsigned char type ;
X`009`009`009short int target_0_15 ;
X`009`009`009unsigned char target_16_23 ;
X`009`009`009unsigned long rqstid ;
X`009`009`009char msg[80] ;
X`009`009      `125 ;
X`009struct dsc    `123
X`009`009`009long length ;
X`009`009`009struct opcfmt *addr ;
X`009`009      `125 ;
X
X`009struct opcfmt msgdsc ;
X`009struct dsc opmsg = `123 80,&msgdsc `125 ;
X`009int reply_chan,status ;
X
X`009reply_chan = 0 ;
X`009msgdsc.type = OPC$_RQ_RQST ;
X`009msgdsc.target_0_15 = OPC$M_NM_CENTRL ;
X`009msgdsc.target_16_23 = 0 ;
X`009msgdsc.rqstid = 0 ;
X`009strcpy(msgdsc.msg,s) ;
X`009opmsg.length = 8 + strlen(msgdsc.msg) ;
X`009opmsg.addr = &msgdsc ;
X`009return( sys$sndopr(&opmsg,reply_chan) ) ;
X
X`125`009
X
X
X`012
X
Xsendlogfile(s)
Xchar *s ;
X`123
X`009struct dsc$descriptor_s janlogmsg ;
X
X`009janlogmsg.dsc$w_length  = strlen(s) ;
-+-+-+-+-+ End of part 2 +-+-+-+-+-
