;PUPDEF.MAC;34    13-JAN-83 14:34:08    EDIT BY TAFT
; Change ASSIGN to .ASSIGN
;PUPDEF.MAC;33    26-SEP-82 15:14:24    EDIT BY TAFT
; Add Desired-Property property and X.prop indices.
; Add New-enumerate command
; Define MOVX and TX-- macros
;PUPDEF.MAC;32    12-SEP-80 11:28:29    EDIT BY TAFT
; Add SNDSTL
;PUPDEF.MAC;31    28-NOV-79 11:14:18    EDIT BY TAFT
; Add FTP/Mail flags to mark type table
;PUPDEF.MAC;30     2-SEP-79 15:58:49    EDIT BY TAFT
;PUPDEF.MAC;29    11-APR-79 17:31:43    EDIT BY TAFT
; Put Sender property in its right alphabetical sequence, dummy
;PUPDEF.MAC;28    18-MAR-79 19:18:28    EDIT BY TAFT
; Put back Sender property
;PUPDEF.MAC;27    24-MAY-78 18:12:41    EDIT BY TAFT
; Add New-Store mark
;PUPDEF.MAC;26    15-SEP-77 11:19:01    EDIT BY TAFT
; Fix [Mailbox-exception] command to take sub-codes
;PUPDEF.MAC;25     1-SEP-77 15:52:10    EDIT BY TAFT
; Revise property and mark tables for updated Mail Transfer Protocol
;PUPDEF.MAC;24     3-JUN-77 11:04:13    EDIT BY TAFT
; Remove "Sender" and "Distribution" properties
;PUPDEF.MAC;23     2-JUN-77 21:33:43    EDIT BY TAFT
; Add "Size" and "Author" properties
; Add "Rename" command mark
;PUPDEF.MAC;22    15-APR-77 10:03:57    EDIT BY TAFT
; Add SERVF
;PUPDEF.MAC;21    31-MAR-77 20:16:42    EDIT BY TAFT
; Add marks and properties for Mail Transfer Protocol
;PUPDEF.MAC;20    19-MAR-77 20:24:21    EDIT BY TAFT
; Add "delete" mark type
; Add date properties
;PUPDEF.MAC;18    18-MAR-77 17:05:38    EDIT BY TAFT
; Move mark and property definitions here from PFUDEF.MAC.
; Add some common flag bits.
;PUPDEF.MAC;16    10-MAR-77 14:24:40    EDIT BY TAFT
; Divide into two definitions files:
; PUPDEF.MAC contains definitions common to PUPSRV and PUPFTP
; PSVDEF.MAC contains stuff specific to PUPSRV
;PUPDEF.MAC;14    20-OCT-76 13:27:17    EDIT BY TAFT
; Add defs for net directory server
;PUPDEF.MAC;13     2-OCT-76 23:16:30    EDIT BY TAFT
; Add defs for gateway info server
;PUPDEF.MAC;11    30-JUN-76 18:04:45    EDIT BY TAFT
; Revise storage assignment macros
; Add defs for event report server

; Copyright 1979 by Xerox Corporation

	UNIVERSAL PUPDEF -- DEFINITIONS COMMON TO PUPSRV AND PUPFTP
	SUBTTL E. A. Taft / September, 1975


; Standard Accumulator assignments

	F=0		; Flags

	A=1		; General scratch
	B=2
	C=3
	D=4

	P1=10		; Permanent -- saved by callees
	P2=11
	P3=12
	P4=13

	P=17		; Stack


; Flag assignments common to PUPSRV and PUPFTP

DEBUGF==1B0		; In debug mode
ENABLF==1B1		; We are enabled as wheel/operator
SERVF==1B2		; On if we are server, off if user

RAISEF==1B18		; Raise lower-case input


; Macro to declare storage PC's to be used in a module

DEFINE USEVAR(LSVAR,LSPVAR) <
	DEFINE LS(LOC,SIZE<1>) <.ASSIGN LOC,LSVAR,SIZE>
	DEFINE LSP(LOC,SIZE<1>) <.ASSIGN LOC,LSPVAR,↑O1000*>
	DEFINE GS(LOC,SIZE<1>) <.ASSIGN LOC,GSVAR,SIZE>
	DEFINE GSP(LOC,SIZE<1>) <.ASSIGN LOC,GSPVAR,↑O1000*>
>

; Definitions needed to append items to a list and then extract
;  them all for assembly in a single place

DEFINE APPEND(DEF,ITEM) <
	DEFINE DEF(XX,MORE) >
