!
!   MBMLIB - library file for the MailBox Master
!

literal
    true = 1 eql 1,
    false = 0 eql 1;

literal
    Ctrl_C_efn = 63,
    QIO_efn = 62,
    Timer_efn = 61;


macro
    $dsc = $bblock[8] %,
    $dsc_dynamic = $bblock[8] preset (
	[DSC$W_LENGTH] = 0, [DSC$B_DTYPE] = DSC$K_DTYPE_T,
	[DSC$B_CLASS] = DSC$K_CLASS_D, [DSC$A_POINTER] = 0) %,
    $dsc_static = $bblock[8] preset (
	[DSC$W_LENGTH] = 0, [DSC$B_DTYPE] = DSC$K_DTYPE_T,
	[DSC$B_CLASS] = DSC$K_CLASS_S, [DSC$A_POINTER] = 0) %,
    VMS_sts = $bblock[4] %;


macro
    SS_Error (cond) = cond %,

    MBM_Cond (cond) =
	(external literal %name ('MBM_', cond); %name ('MBM_', cond)) %,

    MBM_Error (cond) =
	MBM_Cond (cond)
	, %length - 1
	%if not %null (%remaining) %then , %remaining %fi %;

keywordmacro
    RMS_Error (fab, rab) =
	%if %null (fab) eqv %null (rab) %then
	    %error ('RMS_Error macro allows exactly one argument')
	%else
	    %if not %null (fab) %then
		(bind ifab = fab: $FAB_DECL; .ifab[FAB$L_STS]),
		(bind ifab = fab: $FAB_DECL; .ifab[FAB$L_STV]) %fi
	    %if not %null (rab) %then
		(bind irab = rab: $RAB_DECL; .irab[RAB$L_STS]),
		(bind irab = rab: $RAB_DECL; .irab[RAB$L_STV]) %fi
	%fi %;



macro ef_mask (efn) [] =
    (
	1^((efn) mod %bpval)
	%if not %null (%remaining) %then or ef_mask (%remaining) %fi
    ) %;


macro
    _VMS_ItmLst (Info_Source) [Tuple] =
	 _VMS_Itm (Prefix = Info_Source, %remove (Tuple)) %;
keywordmacro
    _VMS_Itm (Prefix, Code, BufLen=%upval, Buffer, RetLen=0) =
	(BufLen + %name (Prefix, '$_', Code)^16), Buffer, RetLen %;

macro
    DVI_ItmLst [] =
	_VMS_ItmLst (DVI, %remaining), 0 %,

    JPI_ItmLst [] =
	_VMS_ItmLst (JPI, %remaining), JPI$C_LISTEND %,

    SYI_ItmLst [] =
	_VMS_ItmLst (SYI, %remaining), SYI$C_LISTEND %;


field
    IOSB$FIELD =
	set
    IOSB$W_STATUS	= [0, 0, 16, 0],
    IOSB$W_IOLEN	= [2, 0, 16, 0],
    IOSB$W_TRMNTR	= [4, 0, 16, 0],
    IOSB$W_TRMSIZ	= [6, 0, 16, 0],
    IOSB$L_PID		= [4, 0, 32, 0]
	tes;
macro
    IOSB$DEF = $bblock[8] field (IOSB$FIELD) %;

