Trailing-Edge
-
PDP-10 Archives
-
DEC_CMS-20_V1.0_SRC
-
cms/sources/strops.b36
There are no other files named strops.b36 in the archive.
MODULE strops (! string operations
IDENT = '1',
%if
%bliss(bliss36)
%then
language(bliss36)
%fi
) =
BEGIN
!
! COPYRIGHT (C) 1982 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: CMS Library Processor
!
!
! ABSTRACT:
!
! This module contains routines that handle string operations on the
! DS-20.
!
! ENVIRONMENT: DS-20
!
! AUTHOR: R. Wheater CREATION DATE: 28 jan 81
!
! MODIFIED BY:
!
!--
!
! TABLE OF CONTENTS:
!
FORWARD ROUTINE
cvtas0:novalue, ! convert descriptor string to ASCIZ string
cvtdes, ! convert ASCIZ string to descriptor string
freas0; ! free memory used by ASCIZ string
!
! INCLUDE FILES:
!
require 'jsys:';
library 'XPORT:';
require 'BLISSX:';
!
! MACROS:
!
!
! EQUATED SYMBOLS:
!
!
! OWN STORAGE:
!
!
! EXTERNAL REFERENCES:
!
external routine
bug; ! print bug message
GLOBAL ROUTINE cvtas0(a_desc,a_ptr_z): novalue =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine will take a string in xport descriptor format and
! convert to an ASCIZ string(defined by a pointer and ending in
! BINARY ZEROS). The storage for the ASCIZ string is allocated within
! this routine. The storage may be later freed using the FREAS0 string.
!
! FORMAL PARAMETERS:
!
! a_desc Address of descriptor for string(as defined conceptually
! by export.
!
! a_ptr_z Address of location to write pointer to string after
! converted to an ASCIZ string.
!
! IMPLICIT INPUTS:
!
! None.
!
! IMPLICIT OUTPUTS:
!
! None.
!
! ROUTINE VALUE and
! COMPLETION CODES:
!
! None.
!
! SIDE EFFECTS:
!
! None.
!
!--
BEGIN
bind
desc = .a_desc: desc_block, ! desc
ptr_z = .a_ptr_z; ! ASCIZ ptr
local
p_tmp, ! work pointer
status;
! get required dynamic memory
status=$xpo_get_mem(characters=.desc[desc_len] + 1,
result=ptr_z,failure=0) ;
if
.status neq xpo$_normal
then
bug(cat('CVTAS0 is unable a acquire dynamic memory')) ;
p_tmp = .ptr_z ;
! transfer the string
ch$move(.desc[desc_len],.desc[desc_ptr],.p_tmp) ;
p_tmp = ch$plus(.p_tmp,.desc[desc_len]) ;
! add binary zero at end
ch$wchar(00,.p_tmp) ;
END; ! end of routine cvtas0
GLOBAL ROUTINE cvtdes(ptr_z,a_desc) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine will take an ASCIZ string and convert it back to xport
! string descriptor format.
!
! FORMAL PARAMETERS:
!
! ptr_z Pointer to valid ASCIZ string
!
! a_desc Address of the descriptor to be used in storing the string
! the string, the length field of this descriptor will be
! updated.
!
! IMPLICIT INPUTS:
!
!
!
! IMPLICIT OUTPUTS:
!
!
!
! ROUTINE VALUE and
! COMPLETION CODES:
!
! true = success
! false = input not ASCIZ string or input string too big for the output
! descriptor.
!
! SIDE EFFECTS:
!
!
!
!--
BEGIN
bind
desc = .a_desc: desc_block ; ! desc to use on output
local
p_tmp ; ! work pointer
! scan string for binary zero character (use input length as scan length)
p_tmp = ch$find_ch(.desc[desc_len]+1,.ptr_z,00) ;
if
ch$fail(.p_tmp) eql 1
then
return false ;
desc[desc_len] = ch$diff(.p_tmp,.ptr_z) ;
! move string
ch$move(.desc[desc_len],.ptr_z,.desc[desc_ptr]) ;
true
END; ! end of routine cvtdesc
GLOBAL ROUTINE freas0(ptr_z) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine frees the dynamic memory contains the ASCIZ string that was
! acquired by the CVTAS0 routine.
!
! FORMAL PARAMETERS:
!
! ptr_z pointer to ASCIZ string
!
! IMPLICIT INPUTS:
!
! None.
!
! IMPLICIT OUTPUTS:
!
! None.
!
! ROUTINE VALUE and
! COMPLETION CODES:
!
! True = success
! false = could not find end of string and/or no memory was freed
!
! SIDE EFFECTS:
!
! None.
!
!--
BEGIN
local
count, ! character count
p_tmp, ! work pointer
status; ! xport return status
! find ending binary zeros
p_tmp = ch$find_ch((1^18),.ptr_z,%char(00)) ;
if
ch$fail(.p_tmp) eql 1
then
return false ;
count = ch$diff(.p_tmp,.ptr_z) + 1 ;
! free the memory
status = $xpo_free_mem(string=(.count,.ptr_z),failure=0) ;
if
.status neq xpo$_normal
then
return false ;
true
END; ! end of routine freas0
END ! End of module
ELUDOM