;<PUP>PUPDEF.MAC.10, 31-Mar-82 15:48:46, Edit by SCHOEN
; Add global storage dummy parameters to USEVAR definition
;<PUP>PUPDEF.MAC;8	3/1/81			Edit by RINDFLEISCH
; Added SAVE/RSTR macros for PUSH/POP and CALL/RET for PUSHJ/POPJ
;<PUP>PUPDEF.MAC;7	20-Aug-80 13:12:12  Edit by SCHOEN
; Added RUNM UUO for lower-fork runnable PUPFTP
;<PUP>PUPDEF.MAC;6	11-Jul-80 13:06:53  Edit by SCHOEN
; Added SHXINT, SHXFLG defns for user "!" typeout when not debugging
;<PUP>PUPDEF.MAC;5	4/23/80		Edit by SCHOEN
; SEARCH SYSDEF so calls to VACCT and GDACC simulations don't fail
; on Tops20
;<SCHOEN>PUPDEF.MAC;4    4/3/80			EDIT BY RINDFLEISCH
; Added macros to simulate VACCT and GDACC JSYSs
;<PUP>PUPDEF.MAC;3    25-Mar-80 12:45:08    EDIT BY SCHOEN
; Changed (no)tenex/tops20 opdefs to macro so they work
;<PUP>PUPDEF.MAC;2    21-Mar-80 12:45:08    EDIT BY SCHOEN
; Define (no)tenex/tops20 macros for conditional assembly
;<PUP>PUPDEF.MAC;30     2-SEP-79 15:58:49    EDIT BY TAFT
;<PUP>PUPDEF.MAC;29    11-APR-79 17:31:43    EDIT BY TAFT
; Put Sender property in its right alphabetical sequence, dummy
;<PUP>PUPDEF.MAC;28    18-MAR-79 19:18:28    EDIT BY TAFT
; Put back Sender property
;<PUP>PUPDEF.MAC;27    24-MAY-78 18:12:41    EDIT BY TAFT
; Add New-Store mark
;<PUP>PUPDEF.MAC;26    15-SEP-77 11:19:01    EDIT BY TAFT
; Fix [Mailbox-exception] command to take sub-codes
;<PUP>PUPDEF.MAC;25     1-SEP-77 15:52:10    EDIT BY TAFT
; Revise property and mark tables for updated Mail Transfer Protocol
;<PUP>PUPDEF.MAC;24     3-JUN-77 11:04:13    EDIT BY TAFT
; Remove "Sender" and "Distribution" properties
;<PUP>PUPDEF.MAC;23     2-JUN-77 21:33:43    EDIT BY TAFT
; Add "Size" and "Author" properties
; Add "Rename" command mark
;<PUP>PUPDEF.MAC;22    15-APR-77 10:03:57    EDIT BY TAFT
; Add SERVF
;<PUP>PUPDEF.MAC;21    31-MAR-77 20:16:42    EDIT BY TAFT
; Add marks and properties for Mail Transfer Protocol
;<PUP>PUPDEF.MAC;20    19-MAR-77 20:24:21    EDIT BY TAFT
; Add "delete" mark type
; Add date properties
;<PUP>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.
;<PUP>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
;<PUP>PUPDEF.MAC;14    20-OCT-76 13:27:17    EDIT BY TAFT
; Add defs for net directory server
;<PUP>PUPDEF.MAC;13     2-OCT-76 23:16:30    EDIT BY TAFT
; Add defs for gateway info server
;<PUP>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

IFNDEF FT10X,<SEARCH SYSDEF>

; 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
RUNF==1B3		; PUPFTP running as lower fork option

RAISEF==1B18		; Raise lower-case input
SHXFLG==1B19		; Typed a "!" on a line


; Macros to define conditional assembly for Tops-20/Tenex
; assumes calling program has "SEARCHed SYSDEF"
; ejs, 3/20/80
define tops20,<ifn ft20>
define notops20,<ife ft20>
define tenex,<ifn ft10x>
define notenex,<ife ft10x>

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

DEFINE USEVAR(LSVAR,LSPVAR,GSVAR<GSVAR>,GSPVAR<GSPVAR>) <
	DEFINE LS(LOC,SIZE<1>) <.ASSIGN LOC,LSVAR,SIZE>
	DEFINE LSP(LOC,SIZE<1>) <.ASSIGN LOC,LSPVAR,↑O1000*<SIZE>>
	DEFINE GS(LOC,SIZE<1>) <.ASSIGN LOC,GSVAR,SIZE>
	DEFINE GSP(LOC,SIZE<1>) <.ASSIGN LOC,GSPVAR,↑O1000*<SIZE>>
>

