COMPILATION LISTING OF SEGMENT iodd_parse_ Compiled by: Multics PL/I Compiler, Release 31a, of October 12, 1988 Compiled at: Honeywell Bull, Phoenix AZ, SysM Compiled on: 10/28/88 1333.4 mst Fri Options: optimize map 1 /****^ ******************************************** 2* * * 3* * Copyright, (C) Honeywell Bull Inc., 1988 * 4* * * 5* ******************************************** */ 6 7 8 /****^ HISTORY COMMENTS: 9* 1) change(88-06-13,Brunelle), approve(88-06-13,MCR7911), 10* audit(88-10-21,Wallman), install(88-10-28,MR12.2-1199): 11* Created. 12* END HISTORY COMMENTS */ 13 14 /* format: style4 */ 15 16 /* This is a common procedure containing entrypoints to parse an input command 17* line and to parse a major/minor arguments string */ 18 19 iodd_parse_: proc; 20 21 /* no entry here */ 22 return; 23 24 /* Arguments */ 25 26 /* Following two are for iodd_parse_$args */ 27 dcl key char (*) var parameter; /* key string to look for */ 28 dcl arg_string char (*) parameter; /* string to examine */ 29 30 /* following three are for iodd_parse_$command */ 31 dcl command_line char (*) parameter; /* command line to parse */ 32 dcl elements_ptr ptr parameter; /* pointer to the structure we fill in */ 33 dcl ec fixed bin (35); /* error code */ 34 35 /* External Procedures & Variables */ 36 37 dcl error_table_$noarg fixed bin (35) ext static; 38 dcl error_table_$bigarg fixed bin (35) ext static; 39 dcl error_table_$unbalanced_quotes ext fixed bin (35); 40 41 /* Builtins */ 42 43 dcl (addr, index, length, ltrim, rtrim, search, substr, verify) builtin; 44 45 /* Internal Static */ 46 47 dcl COMMA char (1) defined QUOTE_COMMA pos (2); 48 dcl NEWLINE char (1) defined WHITESPACE pos (4); 49 dcl SPACE_OR_TAB char (2) defined WHITESPACE pos (2); 50 dcl QUOTE char (1) defined QUOTE_COMMA pos (1); 51 dcl QUOTE_COMMA char (2) int static options (constant) init (""","); 52 53 /* whitespace - BS SP HT NL VT NP CR */ 54 dcl WHITESPACE char (7) static options (constant) init (" 55 "); 56 57 /* Automatic */ 58 59 dcl break_char_index fixed bin; /* location of break char following keyword string */ 60 dcl first char (1) based (addr (line)); /* first char of the line */ 61 dcl i fixed bin; /* do index */ 62 dcl keyword_location fixed bin; /* location of keyword within arg_string */ 63 dcl len fixed bin; /* general index variable for length */ 64 dcl line char (128); /* internal copy of the command line */ 65 dcl one_char char (1); /* obvious */ 66 dcl start fixed bin; /* starting position of the token */ 67 dcl string_offset fixed bin; 68 dcl temp char (256) var; 69 dcl value char (256) var; 70 71 dcl 1 elements aligned based (elements_ptr), /* this is the structure we fill in */ 72 2 max_wanted fixed bin, /* the number of tokens to look for */ 73 2 n fixed bin, /* number of valid tokens */ 74 2 token (max_wanted) char (64) var; /* save exact length with each */ 75 76 args: entry (key, arg_string) returns (char (256) var); 77 78 /* this entry is a common argument parsing routine used by the I/O daemon 79* driver processes on the system. It was originally extracted from 80* remote_driver_.pl1. 81* 82* Each of the drivers on the system use this routine to parse the data in 83* their major and/or minor argument strings. The format for data within the 84* strings is 85* 86* [optional space] [, [optional space] ] 87**/ 88 89 /* make gross pass to see if key exists in input string. if not, get out quick */ 90 keyword_location = index (arg_string, key); 91 if keyword_location = 0 then do; 92 return (""); 93 end; 94 95 /* the keyword exists. if it is 1st keyword or preceeded by whitespace, it is 96* valid keyword; otherwise it is last part of another type of keyword and we 97* must look further */ 98 99 if keyword_location > 1 then do; 100 try_again: one_char = substr (arg_string, keyword_location - 1, 1); 101 if index (WHITESPACE, one_char) ^= 0 then /* preceeded by whitespace */ 102 goto copy_to_temp_string; 103 if one_char = COMMA then /* preceeded by a comma */ 104 goto copy_to_temp_string; 105 106 if keyword_location < length (arg_string) then do; 107 string_offset = keyword_location + length (key); 108 keyword_location = index (substr (arg_string, string_offset), key); 109 if keyword_location ^= 0 then do; 110 keyword_location = keyword_location + string_offset - 1; 111 go to try_again; 112 end; 113 end; 114 return (""); 115 end; 116 else do; 117 118 /* copy all of string following the keyword, removing leading and trailing whitespace */ 119 copy_to_temp_string: 120 string_offset = keyword_location + length (key); 121 temp = rtrim (ltrim (substr (arg_string, string_offset), WHITESPACE), WHITESPACE); 122 123 if temp = "" then do; /* all blanks */ 124 return (""); 125 end; 126 127 /* look for a break char to terminate end of return string. If no break char 128* is found, return value is rest of string so just return it as is */ 129 break_char_index = search (temp, QUOTE_COMMA); 130 if break_char_index = 0 then do; 131 return (temp); 132 end; 133 134 /* found some sort of break char, must process based on type of character it 135* is. If it is a comma, this terminates the end of the string to return so 136* return everything up to the comma */ 137 if substr (temp, break_char_index, 1) = COMMA then do; 138 return (substr (temp, 1, break_char_index - 1)); 139 end; 140 141 /* the break character was a start quote then we must look for an end quote */ 142 /* copy everything up to the quote into return string */ 143 value = substr (temp, 1, break_char_index - 1); 144 145 find_level_1: if break_char_index = length (temp) then /* quotes don't balance */ 146 return (""); 147 temp = substr (temp, break_char_index + 1); /* skip starting quote */ 148 break_char_index = search (temp, QUOTE); /* look for closing quote */ 149 /* allow commas within quotes */ 150 if break_char_index = 0 then do; /* quotes do not balance */ 151 return (""); /* so return nothing */ 152 end; 153 154 /* copy everything up to the new quote */ 155 value = value || substr (temp, 1, break_char_index - 1); 156 157 if break_char_index = length (temp) then /* unbalanced quotes */ 158 return (""); 159 if substr (temp, break_char_index + 1, 1) = QUOTE then do; /* double quote? */ 160 value = value || QUOTE; /* replace with a single quote */ 161 break_char_index = break_char_index + 1;/* move the index */ 162 go to find_level_1; /* and search on */ 163 end; 164 end; 165 166 temp = value; 167 168 return (rtrim (temp)); 169 170 171 172 command: entry (command_line, elements_ptr, ec); 173 174 /* entry to parse the command_line string into a structure containing one 175* element per token up to the maximum requested */ 176 177 elements.n = 0; /* initialize to none found */ 178 len = length (command_line); /* how long is it? */ 179 if len > 127 then do; /* if too long to leave trailing blank */ 180 ec = error_table_$bigarg; /* give a code */ 181 return; /* and quit now */ 182 end; 183 line = command_line; /* copy the string */ 184 i = index (line, NEWLINE); /* see if there was a nl char */ 185 if i > 0 then line = substr (line, 1, i - 1); /* and drop it and the rest */ 186 do i = 1 to max_wanted; /* look for max_wanted tokens */ 187 len = verify (line, SPACE_OR_TAB); /* correct for leading spaces or tabs */ 188 if len = 0 then go to tally; /* nothing left so quit */ 189 if len > 1 then line = substr (line, len); /* left justify */ 190 start = 1; /* assume the first char is good */ 191 if first = QUOTE then do; /* different action for quoted string */ 192 start = 2; /* so we will skip the quote later */ 193 len = index (substr (line, 2), QUOTE); /* find the closing quote */ 194 if len = 0 then do; 195 ec = error_table_$unbalanced_quotes; /* too bad */ 196 return; /* return what we found */ 197 end; 198 end; 199 else len = search (line, SPACE_OR_TAB); /* find end of token */ 200 if len > 64 then do; /* complain if too long */ 201 ec = error_table_$bigarg; 202 return; /* return what we found */ 203 end; 204 elements.n = elements.n + 1; /* add one more token to the list */ 205 elements.token (elements.n) = substr (line, start, len - 1); 206 line = substr (line, len + start); /* get ready for the next one...left shift */ 207 end; 208 209 tally: if elements.n = 0 then /* if none found, give an error */ 210 ec = error_table_$noarg; 211 else ec = 0; 212 return; 213 214 end iodd_parse_; SOURCE FILES USED IN THIS COMPILATION. LINE NUMBER DATE MODIFIED NAME PATHNAME 0 10/28/88 1230.2 iodd_parse_.pl1 >special_ldd>install>MR12.2-1199>iodd_parse_.pl1 NAMES DECLARED IN THIS COMPILATION. IDENTIFIER OFFSET LOC STORAGE CLASS DATA TYPE ATTRIBUTES AND REFERENCES (* indicates a set context) NAMES DECLARED BY DECLARE STATEMENT. COMMA defined char(1) packed unaligned dcl 47 ref 103 137 NEWLINE defined char(1) packed unaligned dcl 48 ref 184 QUOTE defined char(1) packed unaligned dcl 50 ref 148 159 160 191 193 QUOTE_COMMA 000002 constant char(2) initial packed unaligned dcl 51 ref 103 103 129 137 137 148 148 159 159 160 160 191 191 193 193 SPACE_OR_TAB defined char(2) packed unaligned dcl 49 ref 187 199 WHITESPACE 000000 constant char(7) initial packed unaligned dcl 54 ref 101 121 121 184 184 187 187 199 199 addr builtin function dcl 43 ref 191 arg_string parameter char packed unaligned dcl 28 ref 76 90 100 106 108 121 break_char_index 000100 automatic fixed bin(17,0) dcl 59 set ref 129* 130 137 138 143 145 147 148* 150 155 157 159 161* 161 command_line parameter char packed unaligned dcl 31 ref 172 178 183 ec parameter fixed bin(35,0) dcl 33 set ref 172 180* 195* 201* 209* 211* elements based structure level 1 dcl 71 elements_ptr parameter pointer dcl 32 ref 172 177 186 204 204 205 205 209 error_table_$bigarg 000012 external static fixed bin(35,0) dcl 38 ref 180 201 error_table_$noarg 000010 external static fixed bin(35,0) dcl 37 ref 209 error_table_$unbalanced_quotes 000014 external static fixed bin(35,0) dcl 39 ref 195 first based char(1) packed unaligned dcl 60 ref 191 i 000101 automatic fixed bin(17,0) dcl 61 set ref 184* 185 185 186* index builtin function dcl 43 ref 90 101 108 184 193 key parameter varying char dcl 27 ref 76 90 107 108 119 keyword_location 000102 automatic fixed bin(17,0) dcl 62 set ref 90* 91 99 100 106 107 108* 109 110* 110 119 len 000103 automatic fixed bin(17,0) dcl 63 set ref 178* 179 187* 188 189 189 193* 194 199* 200 205 206 length builtin function dcl 43 ref 106 107 119 145 157 178 line 000104 automatic char(128) packed unaligned dcl 64 set ref 183* 184 185* 185 187 189* 189 191 193 199 205 206* 206 ltrim builtin function dcl 43 ref 121 max_wanted based fixed bin(17,0) level 2 dcl 71 ref 186 n 1 based fixed bin(17,0) level 2 dcl 71 set ref 177* 204* 204 205 209 one_char 000144 automatic char(1) packed unaligned dcl 65 set ref 100* 101 103 rtrim builtin function dcl 43 ref 121 168 search builtin function dcl 43 ref 129 148 199 start 000145 automatic fixed bin(17,0) dcl 66 set ref 190* 192* 205 206 string_offset 000146 automatic fixed bin(17,0) dcl 67 set ref 107* 108 110 119* 121 substr builtin function dcl 43 ref 100 108 121 137 138 143 147 155 159 185 189 193 205 206 temp 000147 automatic varying char(256) dcl 68 set ref 121* 123 129 131 137 138 143 145 147* 147 148 155 157 159 166* 168 token 2 based varying char(64) array level 2 dcl 71 set ref 205* value 000250 automatic varying char(256) dcl 69 set ref 143* 155* 155 160* 160 166 verify builtin function dcl 43 ref 187 NAMES DECLARED BY EXPLICIT CONTEXT. args 000040 constant entry external dcl 76 command 000542 constant entry external dcl 172 copy_to_temp_string 000174 constant label dcl 119 ref 101 103 find_level_1 000353 constant label dcl 145 ref 162 iodd_parse_ 000017 constant entry external dcl 19 tally 001002 constant label dcl 209 ref 188 try_again 000106 constant label dcl 100 ref 111 THERE WERE NO NAMES DECLARED BY CONTEXT OR IMPLICATION. STORAGE REQUIREMENTS FOR THIS PROGRAM. Object Text Link Symbol Defs Static Start 0 0 1510 1526 1423 1520 Length 1702 1423 16 140 64 0 BLOCK NAME STACK SIZE TYPE WHY NONQUICK/WHO SHARES STACK FRAME iodd_parse_ 240 external procedure is an external procedure. STORAGE FOR AUTOMATIC VARIABLES. STACK FRAME LOC IDENTIFIER BLOCK NAME iodd_parse_ 000100 break_char_index iodd_parse_ 000101 i iodd_parse_ 000102 keyword_location iodd_parse_ 000103 len iodd_parse_ 000104 line iodd_parse_ 000144 one_char iodd_parse_ 000145 start iodd_parse_ 000146 string_offset iodd_parse_ 000147 temp iodd_parse_ 000250 value iodd_parse_ THE FOLLOWING EXTERNAL OPERATORS ARE USED BY THIS PROGRAM. return_mac signal_op ext_entry ext_entry_desc set_chars_eis index_chars_eis verify_eis search_eis NO EXTERNAL ENTRIES ARE CALLED BY THIS PROGRAM. THE FOLLOWING EXTERNAL VARIABLES ARE USED BY THIS PROGRAM. error_table_$bigarg error_table_$noarg error_table_$unbalanced_quotes LINE LOC LINE LOC LINE LOC LINE LOC LINE LOC LINE LOC LINE LOC 19 000016 22 000026 76 000034 90 000061 91 000072 92 000073 99 000104 100 000106 101 000115 103 000126 106 000133 107 000136 108 000141 109 000156 110 000157 111 000162 114 000163 119 000174 121 000200 123 000246 124 000253 129 000264 130 000277 131 000300 137 000315 138 000321 143 000343 145 000353 147 000370 148 000402 150 000410 151 000415 155 000427 157 000443 159 000460 160 000464 161 000473 162 000474 166 000475 168 000502 172 000536 177 000557 178 000563 179 000565 180 000567 181 000572 183 000601 184 000605 185 000616 186 000623 187 000633 188 000643 189 000644 190 000656 191 000660 192 000667 193 000671 194 000702 195 000703 196 000707 198 000716 199 000717 200 000725 201 000730 202 000734 204 000743 205 000747 206 000765 207 001000 209 001002 211 001013 212 001014 ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group BULL including BULL HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell BULL Inc., Groupe BULL and BULL HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, BULL or BULL HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by BULL HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved