🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: vmsnet.sources.d
Article #128

mailserv.001-of-001

#128
From: duck
Date: Mon, 04 Jan 1993 03:31
384 lines
15149 bytes
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-010  25-Jun-1992
$!   On  3-JAN-1993 23:30:54.34   By user DUCK 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. MAILSERVER.DOC;2
$!       2. DOMAIL.COM;44
$!       3. SCAN.COM;5
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ x = P1 - f$parse(P1,,,"version")
$ y = f$search(x)
$ if y .eqs. "" then $ goto file_absent
$ x = f$integer(f$parse(P1,,,"version")-";")
$ y = f$integer(f$parse(y,,,"version")-";")
$ if x .gt. y then $ goto file_absent
$ if f$mode() .eqs. "INTERACTIVE" then $ goto file_interactive
$ if x .eq. y then e "-W-EXISTS, File ''P1' exists. Skipped."
$ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists. Skipped."
$file_delete:
$ delete 'f'*
$ exit
$file_interactive:
$ if x .eq. y then e "-W-EXISTS, File ''P1' exists."
$ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists."
$ read/error=file_delete/end=file_delete-
  /prompt="Create new version [y/n]: " -
  sys$command x
$ if .not. x then $ e "-W-SKIPPED, File ''P1' skipped."
$ if .not. x then $ goto file_delete
$ P1 = P1 - f$parse(P1,,,"version")
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X                   Mail-Server Documentation Release 010393
X                               by Craig Taylor
X                          duck@pembvax1.pembroke.edu
X                                   (c) 1993
X
X
XThe following two files: domail.com and scan.com make up a mail-server progr
Vam
Xwhich can be run in a user account with regular privlages. The only logicals
Xor symbols that need to be changed are in the file domail.com and are:
X
X workdir - this is a definition that reflects where in your account the
X    mailserver program is running from. A mailserver.log file should also be
X    created initially with a blank line. Failure to do so will cause the
X    program to abort with an error when run.
X
X bindir - an equate which reflects where files that are binary that require
X    uuencode to be sent. A file called temp.txt will be generated in this
X    directory  from the uuencode comand before being sent.
X
X txtdir - an equate which reflects where all files that can be sent without
X    uuencode are. The catalog.txt (for the command "catalog") and
X    "documentation.txt" (for the command "help") and status.txt (for the
X    command "status") are assumed. If you wish to change, disable or remove
V any
X    of these modify the scan.com file as appropriate.
X
XTo install the mailserver mofidy the above definitions and equates in
Xdomail.com, create a mailserver.log with a blank line in the workdir. Then m
Vake
Xsure that the system manager has installed uuenccode or that you have n equa
Vte`20
Xsetup in your login.com.`20
X
XIn addation there is a command called "subscribe" which adds the user's name
V to
Xa file called mag.dis. To change the file name requires modifying the scan.c
Vom
Xfile.`20
X
XModifying scan.com is fairly easy for a user with moderate experience in VAX
XDCL language. Those who are not famaliar with DCL should be able to understa
Vnd
Xwhat is going on upon careful reading.
X
XThe mailserver works by first deleting any previous files, going into mail a
Vnd
Xextracting all mail messages that begin with a subject line of "mailser" int
Vo a
Xfile in the workdir directory called requests.txt. This is done in domail.co
Vm.
XNote that it's recommended that the following is added to your login.com fil
Ve:
X
X$ if f$interactive()
X$ then
X. . . `5Bnoormal login.com file`5D
X$ else
X$ mail
Xselect newmail
Xselect/subject="mailser"
Xmove/all mail
Xexit
X$ endif
X
XThis will make sure that all new requests are in your mail directory. If you
Xwish to preview them before they are processed then do not add the above lin
Ves.
X
XAlso you will need to create a folder in mail callled oldmail. I chose to ha
Vve
Xthe mailserver put all the commands in that folder after it finished process
Ving
Xthem instead of deleting them so that I could back-check with them against t
Vhe
Xlogs if any errors cropped up. You'll want to periodically go in there and
Xdelete all the messages but one (if you delete them all then the folder will
Xcease to exist).
X
XI've tried to make this documentation as complete as possible - be sure to r
Vead
Xeach paragraph fully and follow the instructions within. I'm also interested
V in
Xany comments you may have concerning it. One note 'tho - if you send me mail
Xmake sure that it doesn't have the "mailser" subject line or else the
Xmailserver I'm running will flag it as a bunch of errors (oh! - the error.tx
Vt
Xis the file that contains a message stating that an error exists). Use
X"mail-server" instead.
X
XFor any questions or comments feel free to contact me as
Xduck@pembvax1.pembroke.edu.
$ CALL UNPACK MAILSERVER.DOC;2 1947746383
$ create 'f'
X$ goto start
X
XMail-Server by Craig Taylor (duck@pembvax1.pembroke.edu)          (c) 1993
X- written in VAX/DCL code consisting of three files:
X     mailserver.com - this file that is submitted to a queue
X     scan.com       - generates .com file based on requests
X     doit.com       - this is the actual file that is used to do the
X                      requests. - regenerated each time.
X
XRelease 010393
X
X$start:
X$ define workdir stud$disk:`5Bduck.mailserv`5D        ! running directory
X$ txtdir :== "stud$disk:`5Bduck.mailserv.text`5D      ! all the send files
X$ bindir :== "stud$disk:`5Bduck.mailserv.binary`5D    ! all the psend files
X$ !
X$ set default workdir
X$ set noon
X$   del requests.txt;*`09`09`09`09  ! delete all the files
X$   del doit.com;*
X$ set on
X$ !
X$ mail`09`09`09`09`09`09  ! go into mail and extract
Xselect mail
Xselect/subject="mailser"
Xextract/all requests.txt
Xmove/all oldmail
Xquit
X$ if (f$search("requests.txt") .eqs. "") then goto endsub
X$   @scan.com`09`09`09`09`09  ! scan and generate files
X$   @doit.com`09`09`09`09`09  ! and send the files....`20
X$ endsub:
X$ wait 00:10:00              ! make sure time has passed before re-submittin
Vg
X$ submit/restart/nolog/after="tomorrow+2"/queue=sys$large workdir:domail.com
$ CALL UNPACK DOMAIL.COM;44 659241511
$ create 'f'
X$!scan.com               (c) 1993 by Craig Taylor (duck@pembvax1.pembroke.ed
Vu)
X$! - Scan and generate .com file for mail-server....
X$! release 010393
X$!
X$! parses requests.txt
X$!
X$ set default workdir
X$ !
X$ open/read infil workdir:requests.txt
X$ open/write outfil workdir:doit.com
X$ open/append logfil workdir:mailserv.log
X$ !
X$ ! write initialization stuff...
X$ write outfil "$ !generated by t.com "  ! be sure to create a new version.
X$ write logfil "%%-Started "+f$time()
X$ !`20
X$ ! States -> 0 = looking for from
X$ !           1 = skipping subjects (local)
X$ !           2 = skipping subjects (far)
X$ !           3 = skipping blanks / looking for commands.
X$ !           4 = looking for commands
X$ !       ->>> then back to 0.
X$ !
X$ state = 0
X$ whofrom = ""
X$ loop:
X$   read/end=endrun infil line
X$   line=f$edit(line,"compress, lowercase")
X$   if (line .eqs. "`0C")`20
X$   then
X$     state = 0
X$     goto loop
X$   endif
X$   if (state .eqs. 3) .and. (f$length(line) .eqs. 0) then goto loop
X$   if (state .eqs. 0) .and. (line .eqs. "") then goto loop
X$   if (state .eqs. 0) .and. (f$locate("from:",line) .eqs. 0)`20
X$   then
X$     state = 1
X$     num = f$length(line)-f$locate("mx%",line)-3
X$     temp = f$extract(f$locate("mx%",line),num,line)
X$     whofrom = f$extract(0,f$locate(" ",temp),temp)
X$     goto loop
X$   endif
X$   if (state .gt. 2) then goto a2
X$   if (line .nes. "") then goto loop      !states 1 and 2
X$      state = state+1
X$      goto loop
X$ ! now = state 3>=  -> write output until null
X$ a2:
X$ state = 4  `20
X$   if (line .eqs. "")`20
X$     then
X$       state = 0   ! go back to looking for "from"
X$       goto loop
X$     else
X$       if (f$locate("send ",line) .eqs. 0)`09`09! hhandle send command
X$        then
X$          num = f$length(line)-f$locate("send ",line)-5
X$          temp = txtdir + f$extract(5,num,line)
X$          if (f$search(temp) .nes. "")`20
X$            then
X$              write outfil "$ mail "
X$              write outfil "send "+temp
X$              write outfil whofrom
X$              write outfil "MAILSERVER REQUEST:"+line
X$              write outfil "quit"
X$              write outfil "$ ! "+line
X$`09       write logfil "SENT:   `09`09"+line+"`09"+whofrom
X$              goto loop
X$            else
X$              write outfil "$ mail "
X$              write outfil "send "+txtdir+"error.txt"
X$              write outfil whofrom
X$              write outfil "MAILSERVER FILE NOT FOUND:"+line
X$              write outfil "quit"
X$              write outfil "$ ! "+line
X$`09       write logfil "%%-SEND-ERROR:`09"+line+"`09"+whofrom
X$              goto loop
X$            endif
X$        endif
X$       if (f$locate("psend ",line) .eqs. 0)`09`09! handle psend command
X$        then
X$          num = f$length(line)-f$locate("psend ",line)-6
X$          temp = bindir+f$extract(6,num,line)
X$          if (f$search(temp) .nes. "")`20
X$            then
X$`09       write outfil "uuencode "+temp+" "+bindir+"temp.txt"
X$              write outfil "$ mail "
X$              write outfil "send "+bindir+"temp.txt"
X$              write outfil whofrom
X$              write outfil "MAILSERVER REQUEST:"+line
X$              write outfil "quit"
X$`09       write outfil "$ del "+bindir+"temp.txt;"
X$              write outfil "$ ! "+line
X$`09       write logfil "PSENT:   `09`09"+line+"`09"+whofrom
X$              goto loop
X$            else
X$              write outfil "$ mail "
X$              write outfil "send "+txtdir+"error.txt"
X$              write outfil whofrom
X$              write outfil "MAILSERVER FILE NOT FOUND:"+line
X$              write outfil "quit"
X$              write outfil "$ ! "+line
X$`09       write logfil PSEND-ERROR:`09"+line+"`09"+whofrom
X$              goto loop
X$            endif
X$        endif
X$        if (f$locate("status",line) .eqs. 0) `09`09! send file
X$        then
X$              write outfil "$ mail "
X$              write outfil "send "+txtdir+"status.txt"
X$              write outfil whofrom
X$              write outfil "MAILSERVER STATUS:"+line
X$              write outfil "quit"
X$              write outfil "$ ! "+line
X$`09       write logfil "STATUS`09 `09`09`09"+whofrom
X$              goto loop
X$        endif
X$        if (f$locate("help",line) .eqs. 0) `09`09! send help file
X$        then
X$              write outfil "$ mail "
X$              write outfil "send "+txtdir+"documentation.txt"
X$              write outfil whofrom
X$              write outfil "MAILSERVER HELP:"+line
X$              write outfil "quit"
X$              write outfil "$ ! "+line
X$`09       write logfil "HELP`09 `09`09`09"+whofrom
X$              goto loop
X$        endif
X$        if (f$locate("catalog",line) .eqs. 0) `09`09! send catalog file
X$        then
X$              write outfil "$ mail "
X$              write outfil "send "+txtdir+"catalog.txt"
X$              write outfil whofrom
X$              write outfil "MAILSERVER CATALOG:"+line
X$              write outfil "quit"
X$              write outfil "$ ! "+line
X$`09       write logfil "CATALOG`09`09`09`09"+whofrom
X$              goto loop
X$        endif
X$        if (f$locate("subscribe",line) .eqs. 0)`09! add "from" name 2 list
X$        then
X$            open/append temp_file workdir:mag.dis
X$            write temp_file whofrom
X$            close temp_file
X$            write outfil "$ mail "
X$            write outfil "send "+txtdir+"subscribed.txt"
X$            write outfil whofrom
X$            write outfil "MAILSERVER SUBSCRIBED:"+line
X$            write outfil "quit"
X$            write outfil "$ ! "+line
X$            write logfil "SUBSCRIBED`09`09`09`09"+whofrom
X$            goto loop
X$        endif
X$    endif
X$ goto  loop
X
X$ endrun:
X$    write logfil "%%-END-OF-RUN "+f$time()+" %%"
X$    close logfil
X$    close outfil
X$    close infil
$ CALL UNPACK SCAN.COM;5 557998421
$ v=f$verify(v)
$ EXIT
Technical Details
Message-ID: <1993Jan3.233133.1@pembvax1.pembroke.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!concert!lester.appstate.edu!pembvax1.pembroke.edu!duck

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!concert!lester.appstate.edu!pembvax1.pembroke.edu!duck
From: duck@pembvax1.pembroke.edu
Newsgroups: vmsnet.sources.d
Subject: mailserv.001-of-001
Message-ID: <1993Jan3.233133.1@pembvax1.pembroke.edu>
Date: 4 Jan 93 03:31:33 GMT
Organization: Pembroke State University
Lines: 384
NNTP-Posting-Host: pembvax1.pembroke.edu