MODULE SVALID ( IDENT = 'X00.05' %TITLE 'String Descriptor Validation' %BLISS32( ,ADDRESSING_MODE( EXTERNAL=LONG_RELATIVE ) ) %BLISS36( ,ENTRY( XST$VALIDATE ),OTS='' ) ) = BEGIN ! ! COPYRIGHT (c) 1980 BY ! DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. ! ! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ! ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE ! INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER ! COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY ! OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY ! TRANSFERRED. ! ! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE ! AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT ! CORPORATION. ! ! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS ! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL. ! !++ ! ! FACILITY: BLISS Library ! ! ABSTRACT: ! ! This module is the XPORT String Descriptor validator. ! ! ENVIRONMENT: User mode - multiple host operating/file systems ! ! AUTHOR: Ward Clark, CREATION DATE: 15-Feb-80 ! !-- ! ! TABLE OF CONTENTS: ! FORWARD ROUTINE XST$VALIDATE; ! String descriptor validation routine ! ! INCLUDE FILES: ! LIBRARY 'XPORT' ; ! Public XPORT control block and macro definitions LIBRARY 'XPOSYS' ; ! Internal XPORT macro definitions $XPO_SYS_TEST( $TOPS10, $TOPS20, $VMS, $11M, $IAS, $RSTS, $RT11 ) ! ! MACROS: ! ! ! EQUATED SYMBOLS: ! ! ! PSECT DECLARATIONS: ! $XPO_PSECTS ! Declare XPORT PSECT names and attributes ! ! OWN STORAGE: ! %IF $VMS %THEN OWN psl_mode : BYTE INITIAL( 0 ), ! PROBE indicator to use PSL mode fixed_size : ! Length in bytes of a FIXED/DYNAMIC descriptor WORD INITIAL( STR$K_F_BLN * %UPVAL ), bounded_size : ! Length in bytes of a BOUNDED/DYNAMIC_BOUNDED descriptor WORD INITIAL( STR$K_B_BLN * %UPVAL ); %FI ! ! EXTERNAL REFERENCES: ! %TITLE 'XST$VALIDATE - String Descriptor Validation' GLOBAL ROUTINE XST$VALIDATE( string ) = !++ ! ! FUNCTIONAL DESCRIPTION: ! ! This routine verifies that all fields of a string descriptor are ! valid and consistant. ! ! FORMAL PARAMETERS: ! ! string - address of a string descriptor ! ! IMPLICIT INPUTS: ! ! None ! ! IMPLICIT OUTPUTS: ! ! None ! ! COMPLETION CODES: ! ! STR$_NORMAL - the string descriptor is valid ! ! STR$_BAD_CLASS - invalid string descriptor class ! STR$_BAD_DTYPE - invalid string data type ! STR$_BAD_MAXLEN - invalid maximum string length ! STR$_BAD_PTR - invalid string pointer ! STR$_NO_STRING - no string specified ! XPO$_BAD_ADDR - descriptor in read-protected memory (VMS only) ! or ! failure completion code from $STR_ASCII, $STR_CONCAT or $STR_FORMAT ! ! SIDE EFFECTS: ! ! None ! !-- BEGIN MAP string : REF $STR_DESCRIPTOR( CLASS = BOUNDED ); %IF $VMS %THEN BUILTIN PROBER, PROBEW; ! VAX memory probe functions %FI ! ! Test for a non-existant string descriptor. ! IF .string EQL 0 THEN RETURN STR$_NO_STRING; ! ! Verify that the descriptor can be read. ! %IF $VMS %THEN IF NOT PROBER( psl_mode, fixed_size, string[$BASE] ) THEN RETURN XPO$_BAD_ADDR; %FI ! ! Base the specific tests on the string data type. ! SELECTONE .string[STR$B_DTYPE] OF SET ! ! First validate the string descriptor class. ! [ STR$K_DTYPE_T ] : ! Standard ASCII string: SELECTONE .string[STR$B_CLASS] OF ! SET ! [ STR$K_CLASS_F, ! FIXED STR$K_CLASS_D, ! DYNAMIC STR$K_CLASS_B, ! BOUNDED STR$K_CLASS_DB, ! DYNAMIC_BOUNDED STR$K_CLASS_XT ] : ! XPORT_TEMPORARY STR$_NORMAL; [ OTHERWISE ] : RETURN STR$_BAD_CLASS; TES; [ STR$K_DTYPE_XXX ] : ! Erroneous XPORT temporary string: SELECTONE .string[STR$B_CLASS] OF ! SET ! [ STR$K_CLASS_F, ! FIXED STR$K_CLASS_XT ] : ! XPORT_TEMPORARY RETURN .string[STR$A_POINTER]; ! Return the $STR_ASCII, $STR_CONCAT or $STR_FORMAT error code. [ OTHERWISE ] : RETURN STR$_BAD_DTYPE; TES; [ OTHERWISE ] : ! Invalid string data type RETURN STR$_BAD_DTYPE; TES; ! ! Validate the string text/buffer. ! SELECTONE .string[STR$B_CLASS] OF ! Base the test(s) on the descriptor class. SET [ STR$K_CLASS_F, STR$K_CLASS_D ] : ! FIXED or DYNAMIC descriptor: %IF NOT $VMS %THEN IF .string[STR$H_LENGTH] NEQ 0 AND ! If string exists, .string[STR$A_POINTER] EQL 0 ! make sure a pointer exists. THEN RETURN STR$_BAD_PTR; %ELSE IF .string[STR$H_LENGTH] NEQ 0 ! If a VAX string exists, THEN ! IF NOT PROBER( psl_mode, ! make sure the string can be read. string[STR$H_LENGTH], .string[STR$A_POINTER] ) THEN RETURN STR$_BAD_PTR; [ STR$K_CLASS_D ] : ! DYNAMIC descriptor: IF .string[STR$H_LENGTH] NEQ 0 ! If a VAX string exists, THEN ! IF NOT PROBEW( psl_mode, ! make sure the string can be written. string[STR$H_LENGTH], .string[STR$A_POINTER] ) THEN RETURN STR$_BAD_PTR; %FI [ STR$K_CLASS_B, STR$K_CLASS_DB ] : ! BOUNDED or DYNAMIC_BOUNDED descriptor: BEGIN %IF $VMS %THEN IF NOT PROBER( psl_mode, bounded_size, ! Verify that VAX descriptor can be read. string[$BASE] ) THEN RETURN XPO$_BAD_ADDR; %FI ! Verify that the maximum string length is large enuf. IF ( .string[STR$B_CLASS] EQL STR$K_CLASS_B OR .string[STR$B_CLASS] EQL STR$K_CLASS_DB ) AND .string[STR$H_MAXLEN] LSS .string[STR$H_LENGTH] + .string[STR$H_PFXLEN] THEN RETURN STR$_BAD_MAXLEN; %IF NOT $VMS %THEN IF .string[STR$H_MAXLEN] NEQ 0 AND ! If string exists, .string[STR$A_POINTER] EQL 0 ! make sure a pointer exists. THEN RETURN STR$_BAD_PTR; %ELSE IF .string[STR$H_MAXLEN] NEQ 0 ! If a VAX string exists, THEN ! IF NOT PROBER( psl_mode, ! make sure the string can be read. string[STR$H_MAXLEN], .string[STR$A_POINTER] - .string[STR$H_PFXLEN] ) THEN RETURN STR$_BAD_PTR; %FI END; %IF $VMS %THEN [ STR$K_CLASS_DB ] : ! DYNAMIC_BOUNDED descriptor: IF .string[STR$H_MAXLEN] NEQ 0 ! If a VAX string exists, THEN ! IF NOT PROBEW( psl_mode, ! make sure the string can be written. string[STR$H_MAXLEN], .string[STR$A_POINTER] - .string[STR$H_PFXLEN] ) THEN RETURN STR$_BAD_PTR; %FI TES; ! ! Return to the caller after successful string descriptor validation. ! RETURN STR$_NORMAL END; END ELUDOM