>
DEFINE EXPAND(DEF,OP) <
	DEFINE OPMAC(A,ITEM) ,>>
	DEF(OPMAC)
	PURGE OPMAC
>

DEFINE UUO(OP,DISP) <
	UUON==UUON+1
	OPDEF OP [B8]
IFB ,
IFNB ,
>

APPEND(UUOS)	;INIT DISPATCH LIST
UUON==0		;INIT UUO NUMBERS


; UUOs used in PUPSRV and PUPFTP

	UUO PRINT	; Print character specified in eff adr
	UUO UTYPE	; Type message on TTY
	UUO UDTYPE	; Type message on TTY iff debugging
	UUO UWRITE	; Write message on arbitrary designator
	UUO UFTPM	; Send FTP reply message

; UUOs used only in PUPSRV

	UUO ULOG	; Log a message
	UUO UELOG	; Log to both file and TTY

; UUOs used only in PUPFTP

	UUO UERROR	; Type error message, clear input buffer
	UUO UNOISE	; Print noise words if Escape hit
	UUO UPROMP	; Type text and also append to cmd buffer


; Macros to call the above UUOs

DEFINE LOG(STRING) 
DEFINE ELOG(STRING) 
DEFINE TYPE(STRING) 
DEFINE DTYPE(STRING) 
DEFINE NOISE(STRING) 
DEFINE PROMPT(STRING) 
DEFINE ERROR(STRING,NPOP<0>) 
DEFINE WRITE(AC,STRING) <
	IFNB ,
	IFB ,
>
DEFINE FTPM(TYPE,CODE,STRING,NPOP<0>,EOCF) <
	ZZ==0
	IFNB ,
	UFTPM [B7+B15+B16++1
		ASCIZ \STRING\]
>

; FTP-related definitions common to server and user

USRSTL==↑D39		; Maximum name/password/acct string lengths
NAMSTL==↑D<2*39+1+2*39>	; Name.Extension length (with possible ↑Vs)
SFNSTL==USRSTL+2+NAMSTL+7  ; Server-Filename string length
SNDSTL==↑D100		; Sender property string length

PQUOTE=="'"		; Quote character in property lists
EOL==37			; Tenex EOL character (internal use only)


; Property list names and assignments
; Calls are of the form
;	X internal mnemonic , property name , storage
; The internal mnemonic must be 4 characters or less.
; Entries must be sorted alphabetically by property name.
; "Storage" is the maximum number of words needed to store
;  the property (default 1).
; Offsets in a property list are assigned to P.' mnemonic.
; Dispatches to process received properties are PP' mnemonic.

DEFINE PNAMES <
	X AUTH,,USRSTL/5+1
	X BYTE,
	X CNAM,
	X CPSW,,USRSTL/5+1
	X CDAT,
	X DPRP,
	X DEVI,,USRSTL/5+1
	X DIRE,,USRSTL/5+1
	X EOLC,
	X MLBX,,0
	X NAMB,,NAMSTL/5+1
	X RDAT,
	X SNDR,,SNDSTL/5+1
	X SFIL,,SFNSTL/5+1
	X SIZE,
	X TYPE,
	X UACT,,USRSTL/5+2
	X UNAM,
	X UPSW,,USRSTL/5+1
	X VERS,
	X WDAT,
>


; Assign offsets and indices for individual properties in a property list

DEFINE X(SYM,NAME,SIZE<1>) <
	P.'SYM==PLSIZE
	PLSIZE==PLSIZE+SIZE
	X.'SYM==PLINDX
	PLINDX==PLINDX+1
>
	PLSIZE==0
	PLINDX==0

	PNAMES

; Must be able to hold all Desired-Property flags in one word
IFG PLINDX-↑D36,

; Mark type assignments
; Calls are of the form
;	XN internal mnemonic , mark type , name string , flags
; or	XS internal mnemonic , mark type , name string , flags
; The internal mnemonic must be 4 characters or less.
; Mark type must be octal.  Entries must be in order of Mark type.
; Mark types are assigned to MK' mnemonic.
; Dispatches to process received Marks are C.' mnemonic.
; The XS macro declares the Mark to have sub-codes.

; Flag assignments
;	B0			; Command has subcommands
	NFETCH==1B1		; Do not pre-fetch command text
	OKRETR==1B2		; Command ok during Retrieve
	OKSTOR==1B3		; Command ok during Store
	NOTFTS==1B4		; Not allowed in FTP server
	NOTMLS==1B5		; Not allowed in Mail server

