COMPILATION LISTING OF SEGMENT rs_open_str_in_ Compiled by: Multics PL/I Compiler, Release 29, of July 28, 1986 Compiled at: Honeywell Bull, Phx, AZ, Sys-M Compiled on: 09/10/87 1451.5 mst Thu Options: optimize list 1 /* *********************************************************** 2* * * 3* * Copyright, (C) Honeywell Information Systems Inc., 1982 * 4* * * 5* * Copyright (c) 1972 by Massachusetts Institute of * 6* * Technology and Honeywell Information Systems, Inc. * 7* * * 8* *********************************************************** */ 9 10 11 /* record_stream_ program for handling stream input openings */ 12 rs_open_str_in_: 13 proc (iocb_ptr_arg); 14 iocb_ptr = iocb_ptr_arg; 15 16 /* set entries for valid operations in this mode */ 17 get_chars = get_chars_rs; 18 get_line = get_line_rs; 19 position = position_str_rs; 20 return; /* end of open initialization routine */ 21 22 get_chars_rs: 23 entry (iocb_ptr_arg, buff_ptr_arg, buff_len_arg, n_read, code); 24 call init_args; 25 if buff_len < 0 26 then code = error_table_$negative_nelem; 27 do while ((buff_len > 0) & (code = 0)); /* get buff_len characters */ 28 if n_left > 0 29 then /* internal buffer is not empty */ 30 do; /* move chars between buffers */ 31 n_moved = min (buff_len, n_left); 32 call move; 33 if n_moved = buff_len 34 then do; /* normal return */ 35 exit: 36 base = base + n_moved; 37 return; 38 end; 39 else /* more characters to be moved */ 40 do; /* advance through input buffer */ 41 buff_len = buff_len - n_moved; 42 buff_ptr = addr (buff (n_moved + 1)); 43 end; 44 end; 45 call get_record; 46 end; 47 return; /* end of get_chars routine */ 48 49 get_line_rs: 50 entry (iocb_ptr_arg, buff_ptr_arg, buff_len_arg, n_read, code); 51 call init_args; 52 if buff_len <= 0 53 then code = error_table_$smallarg; 54 do while ((buff_len > 0) & (code = 0)); /* pick up remainder of line */ 55 if n_left > 0 56 then /* internal buffer is not empty */ 57 do; /* move line between buffers */ 58 line_len = index (substr (rs_buffer, base, n_left), newline); 59 if line_len = 0 60 then length = n_left; 61 else length = line_len; 62 n_moved = min (length, buff_len); 63 call move; /* transfer n_moved chars from rs_buff to input buff */ 64 if length > buff_len 65 then do; /* error: line too long */ 66 code = error_table_$long_record; 67 go to exit; 68 end; 69 else if line_len > 0 /* newline has been found */ 70 then go to exit; 71 else /* keep looking for end of line */ 72 do; /* advance through input_buffer */ 73 buff_len = buff_len - n_moved; 74 buff_ptr = addr (buff (n_moved + 1)); 75 end; 76 end; 77 call get_record; /* rs_buffer empty-- get another record */ 78 end; 79 return; /* end of get_line routine */ 80 81 position_str_rs: 82 entry (iocb_ptr_arg, type, count, code); 83 call brief_init; 84 if type ^= 0 85 then do; /* position to start or end of file */ 86 n_left = 0; /* flush rs_buffer */ 87 call iox_$position (target_iocb_ptr, type, count, code); 88 /* pass call to target */ 89 end; 90 else /* skip case */ 91 do; /* skip n lines */ 92 if count < 0 /* no backward skips permitted */ 93 then code = error_table_$negative_nelem; 94 n = count; 95 do while ((n > 0) & (code = 0)); /* skip n lines */ 96 if n_left <= 0 97 then call get_record; /* if rs_buffer is empty--fill it */ 98 else /* internal buffer is not empty */ 99 do; /* find newline in rs_buffer */ 100 line_len = index (substr (rs_buffer, base, n_left), newline); 101 if line_len > 0 102 then /* newline found */ 103 do; /* successful skip */ 104 base = base + line_len; 105 n_left = n_left - line_len; 106 n = n - 1; 107 end; 108 else n_left = 0; /* crunch past this record */ 109 end; 110 end; 111 end; /* n lines skipped */ 112 return; /* end of stream position routine */ 113 114 /* internal procedures */ 115 init_args: 116 proc; /* initialize upon entry */ 117 buff_len = buff_len_arg; 118 buff_ptr = buff_ptr_arg; 119 n_read = 0; 120 brief_init: 121 entry; 122 code = 0; 123 iocb_ptr = iocb_ptr_arg -> actual_iocb_ptr; 124 rsab_ptr = attach_data_ptr; 125 rs_buff_ptr = open_data_ptr; 126 return; 127 128 end init_args; 129 130 get_record: 131 proc; /* read a new record into the rs_buffer appending newline if default attachment */ 132 call iox_$read_record (target_iocb_ptr, rs_buff_ptr, max_bufsize, n_left, code); 133 if code = 0 134 then do; 135 base = 1; 136 if length_n = 0 137 then /* default attachment */ 138 do; /* append newline */ 139 n_left = n_left + 1; 140 substr (rs_buffer, n_left, 1) = newline; 141 end; 142 end; 143 return; 144 end get_record; 145 146 move: 147 proc; /* take n_moved chars from rs_buffer and append to input buffer */ 148 substr (buffer, 1, n_moved) = substr (rs_buffer, base, n_moved); 149 n_read = n_read + n_moved; 150 n_left = n_left - n_moved; 151 return; 152 153 end move; 154 155 /* declarations for entire program */ 156 dcl (iocb_ptr_arg, iocb_ptr, buff_ptr_arg, buff_ptr) 157 ptr; 158 dcl (buff_len_arg, buff_len, n_read) 159 fixed (21); 160 dcl code fixed (35); 161 dcl error_table_$negative_nelem 162 external fixed (35); 1 1 1 2 dcl 1 iocb aligned based (iocb_ptr), 1 3 /* I/O control block. */ 1 4 2 iocb_version fixed init (1), /* Version number of structure. */ 1 5 2 name char (32), /* I/O name of this block. */ 1 6 2 actual_iocb_ptr ptr, /* IOCB ultimately SYNed to. */ 1 7 2 attach_descrip_ptr ptr, /* Ptr to printable attach description. */ 1 8 2 attach_data_ptr ptr, /* Ptr to attach data structure. */ 1 9 2 open_descrip_ptr ptr, /* Ptr to printable open description. */ 1 10 2 open_data_ptr ptr, /* Ptr to open data structure (old SDB). */ 1 11 2 reserved bit (72), /* Reserved for future use. */ 1 12 2 detach_iocb entry (ptr, fixed (35)),/* detach_iocb(p,s) */ 1 13 2 open entry (ptr, fixed, bit (1) aligned, fixed (35)), 1 14 /* open(p,mode,not_used,s) */ 1 15 2 close entry (ptr, fixed (35)),/* close(p,s) */ 1 16 2 get_line entry (ptr, ptr, fixed (21), fixed (21), fixed (35)), 1 17 /* get_line(p,bufptr,buflen,actlen,s) */ 1 18 2 get_chars entry (ptr, ptr, fixed (21), fixed (21), fixed (35)), 1 19 /* get_chars(p,bufptr,buflen,actlen,s) */ 1 20 2 put_chars entry (ptr, ptr, fixed (21), fixed (35)), 1 21 /* put_chars(p,bufptr,buflen,s) */ 1 22 2 modes entry (ptr, char (*), char (*), fixed (35)), 1 23 /* modes(p,newmode,oldmode,s) */ 1 24 2 position entry (ptr, fixed, fixed (21), fixed (35)), 1 25 /* position(p,u1,u2,s) */ 1 26 2 control entry (ptr, char (*), ptr, fixed (35)), 1 27 /* control(p,order,infptr,s) */ 1 28 2 read_record entry (ptr, ptr, fixed (21), fixed (21), fixed (35)), 1 29 /* read_record(p,bufptr,buflen,actlen,s) */ 1 30 2 write_record entry (ptr, ptr, fixed (21), fixed (35)), 1 31 /* write_record(p,bufptr,buflen,s) */ 1 32 2 rewrite_record entry (ptr, ptr, fixed (21), fixed (35)), 1 33 /* rewrite_record(p,bufptr,buflen,s) */ 1 34 2 delete_record entry (ptr, fixed (35)),/* delete_record(p,s) */ 1 35 2 seek_key entry (ptr, char (256) varying, fixed (21), fixed (35)), 1 36 /* seek_key(p,key,len,s) */ 1 37 2 read_key entry (ptr, char (256) varying, fixed (21), fixed (35)), 1 38 /* read_key(p,key,len,s) */ 1 39 2 read_length entry (ptr, fixed (21), fixed (35)); 1 40 /* read_length(p,len,s) */ 1 41 163 2 1 /* BEGIN: rs_attach_block.incl.pl1 * * * * * */ 2 2 2 3 2 4 /****^ HISTORY COMMENTS: 2 5* 1) change(75-02-13,Asherman), approve(), audit(), install(): 2 6* Initial coding. 2 7* 2) change(87-08-30,GWMay), approve(87-08-30,MCR7730), audit(87-09-10,GDixon), 2 8* install(87-09-10,MR12.1-1104): 2 9* Changed target_name to be unaligned. 2 10* END HISTORY COMMENTS */ 2 11 2 12 2 13 dcl rsab_ptr ptr; 2 14 dcl 1 rs_attach_block based (rsab_ptr) aligned, 2 15 /* record_stream_ attach block */ 2 16 /* the following are set during attachment */ 2 17 2 attach_descrip, 2 18 3 attach_descrip_len 2 19 fixed (35), 2 20 3 attach_descrip_string 2 21 char (66), /* "record_stream_