MODULE XBUILD ( IDENT = 'X00.18' %TITLE 'XPO$BUILD - XPORT File-spec Build' %BLISS32( ,ADDRESSING_MODE( EXTERNAL=LONG_RELATIVE ) ) %BLISS36( ,ENTRY( XPO$BUILD_SPEC ),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 creates a resultant file specification from ! the information in the user, default, and related file ! specification provided by the caller. A special aspect of ! this processing is the translation of an XPORT temporary file ! name indicator into the appropriate name for the host operating ! system. ! ! ENVIRONMENT: User mode - multiple host operating/file systems ! ! AUTHORS: Ward Clark, CREATION DATE: 20 February 1979 ! Linda Duffell !-- ! ! TABLE OF CONTENTS: ! FORWARD ROUTINE XPO$BUILD_SPEC; ! Resultant file-spec setup routine ! ! INCLUDE FILES: ! LIBRARY 'XPORT' ; ! Public XPORT control block and macro definitions LIBRARY 'XPOSYS' ; ! Internal XPORT macro definitions $XPO_SYS_TEST( $TOPS10, $TOPS20, $11M, $RSTS, $RT11 ) %IF $TOPS10 %THEN REQUIRE 'XT10' ; ! TOPS-10 I/O interface macros %FI %IF $11M %THEN REQUIRE 'XRSX' ; ! XPORT-specific RSX-11 and FCS-11 interface definitions %FI ! ! MACROS: ! ! ! EQUATED SYMBOLS: ! LITERAL yes = 1, ! Used to turn an indicator on no = 0, ! Used to turn an indicator off %IF $TOPS10 %THEN max_file_spec = 132; ! Maximum length of a TOPS-10 file specification %FI %IF $TOPS20 %THEN max_file_spec = 218; ! Maximum length of a TOPS-20 file specification %FI %IF $11M %THEN max_file_spec = 5+9+9+4+4; ! Maximum length of an RSX file specification %FI %IF $RT11 %THEN max_file_spec = 22; ! Maximum length of an RT-11 file specification %FI %IF $RSTS %THEN max_file_spec = 7+11+6+4+6+62; ! Maximum length of an RSTS file specification %FI ! ! PSECT DECLARATIONS: ! $XPO_PSECTS ! Declare XPORT PSECT names and attributes ! ! OWN STORAGE: ! ! ! EXTERNAL REFERENCES: ! %IF $TOPS10 OR $TOPS20 OR $RSTS OR $RT11 %THEN EXTERNAL XPO$COUNT_TEMP; ! Count of temporary files created %FI GLOBAL ROUTINE XPO$BUILD_SPEC ( iob ) = !++ ! ! FUNCTIONAL DESCRIPTION: ! ! This routine creates a resultant file specification from ! the information in the user, default, and related file ! specification provided by the caller. A special aspect of ! this processing is the translation of an XPORT temporary file ! name indicator into the appropriate name for the host operating ! system. ! ! FORMAL PARAMETERS: ! ! iob - address of an IOB ! ! IMPLICIT INPUTS: ! ! None ! ! IMPLICIT OUTPUTS: ! ! None ! ! COMPLETION CODE: (also returned in IOB$G_COMP_CODE) ! ! XPO$_NORMAL - resultant file specification successfully created ! ! XPO$_BAD_DFLT - default file specification is invalid ! (IOB$G_2ND_CODE = $XPO_PARSE_SPEC completion code ! or XPO$_WILDCARD) ! XPO$_BAD_IOB - invalid IOB ! (IOB$G_2ND_CODE = XPO$_BAD_LENGTH -invalid length ! XPO$_BAD_RLTD - related file specification is invalid ! (IOB$G_2ND_CODE = $XPO_PARSE_SPEC completion code ! or XPO$_WILDCARD) ! XPO$_BAD_RSLT - resultant file specification is invalid ! (IOB$G_2ND_CODE = $XPO_PARSE_SPEC completion code ! or $STR_COPY completion code ! or XPO$_WILDCARD) ! XPO$_BAD_SPEC - user file specification is invalid ! (IOB$G_2ND_CODE = $XPO_PARSE_SPEC completion code ! or XPO$_WILDCARD) ! ! SIDE EFFECTS: ! ! None ! !-- BEGIN MAP iob : REF $XPO_IOB(); BIND file_spec_desc = iob[IOB$A_FILE_SPEC] : REF $STR_DESCRIPTOR(), default_desc = .iob[IOB$A_DEFAULT] : $STR_DESCRIPTOR(), related_desc = iob[IOB$A_RELATED] : REF $STR_DESCRIPTOR(), resultant_desc = iob[IOB$T_RESULTANT] : $STR_DESCRIPTOR(); LOCAL character, ! Single ASCII character user_spec : $XPO_SPEC_BLOCK, ! User file-spec parse block default : $XPO_SPEC_BLOCK, ! Default file-spec parse block related : $XPO_SPEC_BLOCK, ! Related file-spec parse block resultant : $XPO_SPEC_BLOCK, ! Resultant file-spec parse block local_spec_buff : ! Local resultant file-spec buffer VECTOR[ CH$ALLOCATION(max_file_spec) ], local_spec : ! Local resultant file-spec descriptor $STR_DESCRIPTOR( CLASS=BOUNDED ), file_spec_ptr; ! Pointer into the local resultant file-spec buffer MACRO MERGE_DEFAULT( field_name, wild_name ) = ! Macro to merge user and default file-spec parse blocks IF .user_spec[ %NAME('XPO$H_',field_name) ] EQL 0 THEN BEGIN %IF NOT %NULL(wild_name) %THEN user_spec[ %NAME('XPO$V_WILD_',wild_name) ] = .default[ %NAME('XPO$V_WILD_',wild_name) ]; %FI user_spec[ %NAME('XPO$H_',field_name) ] = .default[ %NAME('XPO$H_',field_name) ]; user_spec[ %NAME('XPO$A_',field_name) ] = .default[ %NAME('XPO$A_',field_name) ]; END %; ! ! Initialization ! $XPO_MAIN_BEGIN( IO ) ! Beginning of MAIN_BLOCK code block ! ! Don't create a new resultant file specification if one already exists. ! IF .resultant_desc[STR$H_LENGTH] NEQ 0 ! If a resultant file-spec already exists, THEN ! $XPO_QUIT( NORMAL ); ! return immediately to the caller. ! ! Setup a descriptor for the local file specification buffer. ! $STR_DESC_INIT( DESCRIPTOR = local_spec, CLASS = BOUNDED, STRING = ( max_file_spec, CH$PTR(local_spec_buff) ) ); ! ! Special XPORT temporary file setup. ! IF $STR_EQL( STRING1 = .file_spec_desc, ! If FILE_SPEC=$XPO_TEMPORARY was specified, STRING2 = $XPO_TEMPORARY, ! perform special temporary file setup. FAILURE = 0 ) THEN ! perform special temporary file setup. BEGIN LOCAL status; status = %IF $TOPS10 %THEN ! Create a TOPS-10 temporary file spec: $STR_COPY( ! STRING = ! $STR_CONCAT( ! $XPO_DFLT_DEV, ! default device name $STR_ASCII( $T10_PJOB, LEADING_ZERO, ! user's job number LENGTH=3 ), ! 'X', ! "X" $STR_ASCII( .XPO$COUNT_TEMP, ! user's temporary file count LEADING_ZERO, LENGTH=2 ), ! '.TMP' ), ! file extension (.TMP) TARGET = resultant_desc, FAILURE = 0 ); XPO$COUNT_TEMP = .XPO$COUNT_TEMP + 1; ! Increment the TOPS-10 temporary file number. %FI %IF $TOPS20 %THEN ! Create a TOPS-20 temporary file spec: $STR_COPY( ! STRING = ! $STR_CONCAT( ! %STRING( $XPO_DFLT_DEV, 'XPORT' ), ! default device name + "XPORT" $STR_ASCII( .XPO$COUNT_TEMP, ! user's temporary file count LEADING_ZERO, LENGTH=3 ), ! '.TEMPORARY;T' ), ! file extension TARGET = resultant_desc, FAILURE = 0 ); XPO$COUNT_TEMP = .XPO$COUNT_TEMP + 1; ! Increment the TOPS20 temporary file number. %FI %IF $11M %THEN ! Create an RSX-11M temporary file spec: $STR_COPY( STRING = %STRING( $XPO_DFLT_DEV, ! default device name 'XPORT.TMP' ), ! temporary file spec TARGET = resultant_desc, FAILURE = 0 ); %FI %IF $RT11 OR $RSTS %THEN ! Create an RT-11/RSTS temporary file spec: $STR_COPY( ! STRING = ! $STR_CONCAT( ! %STRING( $XPO_DFLT_DEV, 'XPO' ), ! default device name + "XPO" $STR_ASCII( .XPO$COUNT_TEMP, ! user's temporary file count LEADING_ZERO, LENGTH=3 ), ! '.TMP' ), ! file extension (.TMP) TARGET = resultant_desc, FAILURE = 0 ); XPO$COUNT_TEMP = .XPO$COUNT_TEMP + 1; ! Increment the RT-11 temporary file number. %FI IF .status ! If the temporary file-spec was successfully created, THEN ! BEGIN ! iob[IOB$V_TEMPORARY] = yes; ! indicate a temporary file name $XPO_QUIT( NORMAL ); ! and jump to return a success code. END ELSE $XPO_QUIT( BAD_RSLT, (.status) ); ! Otherwise, return error codes to the caller. END; ! ! Parse the user, default, and related file specifications. ! $XPO_IF_NOT( $XPO_PARSE_SPEC( ! Parse the user file specification. FILE_SPEC = .file_spec_desc, SPEC_BLOCK = user_spec, FAILURE = 0 ) ) THEN $XPO_QUIT( BAD_SPEC, (.$XPO_STATUS) ); IF NOT .iob[IOB$V_OUTPUT] AND .user_spec[XPO$V_WILD_CARD] THEN $XPO_QUIT( BAD_SPEC, WILDCARD ); $XPO_IF_NOT( $XPO_PARSE_SPEC( ! Parse the default file specification. FILE_SPEC = default_desc, SPEC_BLOCK = default, FAILURE = 0 ) ) THEN $XPO_QUIT( BAD_DFLT, (.$XPO_STATUS) ); IF NOT .iob[IOB$V_OUTPUT] AND .default[XPO$V_WILD_CARD] THEN $XPO_QUIT( BAD_DFLT, WILDCARD ); $XPO_IF_NOT( $XPO_PARSE_SPEC( ! Parse the related file specification. FILE_SPEC = .related_desc, SPEC_BLOCK = related, FAILURE = 0 ) ) THEN $XPO_QUIT( BAD_RLTD, (.$XPO_STATUS) ); IF NOT .iob[IOB$V_OUTPUT] AND .related[XPO$V_WILD_CARD] THEN $XPO_QUIT( BAD_RLTD, WILDCARD ); ! ! Fill in the local resultant file specification buffer. ! ! ! Select a network node name. ! %IF $VMS %THEN MERGE_DEFAULT[ NODE, NODE ]; ! Use the default node name if no user ! node name is provided. IF (NOT .iob[IOB$V_OUTPUT] AND ! Use the related node name if: .user_spec[XPO$H_NODE] EQL 0) ! input file & no user node name OR (.iob[IOB$V_OUTPUT] AND ! or output file .user_spec[XPO$V_WILD_NODE] AND ! & user wildcard node name .related[XPO$H_NODE] NEQ 0) ! & related node name exists THEN $STR_APPEND( STRING = related[XPO$T_NODE], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE $STR_APPEND( STRING = user_spec[XPO$T_NODE], ! Otherwise, use the user node name. TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); %FI ! ! Select a device name. ! MERGE_DEFAULT[ DEVICE, DEV ]; ! Use the default device name if no user ! device name is provided. IF .related[XPO$H_DEVICE] NEQ 0 AND ! Use the related device name if: ( (NOT .iob[IOB$V_OUTPUT] AND ! input file .user_spec[XPO$H_DEVICE] EQL 0) ! & no user device name OR (.iob[IOB$V_OUTPUT] AND ! or output file .user_spec[XPO$V_WILD_DEV]) ) ! & user wildcard device name THEN $STR_APPEND( STRING = related[XPO$T_DEVICE], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE BEGIN IF .user_spec[XPO$V_WILD_DEV] ! If there is no related device name and a THEN ! user wildcard device name $XPO_QUIT( BAD_RLTD, BAD_DEVICE ); ! return error codes to the caller. IF .user_spec[XPO$H_DEVICE] EQL 0 THEN $STR_APPEND( STRING = $XPO_DFLT_DEV, ! Otherwise, use a default device name TARGET = local_spec, ! OPTION = UP_CASE, ! FAILURE = 0 ) ! ELSE ! $STR_APPEND( ! or the device name provided by the caller. STRING = user_spec[XPO$T_DEVICE], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); END; ! ! Select a directory specification. ! %IF NOT $RT11 %THEN MERGE_DEFAULT[ DIRECT, DIR ]; ! Use the default directory spec if no user ! directory spec is provided. IF (NOT .iob[IOB$V_OUTPUT] AND ! Use the related directory spec if: .user_spec[XPO$H_DIRECT] EQL 0) ! input file & no user directory spec OR (.iob[IOB$V_OUTPUT] AND ! or output file .user_spec[XPO$V_WILD_DIR] AND ! & user wildcard directory spec .related[XPO$H_DIRECT] NEQ 0 AND ! & related directory spec exists .user_spec[XPO$H_DIRECT] EQL 4) ! THEN $STR_APPEND( STRING = related[XPO$T_DIRECT], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE IF NOT .user_spec[XPO$V_WILD_DIR] ! If not a user wildcard directory *** TEMPORARY *** THEN ! $STR_APPEND( ! use the user directory spec. STRING = user_spec[XPO$T_DIRECT], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); %FI ! ! Select a file name. ! MERGE_DEFAULT[ FILE_NAME, NAME ]; ! Use the default file name if no user ! file name is provided. ! Use the related file name if: IF (.user_spec[XPO$H_FILE_NAME] EQL 0) OR ! no user file name (.iob[IOB$V_OUTPUT] AND ! or output file .user_spec[XPO$V_WILD_NAME] AND ! & user wildcard file name .related[XPO$H_FILE_NAME] NEQ 0 AND ! & related file name exists .user_spec[XPO$H_FILE_NAME] EQL 1) ! THEN $STR_APPEND( STRING = related[XPO$T_FILE_NAME], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE $STR_APPEND( ! Otherwise, use the user file name. STRING = user_spec[XPO$T_FILE_NAME], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); ! ! Select a file type (extension). ! MERGE_DEFAULT[ FILE_TYPE, TYPE ]; ! Use the default file type if no user ! file type is provided. ! Use the related file type if: IF (.user_spec[XPO$H_FILE_TYPE] EQL 0) OR ! no user file type (.iob[IOB$V_OUTPUT] AND ! or output file .user_spec[XPO$V_WILD_TYPE] AND ! & user wildcard file type .related[XPO$H_FILE_TYPE] NEQ 0 AND ! & related file type exists .user_spec[XPO$H_FILE_TYPE] EQL 2) ! THEN $STR_APPEND( STRING = related[XPO$T_FILE_TYPE], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE $STR_APPEND( ! Otherwise, use the user file type. STRING = user_spec[XPO$T_FILE_TYPE], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); ! ! Select a version number. ! %IF NOT $TOPS10 AND NOT $RT11 AND NOT $RSTS %THEN MERGE_DEFAULT[ FILE_VER, VER ]; ! Use the default version number if no user ! version number is provided. ! Use the related version number if: IF .user_spec[XPO$V_WILD_VER] AND ! user wildcard version number .related[XPO$H_FILE_VER] NEQ 0 AND ! & related version number exists .iob[IOB$V_OUTPUT] ! & an output file is being opened THEN $STR_APPEND( STRING = related[XPO$T_FILE_VER], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE $STR_APPEND( ! Otherwise, use the user version number. STRING = user_spec[XPO$T_FILE_VER], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); %FI %IF $RSTS %THEN ! ! Select RSTS file protection. ! MERGE_DEFAULT[ FILE_PROT]; ! Use the default file protection if no user ! file protection is provided. IF .related[XPO$H_FILE_PROT] NEQ 0 AND ! Use the related file protection if: (NOT .iob[IOB$V_OUTPUT] AND ! input file .user_spec[XPO$H_FILE_PROT] EQL 0) ! & no user protection THEN $STR_APPEND( STRING = related[XPO$T_FILE_PROT], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE $STR_APPEND( ! Otherwise use the protection provided by the caller. STRING = user_spec[XPO$T_FILE_PROT], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); %FI %IF $TOPS20 OR $RT11 OR $RSTS %THEN ! ! Select 'EXTRA' file information. ! MERGE_DEFAULT[ EXTRA ]; ! Use the default if no user ! file 'EXTRA' information is provided. IF .related[XPO$H_EXTRA] NEQ 0 AND ! Use the related if: (NOT .iob[IOB$V_OUTPUT] AND ! input file .user_spec[XPO$H_EXTRA] EQL 0) ! & no user 'EXTRA' is provided. THEN $STR_APPEND( STRING = related[XPO$T_EXTRA], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ) ELSE $STR_APPEND( ! Otherwise, use the 'EXTRA' provided by the caller. STRING = user_spec[XPO$T_EXTRA], TARGET = local_spec, OPTION = UP_CASE, FAILURE = 0 ); %FI ! ! Check for a wildcard in an input resultant file specification. ! $XPO_IF_NOT( $XPO_PARSE_SPEC( ! Parse the resultant file specification. FILE_SPEC = local_spec, SPEC_BLOCK = resultant, FAILURE = 0 )) THEN $XPO_QUIT( BAD_RSLT, (.$XPO_STATUS) ); IF NOT .iob[IOB$V_OUTPUT] AND ! Test for an input wildcard (unsupported). .resultant[XPO$V_WILD_CARD] THEN $XPO_QUIT( BAD_RSLT, WILDCARD ); ! ! See if the user explicitly specified his own terminal. ! %IF NOT $RT11 AND NOT $RSTS %THEN IF $STR_EQL( STRING1 = $XPO_INPUT, ! If the user specified his own terminal, STRING2 = resultant[XPO$T_DEVICE] ) ! THEN ! BEGIN ! $XPO_IF_NOT( $STR_COPY( ! use only the device name as the resultant file-spec. STRING = resultant[XPO$T_DEVICE], TARGET = resultant_desc, FAILURE = 0 ) ) THEN $XPO_QUIT( BAD_RSLT, (.$XPO_STATUS) ); iob[IOB$V_TERMINAL] = yes; ! Indicate that the user specified a terminal. $XPO_QUIT( NORMAL ); ! and return a success code to the caller. END; %FI %IF $RT11 %THEN IF ($STR_EQL( STRING1 = $XPO_INPUT, ! If the user specified his own terminal, STRING2 = resultant[XPO$T_DEVICE] )) OR ! ($STR_EQL( STRING1 = 'TT:', ! STRING2 = resultant[XPO$T_DEVICE] )) ! THEN ! BEGIN ! $XPO_IF_NOT( $STR_COPY( ! use only the device name as the resultant file-spec. STRING = 'TT:', TARGET = resultant_desc, FAILURE = 0 ) ) THEN $XPO_QUIT( BAD_RSLT, (.$XPO_STATUS) ); iob[IOB$V_TERMINAL] = yes; ! Indicate that the user specified a terminal. $XPO_QUIT( NORMAL ); ! and return a success code to the caller. END; %FI %IF $RSTS %THEN IF ($STR_EQL( STRING1 = $XPO_INPUT, ! If the user specified his own terminal, STRING2 = resultant[XPO$T_DEVICE] )) OR ! ($STR_EQL( STRING1 = 'KB:', ! STRING2 = resultant[XPO$T_DEVICE] )) ! THEN ! BEGIN ! $XPO_IF_NOT( $STR_COPY( ! use only the device name as the resultant file-spec. STRING = 'KB:', TARGET = resultant_desc, FAILURE = 0 ) ) THEN $XPO_QUIT( BAD_RSLT, (.$XPO_STATUS) ); iob[IOB$V_TERMINAL] = yes; ! Indicate that the user specified a terminal. $XPO_QUIT( NORMAL ); ! and return a success code to the caller. END; %FI ! ! Move the newly created resultant file specification into dynamic memory. ! $XPO_IF_NOT( $STR_COPY( ! Copy the resultant file-spec into dynamic memory. STRING = local_spec, TARGET = resultant_desc, FAILURE = 0 ) ) THEN $XPO_QUIT( BAD_RSLT, (.$XPO_STATUS) ); $XPO_QUIT( NORMAL ); ! Return a success code to the caller. $XPO_MAIN_END; ! End of MAIN_BLOCK code block ! ! Return to the caller. ! RETURN .iob[IOB$G_COMP_CODE] ! Return the primary IOB completion code. END; END ELUDOM