DEFINE MARKS <
	XN RETR, 1,
	XN STOR, 2,,NOTMLS
	XS YES,  3,,OKRETR+OKSTOR
	XS NO,   4,,OKRETR+OKSTOR
	XN FILE, 5,,NFETCH+OKSTOR
	XN EOC,  6,,NFETCH+OKRETR+OKSTOR
	XN COMM, 7,,OKRETR+OKSTOR
	XS VERS,10,
	XN NSTO,11,,NOTMLS
	XN ENUM,12,,NOTMLS
	XN PLST,13,
	XN NENU,14,,NOTMLS
	XN ABOR,15,,OKRETR+OKSTOR
	XN DELE,16,,NOTMLS
	XN RENA,17,,NOTMLS
	XN SMAI,20,,NOTFTS
	XN RMAI,21,,NOTFTS
	XN FMAI,22,,NOTFTS
	XS MBEX,23,,NOTFTS
>


; Assign the Mark type symbols

DEFINE XN(SYM,TYPE,NAME,FLAGS) <
	MK'SYM==TYPE
	NMARKS==NMARKS+1
>
DEFINE XS(SYM,TYPE,NAME,FLAGS) <
	MK'SYM==TYPE
	NMARKS==NMARKS+1
>

	NMARKS==0
	MARKS

; MOVX and TX-- instructions, ripped off from MACSYM.MAC

DEFINE MOVX (AC,MSK)<
   ..MX1==MSK			;;EVAL EXPRESSION IF ANY
	..MX2==0		;;FLAG SAYS HAVEN'T DONE IT YET
	IFE <..MX1>B53,<
	  ..MX2==1
	  MOVEI AC,..MX1>	;;LH 0, DO AS RH
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <..MX1>B17,<
	  ..MX2==1
	  MOVSI AC,(..MX1)>>	;;RH 0, DO AS LH
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <<..MX1>B53-↑O777777>,<
	  ..MX2==1
	  HRROI AC,<..MX1>>>	;;LH -1
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <<..MX1>B17-↑O777777B17>,<
	  ..MX2==1
	  HRLOI AC,(..MX1-↑O777777)>> ;;RH -1
	IFE ..MX2,<		;;IF STILL HAVEN'T DONE IT,
	  MOVE AC,[..MX1]>	;;GIVE UP AND USE LITERAL
	PURGE ..MX1,..MX2>

;THIS DOUBLE IRP CAUSES ALL COMBINATIONS OF MODIFICATION AND TESTING
;TO BE DEFINED

DEFINE ..DOTX (M,T)<
	IRP M,<
	IRP T,<
	  DEFINE TX'M'T (AC,MSK)<
		..TX(M'T,AC,)>>>>

	..DOTX (,<,E,N,A>) ;DO ALL DEFINITIONS
	PURGE ..DOTX

;..TX
;ALL TX MACROS JUST CALL ..TX WHICH DOES ALL THE WORK

DEFINE ..TX(MT,AC,MSK)<
   ..TX1==MSK			;;EVAL EXPRESSION IF ANY
	..TX2==0		;;FLAG SAYS HAVEN'T DONE IT YET
	IFE <..TX1&↑O777777B17>,<
	  ..TX2==1		;;LH 0, DO AS RH
	  TR'MT AC,..TX1>
	IFE ..TX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <..TX1&↑O777777>,<
	  ..TX2==1		;;RH 0, DO AS LH
	  TL'MT AC,(..TX1)>>
	IFE ..TX2,<		;;IF HAVEN'T DONE IT YET,
	  IFE <<..TX1>B53-↑O777777>,< ;;IF LH ALL ONES, 
	    ..TX3 (MT,AC)>>	;;TRY Z,O,C SPECIAL CASES
	IFE ..TX2,<		;;IF STILL HAVEN'T DONE IT,
	  TD'MT AC,[..TX1]>	;;MUST GIVE UP AND USE LITERAL
	PURGE ..TX1,..TX2>

;SPECIAL CASE FOR LH ALL ONES

DEFINE ..TX3 (MT,AC)<
	IFIDN ,<		;;IF ZEROING WANTED
	  ..TX2==1
	  ANDI AC,↑-..TX1>	;;CAN DO IT WITH ANDI
	IFIDN ,<		;;IF SET TO ONES WANTED
	  ..TX2==1
	  ORCMI AC,↑-..TX1>	;;CAN DO IT WITH IORCM
	IFIDN ,<		;;IF COMPLEMENT WANTED
	  ..TX2==1
	  EQVI AC,↑-..TX1>>	;;CAN DO IT WITH EQV


	END