Lines Matching +full:string +full:- +full:support
26 \ Loader.rc support functions:
28 \ initialize ( addr len -- ) as above, plus load_conf_files
29 \ load_conf ( addr len -- ) load conf file given
30 \ include_conf_files ( -- ) load all conf files in load_conf_files
31 \ print_syntax_error ( -- ) print line and marker of where a syntax
33 \ print_line ( -- ) print last line processed
34 \ load_kernel ( -- ) load kernel
35 \ load_modules ( -- ) load modules flagged
39 \ string counted string structure
40 \ cell .addr string address
41 \ cell .len string length
44 \ string module.name module's name
45 \ string module.loadname name to be used in loading the module
46 \ string module.type module's type
47 \ string module.args flags to be passed during load
48 \ string module.beforeload command to be executed before load
49 \ string module.afterload command to be executed after load
50 \ string module.loaderror command to be executed if load fails
55 \ string conf_files configuration files to be loaded
62 \ strdup ( addr len -- addr' len) similar to strdup(3)
63 \ strcat ( addr len addr' len' -- addr len+len' ) similar to strcat(3)
64 \ s' ( | string' -- addr len | ) similar to s"
65 \ rudimentary structure support
89 \ Crude structure support
105 \ String structure
107 structure: string
121 sizeof string member: module.name
122 sizeof string member: module.loadname
123 sizeof string member: module.type
124 sizeof string member: module.args
125 sizeof string member: module.beforeload
126 sizeof string member: module.afterload
127 sizeof string member: module.loaderror
163 string conf_files
164 string nextboot_conf_file
170 \ Support string functions
171 : strdup { addr len -- addr' len' }
176 : strcat { addr len addr' len' -- addr len+len' }
181 : strchr { addr len c -- addr' len' }
187 len 1 - to len
192 : strspn { addr len addr1 len1 | paddr plen -- addr' len' }
203 plen 1- to plen
206 len 1 - to len
211 : s' \ same as s", allows " in the string
220 : getenv? getenv -1 = if false else drop true then ;
224 : console-iterate { xt | caddr clen taddr tlen -- }
237 \ addr len are 0 0 - there was no comma nor space
238 \ addr len are x 0 - the first char is either comma or space
250 tlen swap - dup
261 tlen 1- to tlen
269 \ determine if a word appears in a string, case-insensitive
270 : contains? ( addr1 len1 addr2 len2 -- 0 | -1 )
277 while 1+ swap 1- repeat
278 swap 2 pick 1- over <
280 2over 2over drop over compare-insensitive 0= if
282 2 pick tuck - -rot + swap over c@ dup 32 =
289 while 1+ swap 1- repeat
295 : boot_serial? ( -- 0 | -1 )
296 s" console" getenv dup -1 <> if
299 \ s" boot_serial" getenv dup -1 <> if
303 \ s" boot_multicons" getenv dup -1 <> if
309 : framebuffer? ( -- t )
320 vocabulary support-functions
321 only forth also support-functions definitions
345 \ Support operators
350 \ Assorted support functions
352 : free-memory free if EFREE throw then ;
354 : strget { var -- addr len } var .addr @ var .len @ ;
357 : strset { addr len var -- } addr var .addr ! len var .len ! ;
360 : strfree { var -- } var .addr @ ?dup if free-memory 0 0 var strset then ;
362 \ free old content, make a copy of the string and assign to variable
363 : string= { addr len var -- } var strfree addr len strdup var strset ;
365 : strtype ( str -- ) strget type ;
368 : strref { addr len var -- addr len }
372 \ unquote a string
373 : unquote ( addr len -- addr len )
374 over c@ [char] " = if 2 chars - swap char+ swap then
379 string name_buffer
380 string value_buffer
391 vocabulary line-reading
392 also line-reading definitions
396 string read_buffer
401 get-current ( -- wid ) previous definitions
403 string line_buffer
407 >search ( wid -- ) definitions
421 : scan_buffer ( -- addr len )
427 read_buffer .addr @ read_buffer_ptr + ( -- addr )
428 r@ read_buffer_ptr - ( -- len )
434 read_buffer .addr @ read_buffer_ptr + ( -- addr )
435 r@ read_buffer_ptr - ( -- len )
439 : line_buffer_resize ( len -- len )
453 : append_to_line_buffer ( addr len -- )
462 scan_buffer ( -- addr len )
463 line_buffer_resize ( len -- len )
464 append_to_line_buffer ( addr len -- )
479 dup -1 = if EREAD throw then
484 get-current ( -- wid ) previous definitions >search ( wid -- )
502 only forth also support-functions definitions
518 vocabulary file-processing
519 also file-processing definitions
547 r@ [char] - =
580 : parse_name ( -- addr len )
587 line_pointer over -
591 : remove_backslashes { addr len | addr' len' -- addr' len' }
607 : parse_quote ( -- addr len )
622 line_pointer over -
627 parse_name ( -- addr len )
633 parse_quote ( -- addr len )
635 parse_name ( -- addr len )
686 get-current ( -- wid ) previous definitions >search ( wid -- )
703 only forth also support-functions also file-processing definitions
707 : assignment_type? ( addr len -- flag )
712 : suffix_type? ( addr len -- flag )
714 name_buffer .len @ over - name_buffer .addr @ +
744 name_buffer .len @ value_buffer .len @ + 5 chars + \ size of result string
746 dup 0 \ start with an empty string and append the pieces
755 free-memory
761 s" loader_conf_files" getenv conf_files string=
765 value_buffer strget unquote nextboot_conf_file string=
768 : append_to_module_options_list ( addr -- )
778 : set_module_name { addr -- } \ check leaks
779 name_buffer strget addr module.name string=
790 : find_module_option ( -- addr | 0 ) \ return ptr to entry matching name_buffer
802 : new_module_option ( -- addr )
809 : get_module_option ( -- addr )
815 name_buffer .len @ load_module_suffix nip - name_buffer .len !
820 name_buffer .len @ module_args_suffix nip - name_buffer .len !
822 get_module_option module.args string=
826 name_buffer .len @ module_loadname_suffix nip - name_buffer .len !
828 get_module_option module.loadname string=
832 name_buffer .len @ module_type_suffix nip - name_buffer .len !
834 get_module_option module.type string=
838 name_buffer .len @ module_beforeload_suffix nip - name_buffer .len !
840 get_module_option module.beforeload string=
844 name_buffer .len @ module_afterload_suffix nip - name_buffer .len !
846 get_module_option module.afterload string=
850 name_buffer .len @ module_loaderror_suffix nip - name_buffer .len !
852 get_module_option module.loaderror string=
885 \ free_buffer ( -- )
898 get-current ( -- wid ) previous definitions >search ( wid -- )
913 : peek_file ( addr len -- )
917 fd @ -1 = if EOPEN throw then
927 only forth also support-functions definitions
931 : load_conf ( addr len -- )
935 fd @ -1 = if EOPEN throw then
956 \ Debugging support functions
958 only forth definitions also support-functions
960 : test-file
966 : find-module ( <module> -- ptr | 0 )
980 : show-nonempty ( addr len mod -- )
987 : show-one-module { addr -- addr }
989 s" Path: " addr module.loadname show-nonempty
990 s" Type: " addr module.type show-nonempty
991 s" Flags: " addr module.args show-nonempty
992 s" Before load: " addr module.beforeload show-nonempty
993 s" After load: " addr module.afterload show-nonempty
994 s" Error: " addr module.loaderror show-nonempty
1000 : show-module-options
1005 show-one-module
1010 : free-one-module { addr -- addr }
1021 : free-module-options
1026 free-one-module
1028 swap free-memory
1034 only forth also support-functions definitions
1038 string current_file_name_ref \ used to print the file name
1044 \ loader_conf_files processing support functions
1046 : get_conf_files ( -- addr len ) \ put addr/len on stack, reset var
1050 : skip_leading_spaces { addr len pos -- addr len pos' }
1059 \ return the file name at pos, or free the string if nothing left
1060 : get_file_name { addr len pos -- addr len pos' addr' len' || 0 }
1072 addr len pos addr r@ + pos r> -
1075 : get_next_file ( addr len ptr -- addr len ptr' addr' len' | 0 )
1104 throw \ Unknown error -- pass ahead
1122 : get_nextboot_conf_file ( -- addr len )
1126 : rewrite_nextboot_file ( -- )
1129 fd @ -1 = if EOPEN throw then
1130 fd @ s' nextboot_enable="NO" ' fwrite ( fd buf len -- nwritten ) drop
1134 : include_nextboot_file ( -- )
1135 s" nextboot_enable" getenv dup -1 <> if
1157 : load_parameters { addr -- addr addrN lenN ... addr1 len1 N }
1167 s" -t "
1168 4 ( -t type name flags )
1174 : before_load ( addr -- addr )
1181 : after_load ( addr -- addr )
1188 : load_error ( addr -- addr )
1195 : pre_load_message ( addr -- addr )
1210 : process_module ( addr -- addr )
1227 : process_module_errors ( addr ior -- )
1254 throw \ Don't know what it is all about -- pass ahead
1260 : load_modules ( -- ) ( throws: abort & user-defined )
1281 : saveenv ( addr len | -1 -- addr' len | 0 -1 )
1282 dup -1 = if 0 swap exit then
1285 : freeenv ( addr len | 0 -1 )
1286 -1 = if drop else free abort" Freeing error" then
1288 : restoreenv ( addr len | 0 -1 -- )
1289 dup -1 = if ( it wasn't set )
1299 : clip_args \ Drop second string if only one argument is passed
1310 \ Parse filename from a semicolon-separated list
1313 : newparse-; { addr len | a1 -- a' len-x addr x }
1316 1 - a1 @ 1 + swap ( remove match )
1317 addr a1 addr -
1323 : parse-; ( addr len -- addr' len-x addr x )
1330 1- swap 1+ swap
1334 1- swap 1+ swap
1341 : try_multiple_kernels ( addr len addr' len' args -- flag )
1344 parse-; 2>r
1375 : load_a_kernel ( flags len 1 | x x 0 -- flag )
1379 end-locals
1382 s" bootfile" getenv dup -1 <> if
1389 s" kernel" getenv dup -1 <> if
1417 : load_from_directory ( path len 1 | flags len' path len 2 -- flag )
1422 0 0 2local oldmodulepath \ like a string
1423 0 0 2local newmodulepath \ like a string
1424 end-locals
1432 oldmodulepath nip dup -1 = if
1435 1+ + \ add oldpath -- XXX why the 1+ ?
1446 flags args 1- load_a_kernel
1448 oldmodulepath nip -1 <> if
1452 newmodulepath drop free-memory
1453 oldmodulepath drop free-memory
1465 flags args 1- load_a_kernel
1468 newmodulepath drop free-memory
1471 oldmodulepath nip -1 <> if
1475 newmodulepath drop free-memory
1476 oldmodulepath drop free-memory
1504 : load_directory_or_file ( path len 1 | flags len' path len 2 -- flag )
1509 end-locals
1519 : initialize ( addr len -- )
1523 : kernel_options ( -- addr len 1 | 0 )
1525 dup -1 = if drop 0 else 1 then
1528 : standard_kernel_search ( flags 1 | 0 -- flag )
1533 dup -1 = if 0 swap then
1535 end-locals
1537 path nip -1 = if ( there isn't a "kernel" environment variable )
1544 : load_kernel ( -- ) ( throws: abort )
1549 : load_xen ( -- flag )
1550 s" xen_kernel" getenv dup -1 <> if
1551 1 1 load ( c-addr/u flag N -- flag )
1554 0 ( -1 -- flag )
1558 : load_xen_throw ( -- ) ( throws: abort )
1563 : set_defaultoptions ( -- )
1564 s" kernel_options" getenv dup -1 = if
1571 \ pick the i-th argument, i starts at 0
1572 : argv[] ( aN uN ... a1 u1 N i -- aN uN ... a1 u1 N ai+1 ui+1 )
1582 : drop_args ( aN uN ... a1 u1 N -- )
1590 : queue_argv ( aN uN ... a1 u1 N a u -- a u aN uN ... a1 u1 N+1 )
1592 over 2* 1+ -roll
1594 over 2* 1+ -roll
1598 : unqueue_argv ( aN uN ... a1 u1 N -- aN uN ... a2 u2 N-1 a1 u1 )
1599 1- -rot
1603 : strlen(argv) ( aN uN .. a1 u1 N -- aN uN .. a1 u1 N len )
1619 : concat_argv ( aN uN ... a1 u1 N -- a u )
1630 2>r ( store string on the result stack )
1636 : set_tempoptions ( addrN lenN ... addr1 len1 N -- addr len 1 | 0 )
1639 0 argv[] drop c@ [char] - <> if
1662 : get_arguments ( -- addrN lenN ... addr1 len1 N )
1666 parse-word
1670 drop ( empty string )
1673 : load_kernel_and_modules ( args -- flag )
1676 s" temp_options" getenv dup -1 <> if