; 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) <XX DEF,<ITEM,MORE>>
>
DEFINE EXPAND(DEF,OP) <
	DEFINE OPMAC(A,ITEM) <IRP ITEM <IFNB <ITEM>,<OP>>>
	DEF(OPMAC)
	PURGE OPMAC
>

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

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
	UUO URUNM	; Error message to shared page

; Macros to call the above UUOs

DEFINE LOG(STRING) <ULOG [ASCIZ \STRING\]>
DEFINE ELOG(STRING) <UELOG [ASCIZ \STRING\]>
DEFINE TYPE(STRING) <UTYPE [ASCIZ \STRING\]>
DEFINE DTYPE(STRING) <UDTYPE [ASCIZ \STRING\]>
DEFINE NOISE(STRING) <UNOISE [ASCIZ \(STRING) \]>
DEFINE PROMPT(STRING) <UPROMP [ASCIZ \STRING\]>
DEFINE ERROR(STRING,NPOP<0>) <UERROR NPOP,[ASCIZ \STRING\]>
DEFINE WRITE(AC,STRING) <
	IFNB <STRING>,<UWRITE AC,[ASCIZ \STRING\]>
	IFB <STRING>,<UWRITE A,[ASCIZ \AC\]>
>
DEFINE FTPM(TYPE,CODE,STRING,NPOP<0>,EOCF) <
	ZZ==<IFNB <EOCF>,<1>>
	UFTPM [<MK'TYPE>B7+<CODE>B15+<ZZ>B16+<NPOP>+1
		ASCIZ \STRING\]
>
DEFINE RUNM(TYPE,STRING) <
	URUNM [TYPE
	       ASCIZ \STRING\]
>

; MACRO definitions to save and restore lists of locations
DEFINE SAVE(LST)<
   IRP LST,<PUSH P,LST>		; Save stuff on stack
>

DEFINE RSTR(LST)<
   IRP LST,<POP P,LST>		; Recover stuff from stack
>

; OPDEF's for subroutine call/return
OPDEF	CALL [PUSHJ P,]
OPDEF	RET  [POPJ P,]


; 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

PQUOTE=="'"		; Quote character in property lists
CR==15			; Char defs
LF==12
FF==14
DEL==177
EOL==37			; Tenex EOL character (internal use only)

; Global network numbers (assigned by Jon Postel/ARPA)
NW%CHS==7		; CHAOSNET
NW%ARP==12		; ARPANET
NW%DLN==26		; DIALNET
NW%SUN==44		; SUNET
NW%LCL==:NW%SUN		; Local connected network for PUPSRV

SHXINT==↑d10		; Type a "!" every 10 pages if not debugging

; 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,<AUTHOR>,USRSTL/5+1
	X BYTE,<BYTE-SIZE>
	X CNAM,<CONNECT-NAME>
	X CPSW,<CONNECT-PASSWORD>,USRSTL/5+1
	X CDAT,<CREATION-DATE>
	X DEVI,<DEVICE>,USRSTL/5+1
	X DIRE,<DIRECTORY>,USRSTL/5+1
	X EOLC,<END-OF-LINE-CONVENTION>
	X MLBX,<MAILBOX>,0
	X NAMB,<NAME-BODY>,NAMSTL/5+1
	X RDAT,<READ-DATE>
	X SNDR,<SENDER>,USRSTL/5+1
	X SFIL,<SERVER-FILENAME>,SFNSTL/5+1
	X SIZE,<SIZE>
	X TYPE,<TYPE>
	X UACT,<USER-ACCOUNT>,USRSTL/5+2
	X UNAM,<USER-NAME>
	X UPSW,<USER-PASSWORD>,USRSTL/5+1
	X VERS,<VERSION>
	X WDAT,<WRITE-DATE>
>


; Assign offsets for individual properties in a property list

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

	PNAMES

; 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

DEFINE MARKS <
	XN RETR, 1,<Retrieve>
	XN STOR, 2,<Store>
	XS YES,  3,<Yes>,OKRETR+OKSTOR
	XS NO,   4,<No>,OKRETR+OKSTOR
	XN FILE, 5,<Here-is-file>,NFETCH+OKSTOR
	XN EOC,  6,<End-of-command>,NFETCH+OKRETR+OKSTOR
	XN COMM, 7,<Comment>,OKRETR+OKSTOR
	XS VERS,10,<Version>
	XN NSTO,11,<New-store>
	XN DIR, 12,<Directory>
	XN PLST,13,<Here-is-property-list>
	XN YUSR,14,<You-are-user>
	XN ABOR,15,<Abort>,OKRETR+OKSTOR
	XN DELE,16,<Delete>
	XN RENA,17,<Rename>
	XN SMAI,20,<Store-mail>
	XN RMAI,21,<Retrieve-mail>
	XN FMAI,22,<Flush-mail>
	XS MBEX,23,<Mailbox-exception>
>


; 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




	END