AsmLib Version .0.9-5.

Asmlib is a library of Linux functions for X86
processors.  All code was written in assembler.
In general, functions do not preserve registers
or check for errors.  The CLD flag is assumed
to be set.  Also, some functions assume other
functions are called first.  For example, the
functions crt_open, crt_type, mouse_enable are
setup functions usually called at beginning of
programs.

Copyrighted by the GNU public liscense.


INDEX
   1. blk/bit_set
   2. blk/bit_set_list
   3. blk/bit_test
   4. blk/blk_clear
   5. blk/blk_del_bytes
   6. blk/blk_find
   7. blk/blk_insert_bytes
   8. blk/blk_make_hole
   9. blk/blk_move
   10. blk/blk_replace
   11. blk/blk_replace_all
   12. blk/blk_replace_table
   13. blk/margins
   14. blk/paragraph
   15. crt/color_cursor
   16. crt/crt_char_at
   17. crt/crt_clear
   18. crt/crt_close
   19. crt/crt_color_at
   20. crt/crt_data
   21. crt/crt_horizontal
   22. crt/crt_line
   23. crt/crt_mouse_line
   24. crt/crt_open
   25. crt/crt_set_color
   26. crt/crt_str
   27. crt/crt_table
   28. crt/crt_table_loc
   29. crt/crt_type
   30. crt/crt_vbar
   31. crt/crt_vertical
   32. crt/crt_win_from_ptrs
   33. crt/crt_window
   34. crt/crt_window2
   35. crt/cursor_to_table
   36. crt/mov_color
   37. crt/move_cursor
   38. date/ascii2days
   39. date/ascii2regs
   40. date/day_name
   41. date/days2ascii
   42. date/days2dateregs
   43. date/days_in_month
   44. date/get_raw_time
   45. date/leap_check
   46. date/leap_count
   47. date/month_name
   48. date/raw2ascii
   49. date/raw2seconds
   50. date/regs2days
   51. date/seconds2bins
   52. date/seconds2dateregs
   53. date/seconds2timeregs
   54. env/env_exec
   55. env/env_home
   56. env/env_shell
   57. env/env_stack
   58. env/find_env_variable
   59. err/err_msg
   60. err/err_number
   61. err/install_signals
   62. err/log_close
   63. err/log_eol
   64. err/log_hex
   65. err/log_num
   66. err/log_regtxt
   67. err/log_str
   68. file/build_current_path
   69. file/build_file_open
   70. file/build_homepath
   71. file/build_write_open
   72. file/dir_change
   73. file/dir_create
   74. file/dir_delete
   75. file/dir_read
   76. file/dir_status
   77. file/file_close
   78. file/file_copy
   79. file/file_delete
   80. file/file_length_handle
   81. file/file_length_name
   82. file/file_list_copy
   83. file/file_open
   84. file/file_open_rd
   85. file/file_read
   86. file/file_read_all
   87. file/file_read_grow
   88. file/file_rename
   89. file/file_simple_read
   90. file/file_status_handle
   91. file/file_status_name
   92. file/file_write
   93. file/file_write_close
   94. file/filename_extract
   95. file/filepath_extract
   96. file/mmap_close
   97. file/mmap_open_ro
   98. file/mmap_open_rw
   99. key_mouse/is_alpha
   100. key_mouse/is_number
   101. key_mouse/key_decode1
   102. key_mouse/key_decode2
   103. key_mouse/key_flush
   104. key_mouse/key_mouse1
   105. key_mouse/key_mouse2
   106. key_mouse/key_poll
   107. key_mouse/key_string1
   108. key_mouse/key_string2
   109. key_mouse/mouse_enable
   110. key_mouse/mouse_line_decode
   111. log/log_fd
   112. log/log_signals
   113. process/check_process
   114. process/process_info_pid
   115. process/process_info_us
   116. process/process_search
   117. process/process_walk
   118. random/random_dword
   119. random/random_seed
   120. random/scale_word
   121. sort/sort_bubble
   122. sort/sort_selection
   123. str/str_insert
   124. str/str_join
   125. str/str_len
   126. str/str_move
   127. str/str_move
   128. str/str_replace
   129. str/str_replace_all
   130. str/str_search
   131. str/strlen1
   132. str/strlen2
   133. str_cmp/str_compare
   134. str_conv/ascii_to_dword
   135. str_conv/byte2hexascii
   136. str_conv/byte_to_hexascii
   137. str_conv/dword2hexascii
   138. str_conv/dword_to_ascii
   139. str_conv/dword_to_hexascii
   140. str_conv/dword_to_l_ascii
   141. str_conv/dword_to_lpadded_ascii
   142. str_conv/dword_to_r_ascii
   143. str_conv/hexascii2byte
   144. str_conv/hexascii2dword
   145. str_conv/hexascii2nibble
   146. str_conv/hexascii2word
   147. str_conv/hexascii_to_byte
   148. str_conv/hexascii_to_dword
   149. str_conv/hexascii_to_nibble
   150. str_conv/nibble2hexascii
   151. str_conv/word2hexascii
   152. str_parse/read_setup
   153. sys/sys_ex
   154. sys/sys_ex_home
   155. sys/sys_ex_path
   156. sys/sys_launch
   157. sys/sys_launch_engine
   158. sys/sys_launch_path
   159. sys/sys_pipe_capture
   160. sys/sys_pipe_feed
   161. sys/sys_shell
   162. sys/sys_shell_alt
   163. sys/sys_shell_cmd
   164. sys/sys_win_alt
   165. sys/sys_win_normal
   166. sys/sys_wrap
   167. sys/wait_event
   168. sys/write_setup
   169. widget/edit_file_in_box
   170. widget/edit_text_in_box
   171. widget/form
   172. widget/make_box
   173. widget/message_box
   174. widget/show_box

------------------------------------------
1. blk/bit_set
------------------------------------------
bit_set - set bit in array
 INPUTS
   eax = bit number, zero based
   - eax(0) sets bit 1 (00000001h)
   - eax(32) sets first bit of second dword in array
   edi = array pointer
 OUTPUT
   bit set in array
   eax,edx modified
 NOTES
   file bit_set.asm
   note: see bit_test, blk_clear, wait_event

------------------------------------------
2. blk/bit_set_list
------------------------------------------
bit_set_list - set bits in array
 INPUTS
   esi = pointer to list of dword bit values
   - 0 = bit 1 or 00000001h
   - -1 = end of list
   - values in increasing order
   edi = array pointer
 OUTPUT
   bits set in array
   esi moved to end of list, beyond -1 entry
 NOTES
   file bit_set_list.asm
   note: see bit_test, blk_clear, wait_event

------------------------------------------
3. blk/bit_test
------------------------------------------
bit_test - test array of bits
 INPUTS
   eax = bit location (0=bit 1) or 00000001h
   edi = array pointer
 OUTPUT
   carry = bit set
   no-carry = bit cleared
   registers unchanged
 NOTES
   file bit_test.asm
   note: see bit_set_list, blk_clear, wait_event

------------------------------------------
4. blk/blk_clear
------------------------------------------
blk_clear - clear array of bytes
 INPUTS
   ecx = size of array (byte count)
   edi = array pointer
   the CLD flag is set
 OUTPUT
   ecx = 0
   edi = unchanged
 NOTES
   file blk_clear.asm
   note: see bit_set_list, bit_test, wait_event

------------------------------------------
5. blk/blk_del_bytes
------------------------------------------
blk_del_bytes - delete area from block of data
 INPUTS
   eax = number of bytes to delete
   edi = ptr to top of delete area
   ebp = end of file
 OUTPUT
   ebp = adusted file end ptr
 NOTES
   all registers destroyed
   file blk_pkg.asm

------------------------------------------
6. blk/blk_find
------------------------------------------
blk_find - search block of text for string
 INPUTS
   ebp end of file ptr(fwd search) start of file(backwards search)
   esi match string
   edi search start ptr in buffer
   edx scan_direction +1 for forward -1 for reverse find
   ch case mask df=ignore case, ff=match case
 OUTPUT
   ebx match pointer if no carry (jnc match_found)
   clobbered ecx,eax,esi
 NOTES
   The match string ends with zero and the buffer/block
   end is put in register ebp if needed (forward search)

------------------------------------------
7. blk/blk_insert_bytes
------------------------------------------
blk_insert_bytes - insert data into block
 INPUTS
   edi = insert point
   ebp = block end ptr
   eax = lenght of insert string
   esi = string to insert
 OUTPUT
   ebp = adjusted block end ptr
 NOTES
   all registers are destroyed
   file blk_pkg.asm

------------------------------------------
8. blk/blk_make_hole
------------------------------------------
blk_make_hole - make hole in data block for insert
 INPUTS
   edi = insert point
   ebp = file end
   eax = number of characters to insert
 OUTPUT
   ebp = adjust file end ptr
 NOTES
   all registers destroyed
   file blk_pkg.asm

------------------------------------------
9. blk/blk_move
------------------------------------------
blk_move - move block of data
 INPUTS
   eax = move length
   esi = from
   edi = to
 OUTPUT
   edi - unchanged
 NOTES
   file blk_pkg.asm
   see also, str_move

------------------------------------------
10. blk/blk_replace
------------------------------------------
blk_replace - replace first match in buffer
 INPUTS
   eax = ptr to replacement string
   ch = search case mask, dfh=ignore 0ffh=use case
   esi = match string ptr
   edi = buffer search startng point
   ebp = eof (end of data in buffer)
 OUTPUT
   carry flag set if no replacement occured
   ebp = adusted file end ptr if any replaces occured
   edi = ptr to end of inserted string
 NOTES
   all registers are destroyed
   file blk_replace.asm

------------------------------------------
11. blk/blk_replace_all
------------------------------------------
blk_replace_all - replace all matches in buffer
 INPUTS
   eax = ptr to replacement string
   ch = search case mask, dfh=ignore 0ffh=use case
   esi = match string ptr
   edi = buffer search startng point
   ebp = eof (end of data in buffer)
 OUTPUT
   ebp = adusted file end ptr if any replaces occured
   edi = ptr to end of inserted string
 NOTES
   all registers destroyed
   file blk_replace.asm

------------------------------------------
12. blk/blk_replace_table
------------------------------------------
blk_replace_table - replace strings using table
 INPUTS
   ebx = replace table with pairs of asciiz strings.
   example:
   - db "find str1",0, "replacement text1",0
   - db "find str2",0, "replacement text2",0
   _ db "find_str3",0, 0
   _ db 0 ;;end of table
   edi = buffer with text
   ebp = file end ptr
   ch = case flag for find str, 0df=ignore case 0ffh=use case
 OUTPUT
   buffer modified
   ebp = adjusted buffer end ptr
 NOTES
   file: blk_replace_table.asm

------------------------------------------
13. blk/margins
------------------------------------------
margins - sets margins for paragraph function
 INPUTS
   ah = left margin, 1=left most column
   al = right margin, (right most column)
 OUTPUT
   none
 NOTES
   file: paragraph.asm

------------------------------------------
14. blk/paragraph
------------------------------------------
paragraph - formats one paragraph
 INPUTS
   esi = pointer inside paragraph somewhere
   edi = start of buffer with all paragraphs
   ebp = end of text data, (all paragraphs)
 OUTPUT
   ebp = new end of text data
   edi = end of reformated paragraph
 NOTES
   file paragraph.asm
   The paragraph function first finds the start and end of
   current text block. Next, it creates a hole at top to
   place reformated data. It is critical that text data
   area can expand without overflowing work area.
   -
   The start of all text must have a 0ah character infront
   of the buffer. the end of all text is expected to also
   have a 0ah terminator.

------------------------------------------
15. crt/color_cursor
------------------------------------------
color_cursor - place a colored cursor on the screen
 INPUTS
   eax = cursor color
   bh = row
   bl = column
   ecx = ptr to data under cursor (display char)
 OUTPUT
   solid character displayed
 NOTES
   file crt_screen.asm
   data under cursor is expected to be normal ascii

------------------------------------------
16. crt/crt_char_at
------------------------------------------
crt_char_at - display one colored char at location.
 INPUTS
   eax = color (aa??ffbb) attribute,foreground,background
   bl = column
   bh = row
   cl = ascii char
 OUTPUT
   one colored character displayed
 NOTES
   file crt_char

------------------------------------------
17. crt/crt_clear
------------------------------------------
crt_clear - clear the screen
 INPUTS
   eax = screen color
 OUTPUT
   screen is cleared
 NOTES
   file crt_vertical.asm
   see function crt_set_color for color info

------------------------------------------
18. crt/crt_close
------------------------------------------
crt_close
 INPUTS
   none
 OUTPUT
   none
 NOTES
   file: crt_setup.asm
   Call this function if crt_open was called previously. Normally
   this function is called before exiting the program.

------------------------------------------
19. crt/crt_color_at
------------------------------------------
crt_color_at - move cursor and display colored string
 INPUTS
   eax = color (aa??ffbb) attribute,foreground,background
   bl = column
   bh = row
   ecx = message ptr (asciiz)
 OUTPUT
   colored message string displayed
 NOTES
   file crt_color.asm

------------------------------------------
20. crt/crt_data
------------------------------------------
crt_data - common data used by crt functions
 INPUTS
   crt_open sets crt_rows & crt_columns
 OUTPUT
 NOTES
   file crt_data.asm
   -
   crt_rows (byte) set by crt_open
   crt_columns (byte) set by crt_open
   -
   - scratch variables -------------------
   crt_left_column - used by many
   data_end_ptr - used by many
   win_columns - used by many
   lib_buf - 200 byte buffer
   -
   - default color definitions -----------
   - norm_text_color dd 30003734h ;used for inactive window
   -;grey-foreground=7 blue-backgound=4 0=norm attr
   -
   - bold_edit_color dd 31003734h ; active window in edit mode
   - ;grey-foreground=7 blue-backgound=4 0=bold attr
   -
   - bold_cmd_color dd 31003334h ; active window in command mode
   - ;grey-foreground=7 blue-backgound=4 0=bold attr
   -
   - high_text_color dd 31003634h ;used for highlighting block
   - ;grey-foreground=7 blue-backgound=4 0=inver attr
   -
   - asm_text_color dd 31003234h ;used to highlight comments ";"
   - ;cyan-foreground=6 blue-backgound=4 0=norm attr
   -
   - status_color dd 30003036h ;used for status line
   - status_color1 dd 31003336h ; special data on status line
   - status_color2 dd 31003331h ; error messags or macro record
   - exit_screen_color dd 31003334h ; error messags on status line

------------------------------------------
21. crt/crt_horizontal
------------------------------------------
crt_horizontal - repeat display character
 INPUTS
   bl = character to repeat at cursor position
   eax = color, see (mov_color) for format of color
   ecx = number of times to display character
   lib_buf is used to build display line
 OUTPUT
   eax = negative system error# or positive if success
 NOTES
   source file crt_horizontal.asm
   The current window width is not checked, crt_horizontal
   will attempth display even if window size too small.

------------------------------------------
22. crt/crt_line
------------------------------------------
crt_line  - display line with embedded color codes * and fit line into
window area
 INPUTS
   ebx = ptr to color list, each color def is dword
   ch = starting row 1+
   cl = starting column 1+
   dl = max line length, must be 1+
   esi = ptr to data for line, each line end with 0ah, or 0
   - color codes start at 1 (first color in table)
   - color codes 1-9 are possible.
 OUTPUT
   line is built in buffer lib_buf then displayed
   esi - points at char beyond 0ah
 NOTES
   source file:

------------------------------------------
23. crt/crt_mouse_line
------------------------------------------
crt_mouse_line - display line in mouse_decode format
 INPUTS
   esi = menu line to display (see notes)
   ah = display row 1+
   (menu line always starts at column 1)
   ecx = color for spaces between buttons
   edx = color for buttons
   -
   hex color def: aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brown 34-blue 35-purple 36-cyan 37-grey
   attributes 30-normal 31-bold 34-underscore 37-inverse
 OUTPUT
   menu line displayed
 NOTES
   file: crt_mouse_line.asm (see also mouse_line_decode.asm)
   The menu line has buttons separated by a number from 0-8.
   the number represents a count of spaces between buttons.
   -example:
   -line: db "button1",2,"button2",3,"button3",0
   -(zero indicates end of line, 2=2 spaces)
   Colors are in standard format (see crt_color.asm)

------------------------------------------
24. crt/crt_open
------------------------------------------
crt_open
 INPUTS
   none
 OUTPUT
   [crt_rows] - global variable (byte) with row count
   [crt_columns] - global variable (byte) with collumn count
 NOTES
   file: crt_setup.asm
   Call crt_open if interactive terminal programs are utilized.
   This function provides information about window size and
   and disables default keyboard handling. It allows individual
   keys to be processed without waiting for user to type a <return>.

------------------------------------------
25. crt/crt_set_color
------------------------------------------
crt_set_color - set color mode for display
 INPUTS
   eax = color code
   eax = aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brwn 34-blu 35-purple 36-cyan 37-gry
   attributes 30-normal 31-bold 34-underscore 37-inverse
 OUTPUT
   vt100 color string sent to display
 NOTES
   file crt_color.asm
   This function sends vt100 color command to crt

------------------------------------------
26. crt/crt_str
------------------------------------------
crt_str - display asciiz string at curent cursor position
 INPUTS
   ecx = ptr to string
 OUTPUT
   uses current color, see crt_set_color, crt_clear
 NOTES
   file crt_str.asm

------------------------------------------
27. crt/crt_table
------------------------------------------
crt_table
 INPUTS
   esi = ptr to table data
   [win_rows] - global variable set by crt_open
   [left_column] - global dword for scroll right-left, set by caller
   [lib_buf] - temp buffer used internaly
   colors described below are contained in file crt_data.asm and
   can be modified.
 OUTPUT
 NOTES
   file crt_table.asm
   crt_open must be called before using this function.
   Tables contain a mix of color information, line information, and
   negative codes indicating the process for ajacent data. If a
   mouse click occurs on the screen, the table can be scaned for
   a negative number that signals the process to run.
   The caller can change colors as user clicks on various areas.
   The a_todo program edit mode uses this function.
   -
   codes: 0 - end of table
   1 - normal color
   2 - edit/select field color
   3 - active edit/select field color
   4 - button color color
   5 - blank all rows from here to [window_rows]
   9 - add blanks to end of line, init for next line
   -x - process code for mouse clicks
   -
   sample table --------------------
   -
   db -67 ;trap to catch clicks at upper left corner of screen
   edit_table:
   db 1,' ',-73,4,'Previous(PgUp)',1,' '
   db -74,4,'Next(PgDn)',1,' ',-65,4,'Delete(F8)',1,' '
   db -67,4,'Abort edits(F9)',1,' ',-66,4,'Done(F10)',1,9
   db 1,9
   db 1,'todo state: ',-1,2
   pending
   db 'Pending',1,' ',-2,2
   completed
   db 'completed',1,' ',-3,2
   deleted
   db 'deleted',1,9
   db 1,9
   db 1,9
   db 5
   db 0
   edit_table_end

------------------------------------------
28. crt/crt_table_loc
------------------------------------------
crt_table_loc - use table ptr to find crt row/col
 INPUTS
   esi = ptr to top of table
   edi = ptr any location inside table
 OUTPUT
   ah = row
   al = column
 NOTES
   file crt_table.asm

------------------------------------------
29. crt/crt_type
------------------------------------------
crt_type - check if vt100 mode enabled
 INPUTS
   none
 OUTPUT
   cl = zero if no response
   cl = 30h if vt100, 31h if vt220
   [terminal_type] (byte) set to -cl- value
 NOTES
   source file: crt_type.asm

------------------------------------------
30. crt/crt_vbar
------------------------------------------
crt_vbar - display vertical bar lenght of window
 INPUTS
   [crt_columns] - set by crt_open
   [crt_rows] - set by crt_open
 OUTPUT
   vertical bar displayed on screen,
 NOTES
   file crt_vertical.asm
   call crt_set_color to set bar color

------------------------------------------
31. crt/crt_vertical
------------------------------------------
crt_vertical - repeat char vertically
 INPUTS
   al = column (ascii)
   ah = row (ascii)
   bl = char
   bh = repeat count
 OUTPUT
   display character in vertical column
 NOTES
   file crt_vertical.asm

------------------------------------------
32. crt/crt_win_from_ptrs
------------------------------------------
crt_win_from_ptrs - display window using ptrs to lines
 INPUTS
   ebx = ptr to color table
   ch = starting row
   cl = starting col
   dl = number of cols
   dh = number of rows
   ebp = ptr to list of line ptrs
   edi = adjustment to pointers in pointer list (ebp).
   - negative number ok, display starts at [ptr + edi]
   each line terminated with 0ah or 0
   codes 1-9 found in line are color info.
 OUTPUT
 NOTES
   source file: crt_ptr_window.asm

------------------------------------------
33. crt/crt_window
------------------------------------------
crt_window - display one window/page of data
 INPUTS
   esi = ptr to information block as follows
   - dword - color for page
   - dword - display data ptr
   - dword - end of all display data, (not end of this page)
   - - points at 0ah char beyond last data item.
   - dword - scroll count, 0=left edge not scrolled
   - byte - total window columns 1+
   - byte - total window rows 1+
   - byte - starting row 1+
   - byte - starting column 1+
 OUTPUT
   none
 NOTES
   file crt_window.asm
   buffer lib_buf is used to build each line displayed.
   This buffer is a temp buffer available for general use.
   lib_buf is 600 bytes long.

------------------------------------------
34. crt/crt_window2
------------------------------------------
crt_window2  - display window with embedded color * codes, window size
is input.
 INPUTS
   ebx = ptr to color list, each color def is dword
   ch = starting row 1+
   cl = starting column 1+
   dl = max line length, must be 1+
   dh = row count 1+
   esi = ptr to data for line
   - color codes start at 0 (first color in table)
   - color codes 0-9 are possible.
   - number of lines must equal or greater than size
   - of window.
*
 OUTPUT
   window displayed
 NOTES
   source file: crt_window2.asm

------------------------------------------
35. crt/cursor_to_table
------------------------------------------
cursor_to_table - find table location from cursor row/col
 INPUTS
   esi = ptr to top of table
   cl = target column
   ch = target row
 OUTPUT
   esi = table pointer for target row/column
 NOTES
   file crt_table.asm

------------------------------------------
36. crt/mov_color
------------------------------------------
mov_color - copy vt100 string to buffer
 INPUTS
   eax = color code
   eax = aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brn 34-blu 35-purple 36-cyan 37-gry
   attributes 30-normal 31-bold 34-underscore 37-inverse
   edi = location to copy color string
 OUTPUT
   string is copied, edi points to zero at end of string
   register esi is preserved
 NOTES
   file crt_color.asm
   This function copies and asciiz string (including the zero)

------------------------------------------
37. crt/move_cursor
------------------------------------------
move_cursor - move cursor
 INPUTS
   al = column (1-xx)
   ah = row (1-xx)
 OUTPUT
   cursor placed on screen
 NOTES
   file crt_move.asm
   This function moves the cursor by sending vt100
   escape commands to crt.

------------------------------------------
38. date/ascii2days
------------------------------------------
ascii2days - convert ascii year,month,day to days since 1970
 INPUTS
   esi = ptr to ascii string "YYYYMMDD"
 OUTPUT
   eax = binary days since 1970
 NOTES
   source file: ascii2days.asm

------------------------------------------
39. date/ascii2regs
------------------------------------------
ascii2regs - convert ascii year,month,day to bin year,month,day
 INPUTS
   esi = ptr to ascii string "yyymmdd" without separators
 OUTPUT
   edx = binary year
   ah = binary month 1-12
   al = binary day of month 1-31
 NOTES
   source file: ascii2regs.asm

------------------------------------------
40. date/day_name
------------------------------------------
day_name - lookup name for day
 INPUTS
   ecx = day code, 0=sun 1=mons etc.
 OUTPUT
   esi = pointer to full asciiz name.
*
 NOTES
   source file: day_name.asm
   -

------------------------------------------
41. date/days2ascii
------------------------------------------
days2ascii - convert days to week,day,month, etc.
 INPUTS
   eax = days since jan 1 1970
   ebx = buffer for ascii output
   ebp  = format template for ascii output the format string contains
   two  types  of  data.  Numeric codes "0123456789" and non-numberic
   ascii characters. Non-numberic characters are passed to the output
   and  not  modified.  Any  numberic character found is processed as
   follows:  0  -stuff ascii year 1 -stuff ascii month 2 -stuff ascii
   day  of month 6- -stuff short month name 6+ -stuff long month name
   7- -stuff short day of week name 7+ -stuff long day of week name
 OUTPUT
edi  -  points  at  end of output string ebp - points at end of format
string Note: the termporary library buffer "lib_buf" is utilized. *
 NOTES
   source file: days2ascii.asm
   -

------------------------------------------
42. date/days2dateregs
------------------------------------------
days2dateregs - convert days to week,day,month, etc.
 INPUTS
   eax = days since jan 1 1970
 OUTPUT
   eax days_since_1970 - total days since 1970
   dh [day_of_week] - 0=wednesday 1=thursday...-> 0=sunday
   ebx year - current year
   dl day_of_month - 1 based
   esi month_number - 1 based
*
 NOTES
   source file: days2dateregs.asm
   -

------------------------------------------
43. date/days_in_month
------------------------------------------
days_in_month - returns number of days in month
 INPUTS
   bl = binary month number, 1=january
   edx = binary year
 OUTPUT
   bl = number of days in month
 NOTES
   source file: days_in_month.asm

------------------------------------------
44. date/get_raw_time
------------------------------------------
get_raw_time - get raw time from kernel
 INPUTS
   none
 OUTPUT
   eax - raw seconds since Jan 1 1970
   ebx - raw microseconds
 NOTES
   source file: get_raw_time.asm
   -
   see date_get function before using this function.

------------------------------------------
45. date/leap_check
------------------------------------------
leap_check - check for leap year
 INPUTS
   eax = binary year
 OUTPUT
   carry set if leap year
   eax - modified
 NOTES
   source file: leap_check.asm

------------------------------------------
46. date/leap_count
------------------------------------------
leap_count - count leap years from 1970 till target
 INPUTS
   eax = binary year (target)
 OUTPUT
   eax = leap years between 1970 and target, excluding target
 NOTES
   source file: leap_count.asm
   note: the input year is not included in totals
   - it is assumed date is jan 1 and leap has
   - not occured yet.

------------------------------------------
47. date/month_name
------------------------------------------
month_name - lookup name for month
 INPUTS
   ecx = month code, 1=january 2= feb etc.
 OUTPUT
   esi = pointer to full asciiz name.
*
 NOTES
   source file: month_name.asm
   -

------------------------------------------
48. date/raw2ascii
------------------------------------------
raw2ascii - apply zone adjustment to raw system time
 INPUTS
   eax = raw system time from get_raw_time or file status
   edi = destination for ascii
   ebx = format string for ascii output, terminated by zero byte. the
   format   string   contains   two  types  of  data.  Numeric  codes
   "0123456789"   and  non-numberic  ascii  characters.  Non-numberic
   characters are passed to the output and not modified. Any numberic
   character  found  is  processed  as follows: 0 -stuff ascii year 1
   -stuff ascii month 2 -stuff ascii day of month 3 -stuff ascii hour
   4  -stuff ascii minute 5 -stuff ascii second 6- -stuff short month
   name 6+ -stuff long month name 7- -stuff short day of week name 7+
   -stuff long day of week name 8 -stuff AM/PM 9 -stuff 3 letter zone
   code   example:   db   "0-1-2   3:4:5",0  displays  year-month-day
   hour:minute:sec
 OUTPUT
   ebx - points to time struc (in temporary lib buffer lib_buf)
   - struc time
   - .ct: resd 1 ; raw C time (seconds since the Epoch)
   - .at: resd 1 ; zone adjusted seconds since last Epoch
   - .zo: resd 1 ; time zone offset
   - .zi: resb 6 ; time zone identifier
   - .tz: resb 10 ; time zone name
   - .dc: resd 1 ; days since last Epoch
   - .sc: resd 1 ; seconds
   - .mn: resd 1 ; minutes
   - .hr: resd 1 ; hours
   - .yr: resd 1 ; year
   - .mr: resd 1 ; meridian (0 for AM)
   - .wd: resd 1 ; day of the week (Sunday=0, Saturday=6)
   - .dy: resd 1 ; day of the month
   - .mo: resd 1 ; month (one-based)
   edi - points to end of stored ascii string
   ebp - points to end of format string
   all other registers are not preserved
   the temp library buffer lib_buf has time structure
 NOTES
   source file: raw2ascii.asm
   UNIX system time and file times need to be adjusted by local zone.

------------------------------------------
49. date/raw2seconds
------------------------------------------
raw2seconds - apply zone adjustment to raw system time
 INPUTS
   eax = raw system time from get_raw_time
   edi = pointer to short form of time structure
   - struc time
   - .ct: resd 1 ; raw C time (seconds since the Epoch)
   - .at: resd 1 ; zone adjusted seconds since last Epoch
   - .zo: resd 1 ; time zone offset
   - .zi: resb 6 ; time zone identifier
   - .tz: resb 10 ; time zone name
 OUTPUT
   eax - seconds since Jan 1 1970 adjusted for zone
   also, fields .ct through .tz are filled out if zone data found.
   if zone not found, only .ct .at .zo and .zi are filled in
 NOTES
   source file: raw2seconds
   UNIX system time and file times need to be adjusted by local zone.

------------------------------------------
50. date/regs2days
------------------------------------------
regs2days - convert day,month,year to days since 1970
 INPUTS
   edx = binary year 1970-2099
   ah = binary month 1-12
   al = binary day 1-31
 OUTPUT
   eax = days elapsed since Jan 1 1970
 NOTES
   source file: regs2days.asm

------------------------------------------
51. date/seconds2bins
------------------------------------------
   seconds2bins - convert seconds to year,month,day,hr, etc.
 INPUTS
   ebp = ptr to time structure, see time.inc
   [ebp + time.at] = adjusted seconds
*
 OUTPUT
   the time structure is filled in as follows:
   [ebp + time.sc current seconds
   [ebp + time.mn current minute
   [ebp + time.hr current hour
   [ebp + time.mr meridian 0=AM
   [ebp + time.dc days since last epoch
   [ebp + time.yr current year
   [ebp + time.dy day of month
   [ebp + time.mo month number, one based
 NOTES
   source file: seconds2bins.asm

------------------------------------------
52. date/seconds2dateregs
------------------------------------------
seconds2dateregs - convert seconds to week,day,month, etc.
 INPUTS
   eax = seconds since jan 1 1970
 OUTPUT
   eax days_since_1970 - total days since 1970
   dh [day_of_week] - 0=wednesday 1=thursday...-> 0=sunday
   ebx year - current year
   dl day_of_month - 1 based
   esi month_number - 1 based
   register ecx is restored
 NOTES
   source file: seconds2dateregs.asm
   -
   see also date_get

------------------------------------------
53. date/seconds2timeregs
------------------------------------------
seconds2timeregs -
 INPUTS
   eax = seconds since Jan 1 1970
 OUTPUT
   eax = seconds since Jan 1 1970
   edi - dword binary hour
   cl - dword binary minute
   ch - dword binary seconds
 NOTES
   source file: seconds2timeregs.asm
   -

------------------------------------------
54. env/env_exec
------------------------------------------
env_exec - search executable path for program
 INPUTS
   ebx = pointer to envionmet pointer list
   ebp = pointer to program name to search for
 OUTPUT
   if no-carry ebx = ptr to full path of executable
   if carry, file was not found.
 NOTES
   file env_exec.asm (see also build_current_path)
   temp buffer "lib_buf" is used to pass executable path
   back to caller.

------------------------------------------
55. env/env_home
------------------------------------------
env_home - search the enviornment for $HOME
 INPUTS
   ebx = ptr to list of env pointers
   edi = buffer to store $HOME contents
 OUTPUT
   edi = ptr to zero at end of $HOME string
 NOTES
   file: env_home.asm (see also build_homepath)

------------------------------------------
56. env/env_shell
------------------------------------------
   env_shell - search enviornment for SHELL=
 INPUTS
   edx = ptr to buffer (shell path storage)
 OUTPUT
   [edx] - contains SHELL= string or /bin/sh if
   - not found
   edi - points to end of stored string
 NOTES
   source file: env_shell.asm

------------------------------------------
57. env/env_stack
------------------------------------------
env_stack - find stack ptrs to enviornment
 INPUTS
   esp = stack ptr before any pops or pushes
 OUTPUT
   ebp = ptr to enviroment pointers
   [enviro_ptrs] set also
 NOTES
   source file: env_stack.asm

------------------------------------------
58. env/find_env_variable
------------------------------------------
find_env_variable - search enviornment for variable name
 INPUTS
   [enviro_ptrs] - setup by env_stack
   ecx = ptr to variable name (asciiz)
   edx = storage point for variable contents
 OUTPUT
   data stored at edx, if edi is preloaded with
   a zero it can be checked to see if variable found
   edi - if success, edi points to end of varaible stored
 NOTES
   source file: find_env_variable.asm

------------------------------------------
59. err/err_msg
------------------------------------------
err_msg - display error messages
 INPUTS
   eax = error number (binary + or -)
 OUTPUT
   dipplay is cleared and message displayed
 NOTES
   file: /err/err_msg.asm
   operation: clears screen, displays message, waits for key

------------------------------------------
60. err/err_number
------------------------------------------
err_number - display error number
 INPUTS
   eax = error number (either + or -)
 OUTPUT
   none
 NOTES
   clear screen, displays error number, waits for any key

------------------------------------------
61. err/install_signals
------------------------------------------
install_signals - install signals
 INPUTS
   ebp = pointer to table describing each signal to install.
   The table is terminated with a zero byte in the signal number
   field.
   - Sanple table entry for to install the SIGILL signal.
   db 4 ;signal illegal action SIGILL
   dd handleIll ;handler for signal
   dd 0
   dd 4 ;set siginfo telling kernel to pass status data to handler
   dd 0 ;always zero
*
 OUTPUT
 NOTES
   See file /err/install_signals for more documentation.

------------------------------------------
62. err/log_close
------------------------------------------
log_close - close log file in local driectory
 INPUTS
   none
 OUTPUT
   none (all registers unchanged)
 NOTES
   source file: log.asm
   This function is optional for most applications. Normally,
   all files are closed when a program terminates.

------------------------------------------
63. err/log_eol
------------------------------------------
log_eol - write eol (end of line) to "log"
 INPUTS
   none
 OUTPUT
   none (all registers unchaged)
   file "log" will have eol (0ah) appended to end
 NOTES
   source file: log.asm

------------------------------------------
64. err/log_hex
------------------------------------------
log_hex - write hex to file called "log"
 INPUTS
   eax = binary number for log file
   - (converted to hex ascii then written)
 OUTPUT
   none (all registers unchanged)
   file "log" will have <space>number<space> appended.
 NOTES
   source file: log.asm

------------------------------------------
65. err/log_num
------------------------------------------
log_num - write number to file called "log"
 INPUTS
   eax = binary number for log file
   - (convert to decimal ascii then written)
 OUTPUT
   none (all registers unchanged)
   file "log" will have <space>number<space> appended.
 NOTES
   source file: log.asm

------------------------------------------
66. err/log_regtxt
------------------------------------------
log_regtxt - write string in -eax- to file called "log"
 INPUTS
   eax = 4 character ascii string
 OUTPUT
   none (all registers unchanged)
   file "log" will have string appended to end
 NOTES
   source file: log.asm

------------------------------------------
67. err/log_str
------------------------------------------
log_str - write string to file called "log"
 INPUTS
   esi = string ptr for log file
 OUTPUT
   none (all registers unchaged)
   file "log" will have string appended to end
 NOTES
   source file: log.asm

------------------------------------------
68. file/build_current_path
------------------------------------------
   build_current_path - build path using current dir
 INPUTS
   ebx = ptr to buffer
   ebp = append string for path, or zero if no append
 OUTPUT
   eax = negative if error
   eax = positive, then buffer has path.
 NOTES
   file: file_path.asm

------------------------------------------
69. file/build_file_open
------------------------------------------
build_file_open - build path and open file
 INPUTS
   ebp = ptr to file name
   ebx = ptr to enviornment pointers if bit 2 of al set
   al = flags
   - bit 1 (0000 0001) = full path or local file
   - bit 2 (0000 0010) = full path or file at $HOME/[base]
   - (this register optional if full path is provided)
   - (it is ok to set both bits, local path checked first)
 OUTPUT
   eax contains a negative error code or file handle
   - flags set for js/jns jmp
   edx = file permissions if eax positive
 NOTES
   file: file_read.asm

------------------------------------------
70. file/build_homepath
------------------------------------------
build_homepath - build path using $HOME
 INPUTS
   ebx = ptr to enviornment pointers
   edi = buffer
   ebp  =  append  string  (filename  or  dir/filename) if ebp = 0 no
   append string is processed
 OUTPUT
   buffer (passed in edi) has path if eax positive
 NOTES
   file: file_path.asm

------------------------------------------
71. file/build_write_open
------------------------------------------
build_write_open - build path and open write file
 INPUTS
   ebx = file name ptr
   ebp = ptr to enviornment pointer if flag bit 0010 set
   edx = file attributes if flag bit 1000 set
   esi = flags 0000 0001 write to local dir or full path if given
   - 0000 0010 write to $HOME or full path if given
   - 0000 0100 check for existing file and preserve attr
   - 0000 1000 file attr are in edx, ignore 0100 flag
   - 0001 0000 append to existing file if found
   Note: file name in ebx can be partial directory (dir/file.inc)
 OUTPUT
   eax = negative error number or positive identifier (handle)
 NOTES
   file: file_write.asm

------------------------------------------
72. file/dir_change
------------------------------------------
dir_change - change current working directory
 INPUTS
   ebx = path of new dir
 OUTPUT
   eax = negative if error
 NOTES
   file: file_dir.asm
   kernel: chdir (12)

------------------------------------------
73. file/dir_create
------------------------------------------
dir_create - create a new directory
 INPUTS
   ebx = path of new directory
 OUTPUT
   eax = negative error# if problem
 NOTES
   file: file_dir.asm
   kernel: mkdir(39)
   This function creates a user read/write directory
   if other directories are needed use kernel call

------------------------------------------
74. file/dir_delete
------------------------------------------
dir_delete - delete an empty directory
 INPUTS
   ebx = path of directory
 OUTPUT
   eax = negative error# if problem
 NOTES
   file: file_dir.asm
   kernel: rmdir(40)

------------------------------------------
75. file/dir_read
------------------------------------------
dir_read - open, read, close a directory structure
 INPUTS
   ebx = directory path
   edi = buffer to hold directory info
   ecx = size of buffer
 OUTPUT
   eax = negative error# if problems
 NOTES
   file: file_dir.asm
   kernel open(5) getdents(141) close(6)

------------------------------------------
76. file/dir_status
------------------------------------------
dir_status - check if directory exists
 INPUTS
   ebx = path for directory
 OUTPUT
   eax = negative error if problems, js,jns flags
   - set for conditonal jump
   ecx = fstat buffer ptr if success
   - (see lstat kernel call)
 NOTES
   file: file_dir.asm
   kernel: lstat (107)
   temp buffer lib_buf is used.

------------------------------------------
77. file/file_close
------------------------------------------
file_close - close opened file
 INPUTS
   ebx = file handle (file descriptor)
 OUTPUT
   eax = negative if error (error number)
   flag bits set for js jns jumps
 NOTES
   file: file_basics.asm

------------------------------------------
78. file/file_copy
------------------------------------------
file_copy - copy one file
 INPUTS
   ch = flags (these flags are for reading file)
   - bit 1 (0000 0001) = full path or local file
   - bit 2 (0000 0010) = full path or file at $HOME/[base]
   - (this register optional if full path is provided)
   - (it is ok to set both bits, local path checked first)
   ebx = ptr to (from) filename
   cl = flags (write file flags)
   0000 0001 - write to local directory or full path if given
   0000 0010 - write to $HOME or full path if given
   0000 0100 - use existing write attributes
   0000 1000 - file attributes are from input file,
   - (ignore 0100 flag)
   0001 0000 - append to existing file if found
   edx = ptr to (destination) filename
   ebp = ptr to enviornment pointer if any flag = 2
 OUTPUT
   eax = negative error code or success if positive
 NOTES
   file: file_copy.asm

------------------------------------------
79. file/file_delete
------------------------------------------
file_delete - delete file
 INPUTS
   ebx = path of file to delete
 OUTPUT
   eax = negative error# if problem
 NOTES
   file: file_dir.asm
   kernel: unlink(10)

------------------------------------------
80. file/file_length_handle
------------------------------------------
file_length_handle - get lenght of file using descriptor
 INPUTS
   ebx = file handle (file descriptor)
 OUTPUT
   eax = negative if error (error number)
   flag bits set for js jns jumps
   else (eax positive) file length
 NOTES
   file: file_basics.asm

------------------------------------------
81. file/file_length_name
------------------------------------------
file_length_name - get length of named file
 INPUTS
   ebx = ptr to full path for file
 OUTPUT
   eax = negative if error (error number)
   flag bits set for js jns jumps
   else (eax positive) file length
 NOTES
   file: file_basics.asm

------------------------------------------
82. file/file_list_copy
------------------------------------------
file_list_copy - copy files on list
 INPUTS
   esi = ptr to file list
   - file list contains asciiz names
   - example: file_list: db <from flag>
   - db 'from_name1',0
   - db <to flag>
   - db 'to_name1',0
   - db 0 ;end of table
   - from flags
   - bit 1 (0000 0001) = full path or local file
   - bit 2 (0000 0010) = full path or file at $HOME/[base]
   - (this register optional if full path is provided)
   - (it is ok to set both bits, local path checked first)
   - destination flags
   - 0000 0001 - write to local directory or full path if given
   - 0000 0010 - write to $HOME or full path if given
   - 0000 0100 - check for existing file and preserve attributes
   - 0000 1000 - file attributes from in-file, ignore 0100 flag
   - 0001 0000 - append to existing file if found
   ebp = env ptr if any flags have bit 2 set ($HOME paths)
 OUTPUT
 NOTES
   file: file_copy.asm

------------------------------------------
83. file/file_open
------------------------------------------
file_open - open named file
 INPUTS
   ebx = ptr to full file path
   ecx = access flags
   O_ACCMODE 0003
   O_RDONLY 00
   O_WRONLY 01
   O_RDWR 02
   O_CREAT 0100
   O_EXCL 0200
   O_NOCTTY 0400
   O_TRUNC 01000
   O_APPEND 02000
   O_NONBLOCK 04000
   O_NDELAY O_NONBLOCK
   O_SYNC 010000 specific to ext2 fs and block devices
   FASYNC 020000 fcntl, for BSD compatibility
   O_DIRECT 040000 direct disk access hint-currently ignored
   O_LARGEFILE 0100000
   O_DIRECTORY 0200000 must be a directory
   O_NOFOLLOW 0400000 don't follow links;
   edx = permissions used if file created
   S_ISUID 04000 set user ID on execution
   S_ISGID 02000 set group ID on execution
   S_ISVTX 01000 sticky bit
   S_IRUSR 00400 read by owner(S_IREAD)
   S_IWUSR 00200 write by owner(S_IWRITE)
   S_IXUSR 00100 execute/search by owner(S_IEXEC)
   S_IRGRP 00040 read by group
   S_IWGRP 00020 write by group
   S_IXGRP 00010 execute/search by group
   S_IROTH 00004 read by others
   S_IWOTH 00002 write by others
   S_IXOTH 00001 execute/search by others
 OUTPUT
   eax = negative if error (error number)
   eax = positive file handle if success
   flags are set for js jns jump
 NOTES
   file: file_basics.asm

------------------------------------------
84. file/file_open_rd
------------------------------------------
file_open_rd - open named file
 INPUTS
   ebx = ptr to full path for file.
 OUTPUT
   eax = negative err# if file can not be accessed
   flags set for js jns jump
   else eax = file handle of open file
   dx = file permissions if eax positive
   [lib_buf + 200] contains stat_struc (see file_status_*)
 NOTES
   file: file_basics.asm

------------------------------------------
85. file/file_read
------------------------------------------
file_read - read n bytes from open file
 INPUTS
   ebx = file descriptor (handle)
   edx = buffer size
   ecx = buffer ptr
 OUTPUT
   eax contains a negative error code or
   - a positive count of bytes read.
 NOTES
   file: file_basics.asm

------------------------------------------
86. file/file_read_all
------------------------------------------
file_read_all - open,read entire file,close
 INPUTS
   ebp = ptr to file name
   edx = buffer size
   ecx = buffer ptr
   ebx = ptr to enviornment pointers if bit 2 of al set
   al = flags
   - bit 1 (0000 0001) = full path or local file
   - bit 2 (0000 0010) = full path or file at $HOME/[base]
   - (this register optional if full path is provided)
   - (it is ok to set both bits, local path checked first)
 OUTPUT
   eax = negative error (sign bit set for js,jns jump)
   - buffer too small returns error code -2
   ebp = file permissions if eax positive
   eax= lenght of read
   ecx= buffer pointer if eax positive
   edx= reported file size (save as read)
 NOTES
   file: file_read.asm
   If file does not fit into buffer provided an error is
   returned.

------------------------------------------
87. file/file_read_grow
------------------------------------------
file_read_grow - open and read entire file, expand buffer if necessary
 INPUTS
   ebx = ptr to enviornment pointers if bit 2 of al set
   ebp = ptr to file name
   ecx = ptr to buffer
   edi = ptr to segment end (needed for expand kernel call)
   edx = ptr to end of current file
   al = flags (0000 0000) = full path provided
   - bit 1 (0000 0001) = full path or local file
   - bit 2 (0000 0010) = full path or file at $HOME/[base]
   - bit 5 (0001 0000) = insert file
 OUTPUT
   eax = either negative error or positive file length
   ebp = file permissions if eax positive
   ecx = buffer pointer for read
 NOTES
   file: file_read.asm

------------------------------------------
88. file/file_rename
------------------------------------------
file_rename - rename a file
 INPUTS
   ebx = ptr to old file path
   ecx - ptr to new file path
 OUTPUT
   eax = negative if error
 NOTES
   file: file_dir.asm
   kernel: rename(38)

------------------------------------------
89. file/file_simple_read
------------------------------------------
file_simple_read - open & read file to buffer, then close
 INPUTS
   ebx = ptr to full path for file.
   edx = buffer size
   ecx = buffer ptr
 OUTPUT
   eax contains a negative error code or
   - a positive count of bytes read
   - the sign bit is set for js/jns
 NOTES
   file: file_basics.asm

------------------------------------------
90. file/file_status_handle
------------------------------------------
file_status_handle - check filename exists and get status
 INPUTS
   ebx = file descriptor (handle)
 OUTPUT
   eax = result if negative file does not exist and sign
   bit is set for js jns jump
   if eax positive then dx = permissions
   if eax positive ecx = ptr to stat struct (below)
   -
   struc stat_struc
   .st_dev: resd 1 ;device
   .st_ino: resd 1 ;inode
   .st_mode: resw 1 ;see below
   .st_nlink: resw 1 ;number of hard links
   .st_uid: resw 1 ;user ID of owner
   .st_gid: resw 1 ;group ID of owner
   .st_rdev: resd 1 ;device type (if inode device)
   .st_size: resd 1 ;total size in bytes
   .st_blksize: resd 1 ;blocksize for filesystem I/O
   .st_blocks: resd 1 ;number of blocks allocated
   .st_atime: resd 1 ;time of last access
   .__unused1: resd 1
   .st_mtime: resd 1 ;time of last modification
   .__unused2: resd 1
   .st_ctime: resd 1 ;time of last change
   .__unused3: resd 1
   .__unused4: resd 1
   .__unused5: resd 1
   ; --- stat_struc_size
   endstruc
   -
   The following flags are defined for the st_mode field
   -
   S_IFMT 0170000 bitmask for the file type bitfields
   S_IFSOCK 0140000 socket
   S_IFLNK 0120000 symbolic link
   S_IFREG 0100000 regular file
   S_IFBLK 0060000 block device
   S_IFDIR 0040000 directory
   S_IFCHR 0020000 character device
   S_IFIFO 0010000 fifo
   S_ISUID 0004000 set UID bit
   S_ISGID 0002000 set GID bit (see below)
   S_ISVTX 0001000 sticky bit (see below)
   S_IRWXU 00700 mask for file owner permissions
   S_IRUSR 00400 owner has read permission
   S_IWUSR 00200 owner has write permission
   S_IXUSR 00100 owner has execute permission
   S_IRWXG 00070 mask for group permissions
   S_IRGRP 00040 group has read permission
   S_IWGRP 00020 group has write permission
   S_IXGRP 00010 group has execute permission
   S_IRWXO 00007 mask for permissions for others (not in group)
   S_IROTH 00004 others have read permission
   S_IWOTH 00002 others have write permisson
   S_IXOTH 00001 others have execute permission
 NOTES
   file: file_basics.asm
   stat_struc is held in temporary buffer and may be overwritten
   -by next library call.

------------------------------------------
91. file/file_status_name
------------------------------------------
file_status_name - check filename exists and get status
 INPUTS
   ebx = ptr to full path name.
 OUTPUT
   eax = result if negative file does not exist and sign
   - bit is set for js jns jump
   - if eax positive then dx = permissions
   - if eax positive ecx = ptr to stat struct (below)
   -
   struc stat_struc
   .st_dev: resd 1 ;device
   .st_ino: resd 1 ;inode
   .st_mode: resw 1 ;see below
   .st_nlink: resw 1 ;number of hard links
   .st_uid: resw 1 ;user ID of owner
   .st_gid: resw 1 ;group ID of owner
   .st_rdev: resd 1 ;device type (if inode device)
   .st_size: resd 1 ;total size in bytes
   .st_blksize: resd 1;blocksize for filesystem I/O
   .st_blocks: resd 1 ;number of blocks allocated
   .st_atime: resd 1 ;time of last access
   .__unused1: resd 1
   .st_mtime: resd 1 ;time of last modification
   .__unused2: resd 1
   .st_ctime: resd 1 ;time of last change
   .__unused3: resd 1
   .__unused4: resd 1
   .__unused5: resd 1
   ; --- stat_struc_size
   endstruc
   -
   The following flags are defined for the st_mode field
   -
   S_IFMT 0170000 bitmask for the file type bitfields
   S_IFSOCK 0140000 socket
   S_IFLNK 0120000 symbolic link
   S_IFREG 0100000 regular file
   S_IFBLK 0060000 block device
   S_IFDIR 0040000 directory
   S_IFCHR 0020000 character device
   S_IFIFO 0010000 fifo
   S_ISUID 0004000 set UID bit
   S_ISGID 0002000 set GID bit (see below)
   S_ISVTX 0001000 sticky bit (see below)
   S_IRWXU 00700 mask for file owner permissions
   S_IRUSR 00400 owner has read permission
   S_IWUSR 00200 owner has write permission
   S_IXUSR 00100 owner has execute permission
   S_IRWXG 00070 mask for group permissions
   S_IRGRP 00040 group has read permission
   S_IWGRP 00020 group has write permission
   S_IXGRP 00010 group has execute permission
   S_IRWXO 00007 mask for permissions for others (not in group)
   S_IROTH 00004 others have read permission
   S_IWOTH 00002 others have write permisson
   S_IXOTH 00001 others have execute permission
 NOTES
   file: file_basics.asm
   stat_struc is held in temporary buffer and may be overwritten
   by next library call.

------------------------------------------
92. file/file_write
------------------------------------------
file_write - write n bytes to open file
 INPUTS
   ebx = file descriptor (handle)
   edx = number of bytes to write
   ecx = buffer ptr
 OUTPUT
   eax contains a negative error code or
   - a positive count of bytes written
 NOTES
   file: file_basics.asm

------------------------------------------
93. file/file_write_close
------------------------------------------
file_write_close - open,write, and close file
 INPUTS
   ebx = file name ptr
   eax = buffer
   ecx = lenght of write
   ebp = ptr to enviornment pointer if flag bit 0010 set
   edx = file attributes if flag bit 1000 set
   esi = flags 0000 0001 write to local dir or full path if given
   - 0000 0010 write to $HOME or full path if given
   - 0000 0100 check for existing file and preserve attr
   - 0000 1000 file attr are in edx, ignore 0100 flag
   - 0001 0000 append to existing file if found
   Note: file name in ebx can include partial dir (dir/file.inc)
 OUTPUT
   eax = 0 or + normal
   - = -x error occured
 NOTES
   file: file_write.asm

------------------------------------------
94. file/filename_extract
------------------------------------------
   filename_extract - extract filename from full path
 INPUTS
   esi = ptr to buffer for filename
   edi = ptr to full path
 OUTPUT
   esi points to end of full path
   edi points to end end of extracted filename
 NOTES
   file: file_name.asm

------------------------------------------
95. file/filepath_extract
------------------------------------------
filepath_extract - extract path from path + name
 INPUTS
   edi = ptr to full path
   esi = buffer for path storage
 OUTPUT
   edi = ptr to end of extracted path
   esi = ptr to end of full path
   ebx = ptr inside full path to filename
 NOTES
   file: file_name.asm

------------------------------------------
96. file/mmap_close
------------------------------------------
mmap_close - close memory mapped file and release memory
 INPUTS
   eax = mmap fd (file descriptor)
   ebx = ptr to file data
   ecx = size of file to write
 OUTPUT
   eax - pointer to file contents
   (sign bit set if error)
   ebx and ecx are destroyed
 NOTES
   source file: mmap_close.asm
   see mmap_open_rw.asm and mmap_open_ro for opening files

------------------------------------------
97. file/mmap_open_ro
------------------------------------------
mmap_open_ro - returns a read only pointer to file data
 INPUTS
   ebx = poiter to asciiz filename
   ecx = optional buffer size
   - set to zero to read complete file
   lib_buf - temporary library buffer utilized
 OUTPUT
   eax - pointer to file contents
   (sign bit set if error)
   ebx - fd (file descriptor)
   ecx - read length (file length if fits in buffer)
 NOTES
   source file: mmap_open_ro.asm
   -
   notes: the lib_buf buffer is used to hold fstat status
   of file. see man fstat for format.
   -
   It is best to use this function for small files that
   are needed for brief period. See mmap kernel call
   for information on how long data file data is kept.

------------------------------------------
98. file/mmap_open_rw
------------------------------------------
mmap_open_rw - map file into memory for read/write
 INPUTS
   ebx = pointer to file path (asciiz filename)
   - (full path to file or local file)
   ecx = size of memory area to allocate for file
   - (small memory usage encouraged)
 OUTPUT
   eax - pointer to file contents
   (sign bit set if error)
   ebx - file descriptor (fd)
   ecx - file length
 NOTES
   source file: mmap_open_rw.asm
   see also: mmapfile.asm for read only version
   see mmap_close.asm for writing mmap_open_rw data out
   -
   It is best to use this function for small files that
   are needed for brief period. See mmap kernel call
   for information on how long data file data is kept.

------------------------------------------
99. key_mouse/is_alpha
------------------------------------------
is_alpha - check if alpha 20h -> 7eh
 INPUTS
   al = ascii char
 OUTPUT
   eq flag set for je if alpha
 NOTES
   file: /key_mouse/key_decode.asm

------------------------------------------
100. key_mouse/is_number
------------------------------------------
is_number - check if ascii number
 INPUTS
   al = ascii char
 OUTPUT
   eq flag set for je if alpha
 NOTES
   file: /key_mouse/key_decode.asm

------------------------------------------
101. key_mouse/key_decode1
------------------------------------------
key_decode1 - decode non-aplha key strings and get process
 INPUTS
   kbuf - global library buffer with key string
   esi = table of key strings and processes
   first table entry is alpha key process
   middle entries are non alpha keys
   final process is called if no match
   example
   dd gs_normal_char ;alpha key process
   db 1bh,5bh,48h,0 ; pad_home
   dd gs_home ; home process
   db 1bh,5bh,44h,0 ; pad_left
   dd gs_left ; left arrow process
   db 7fh,0 ; backspace
   dd gs_backspace ; backspace process
   db 0 ;end of table
   dd no_match ;no-match process
   -
 OUTPUT
   eax = process pointer
 NOTES
   file: key_decode.asm
   see also crt_open, mouse_enable

------------------------------------------
102. key_mouse/key_decode2
------------------------------------------
key_decode2 - decode aplha key strings and get process
 INPUTS
   esi = table of key strings and processes
   kbuf - global library buffer with alpha key
   example
   db "a" ; a key
   dd a_process ;
   db 'b' ; b key
   dd b_process ;
   db 0 ; end of table
   -
 OUTPUT
   eax = process pointer if no carry
   - carry = key not found
 NOTES
   file: key_decode.asm
   see also crt_open, mouse_enable

------------------------------------------
103. key_mouse/key_flush
------------------------------------------
key_flush - remove keys from input
 INPUTS
   none
 OUTPUT
   none
 NOTES
   file: key_mouse.asm

------------------------------------------
104. key_mouse/key_mouse1
------------------------------------------
key_mouse1 - flush and read one key string or mouse click
 INPUTS
   none
 OUTPUT
   kbuf has key sequence ending with zero byte
   if key sequence starts with byte of -1 then
   it is a mouse click and following bytes are:
   button(0-3), column(1-x), row(1-x)
   button = 0=left 1=middle 2=right 3=release
 NOTES
   file: key_mouse.asm
   The keyboard is flushed before reading key data.
   function crt_open must be called before using!

------------------------------------------
105. key_mouse/key_mouse2
------------------------------------------
key_mouse2 - read one key string or mouse click
 INPUTS
   none
 OUTPUT
   kbuf has key sequence ending with zero byte
   if key sequence starts with byte of -1 then
   it is a mouse click and following bytes are:
   button(0-3), column(1-x), row(1-x)
   button = 0=left 1=middle 2=right 3=release
 NOTES
   file: key_mouse.asm
   The keyboard is not flushed before reading key data.
   function crt_open must be called before using!

------------------------------------------
106. key_mouse/key_poll
------------------------------------------
key_poll - check if key avail.
 INPUTS
   none
 OUTPUT
   zero flag for jz set if no key available
 NOTES
   file: key_mouse.asm

------------------------------------------
107. key_mouse/key_string1
------------------------------------------
key_string1 - get string (preloaded string in buffer)
 INPUTS
   ebp= pointer to table with following:
   - data buffer ptr +0 (dword) cleared or preload with text
   - max string length +4 (dword) buffer must be 1 byte bigger
   - color ptr +8 (dword) (see file crt_data.asm)
   - display row +12 (db) ;row (1-x)
   - display column +13 (db) ;column (1-x)
   - allow 0d/0a in str +14 (db) ;0=no 1=yes
   - initial curosr col +15 (db) ;must be within data area
   notes: user can signal "done" by typing ESC-key. If allow 0d flag
   - is set=0 a string can also be terminated by <Enter> key.
   notes: The Initial cursor column must equal the display column
   - or within the range of "display_column" + "max string length"
   - Thus, if "display_column=5" and "max string length"=2 then
   - "initial cursor" can be 5 or 6
   -
 OUTPUT
   al=0 data in buffer, unknown char in kbuf
   al=1 data in buffer. mouse click
   ah=current cursor column
 NOTES
   file: key_string.asm
   function crt_open must be called before using!

------------------------------------------
108. key_mouse/key_string2
------------------------------------------
   key_string2 - get string (no preloaded string displayed)
 INPUTS
   ebp= pointer to table with following:
   - data buffer ptr +0 (dword) cleared or preload with text
   - max string length +4 (dword) buffer must be 1 byte bigger
   - color ptr +8 (dword) (see file crt_data.asm)
   - display row +12 (db) ;row (1-x)
   - display column +13 (db) ;column (1-x)
   - allow 0d/0a in str +14 (db) ;0=no 1=yes
   notes: user can signal "done" by typing ESC-key. If allow 0d flag
   - is set=0 a string can also be terminated by <Enter> key.
 OUTPUT
   al=0 data in buffer, unknown char in kbuf
   al=1 data in buffer. mouse click
 NOTES
   file: key_string.asm
   function crt_open must be called before using!

------------------------------------------
109. key_mouse/mouse_enable
------------------------------------------
mouse_enable - enable mouse on x terminals
 INPUTS
   none
 OUTPUT
   none
 NOTES
   file: mouse_enable.asm
   function crt_open also needed to use mouse

------------------------------------------
                   110. key_mouse/mouse_line_decode
------------------------------------------
mouse_line_decode - find mouse process from display line text
 INPUTS
   esi = display line text ptr
   edi = process list matching display line buttons
   bl = column mouse click occured on
   example:
   menu_line1
   db 1,' New-proj ',1,' Del-proj ',1,' Add-todo ',1,' Fwd ',0
   process_names
   dd new_proj, del_proj, add_todo, page_fwd
 OUTPUT
   ecx = process match or zero if no match
 NOTES
   file: mouse_line_decode.asm
   assumes click occured on button line matching input tables
   assumes  menu  line  uses  numbers  1-6 to indicate spaces between
   buttons
   assumes menu line text is terminated by a zero

------------------------------------------
111. log/log_fd
------------------------------------------
log_fd - log status of file descriptor
 INPUTS
   eax = fd (file descriptor)
 OUTPUT
 NOTES
   source file: log_fd.asm

------------------------------------------
112. log/log_signals
------------------------------------------
log_signals - install signal logging
 INPUTS
   eax = 1 to enable logging messages to file "log"
   - = 0 to disable logging messages to file "log"
   ebx = optional pointer to local signal handler. It
   - is called each time a non-fatal signal occurs.
   - Set ebx=0 if no handler is needed.
 OUTPUT
   handler called if provided and enabled (see below)
   global dword [signal_flag] is set to indicate signal
   occured. Bits are "or"ed into signal_flag each time a
   signal occurs. The flag can be cleared by user. The
   library function does not check signal_flag.
   -
   If the caller provided handler is called the following
   registers are set:
   - eax = signal number
   - esi = pointer to signal name string
   -
   - signal actions are as follows:
   -
   - name - number logged handler called signal_flag bit
   SIGHUP 1 yes yes 0x00000001
   SIGINT 2 yes yes 0x00000002
   SIGQUIT 3 yes yes 0x00000004
   SIGILL 4 yes no (log_signal aborts program) -
   SIGTRAP 5 yes yes 0x00000010
   SIGABRT 6 yes no (log_signal aborts program) 0x00000020
   SIGIOT 6 yes no (log_signal aborts program) 0x00000020
   SIGBUS 7 yes yes 0x00000040
   SIGFPE 8 yes no (log_signal aborts program) 0x00000080
   SIGKILL 9 no no -
   SIGUSR1 10 yes yes 0x00000200
   SIGSEGV 11 yes no (log_signal aborts program) 0x00000400
   SIGUSR2 12 yes yes 0x00000800
   SIGPIPE 13 yes yes 0x00001000
   SIGALRM 14 yes yes 0x00002000
   SIGTERM 15 yes no (log_signal aborts program) 0x00004000
   SIGSTKFLT 16 yes yes 0x00008000
   SIGCHLD 17 yes yes 0x00010000
   SIGCONT 18 yes yes 0x00020000
   SIGSTOP 19 no no -
   SIGTSTP 20 yes yes 0x00080000
   SIGTTIN 21 yes yes 0x00100000
   SIGTTOU 22 yes yes 0x00200000
   SIGURG 23 yes yes 0x00400000
   SIGXCPU 24 yes yes 0x00800000
   SIGXFSZ 25 yes yes 0x01000000
   SIGVTALRM 26 yes yes 0x02000000
   SIGPROF 27 yes yes 0x04000000
   SIGWINCH 28 yes yes 0x08000000
   SIGIO 29 yes yes 0x10000000
 NOTES
   source file: log_signals.asm
   -
   This function can be used for testing or as a
   signal handler. Function "err_signal_install"
   is also available and allows more flexability.

------------------------------------------
113. process/check_process
------------------------------------------
check_process - get our process information
 INPUTS
   ebx = pid (process id)
 OUTPUT
   al = "U" unknown pid
   al = "S" sleeping
   al = "R" running
   al = "T" stopped
   al = "Z" zombie
   al = "D" dead
 NOTES
   source file: check_process.asm

------------------------------------------
114. process/process_info_pid
------------------------------------------
process_info_pid - get our process information
 INPUTS
   esi = ptr to asciiz pid string
 OUTPUT
   eax = number of bytes of data in buffer lib_buf
   - (if eax negative an error occured)
   ecx = pointer to data in lib_buf (see below)
   - Name: init
   - State: S (sleeping)
   - SleepAVG: 90%
   - Tgid: 1
   - Pid: 1
   - PPid: 0
   - TracerPid: 0
   - Uid: 0 0 0 0
   - Gid: 0 0 0 0
   - FDSize: 32
   - Groups:
   - VmSize: 1408 kB
   - VmLck: 0 kB
   - VmRSS: 496 kB
   - VmData: 148 kB
   - VmStk: 4 kB
   - VmExe: 28 kB
   - VmLib: 1204 kB
   - Threads: 1
   - SigPnd: 0000000000000000
   - ShdPnd: 0000000000000000
   - SigBlk: 0000000000000000
   - SigIgn: ffffffff57f0d8fc
   - SigCgt: 00000000280b2603
   - CapInh: 0000000000000000
   - CapPrm: 00000000ffffffff
   - CapEff: 00000000fffffeff
   The above data is held in a temporary buffer (lib_buf) and
   may be destroyed by other library functions. All entries of
   form xxxx: begin at left edge and are followed by a <tab>. The\
   end of each entry is a <0ah> end of line character. No binary
   data is in lib_buf buffer.
 NOTES
   source file: process_info_pid.asm

------------------------------------------
115. process/process_info_us
------------------------------------------
process_info_us - get our process information
 INPUTS
   none
 OUTPUT
   eax = number of bytes of data in buffer lib_buf
   - (if eax negative an error occured)
   ebx = our process id (binary)
   ecx = pointer to data in lib_buf (see below)
   - Name: init
   - State: S (sleeping)
   - SleepAVG: 90%
   - Tgid: 1
   - Pid: 1
   - PPid: 0
   - TracerPid: 0
   - Uid: 0 0 0 0
   - Gid: 0 0 0 0
   - FDSize: 32
   - Groups:
   - VmSize: 1408 kB
   - VmLck: 0 kB
   - VmRSS: 496 kB
   - VmData: 148 kB
   - VmStk: 4 kB
   - VmExe: 28 kB
   - VmLib: 1204 kB
   - Threads: 1
   - SigPnd: 0000000000000000
   - ShdPnd: 0000000000000000
   - SigBlk: 0000000000000000
   - SigIgn: ffffffff57f0d8fc
   - SigCgt: 00000000280b2603
   - CapInh: 0000000000000000
   - CapPrm: 00000000ffffffff
   - CapEff: 00000000fffffeff
   The above data is held in a temporary buffer (lib_buf) and
   may be destroyed by other library functions. All entries of
   form xxxx: begin at left edge and are followed by a <tab>. The\
   end of each entry is a <0ah> end of line character. No binary
   data is in lib_buf buffer.
 NOTES
   source file: process_info_us.asm

------------------------------------------
116. process/process_search
------------------------------------------
process_search - search through active process's
 INPUTS
   eax = either buffer pointer or continue flag
   - if eax = buffer ptr then this is first call
   - - and searching will begin
   - if eax = 0 this is a continuation call and
   - - we will search to next match
   ebx = buffer size if ptr in eax
   ecx = match string (asciiz process name)
 OUTPUT
   eax = (if eax negative an error occured)
   - (if eax = 0 then no match found)
   - (if eax positive = ptr to process data (see below)
   - Name: init
   - State: S (sleeping)
   - SleepAVG: 90%
   - Tgid: 1
   - Pid: 1
   - PPid: 0
   - TracerPid: 0
   - Uid: 0 0 0 0
   - Gid: 0 0 0 0
   - FDSize: 32
   - Groups:
   - VmSize: 1408 kB
   - VmLck: 0 kB
   - VmRSS: 496 kB
   - VmData: 148 kB
   - VmStk: 4 kB
   - VmExe: 28 kB
   - VmLib: 1204 kB
   - Threads: 1
   - SigPnd: 0000000000000000
   - ShdPnd: 0000000000000000
   - SigBlk: 0000000000000000
   - SigIgn: ffffffff57f0d8fc
   - SigCgt: 00000000280b2603
   - CapInh: 0000000000000000
   - CapPrm: 00000000ffffffff
   - CapEff: 00000000fffffeff
   The above data is held in a temporary buffer (lib_buf) and
   may be destroyed by other library functions. All entries of
   form xxxx: begin at left edge and are followed by a <tab>. The\
   end of each entry is a <0ah> end of line character. No binary
   data is in lib_buf buffer.
 NOTES
   source file: process_search.asm

------------------------------------------
117. process/process_walk
------------------------------------------
process_walk - walk through active process's
 INPUTS
   eax = either buffer pointer or continue flag
   if eax = buffer ptr then this is first call
   - and walking will begin
   if eax = 0 this is a continuation call and
   - we will walk to next process
   ebx = buffer size if ptr in eax
 OUTPUT
   eax = number of bytes of data in buffer lib_buf
   - (if eax negative an error occured)
   - (if eax = zero we are done walking)
   ecx = pointer to data in lib_buf (example below)
   - Name: init
   - State: S (sleeping)
   - SleepAVG: 90%
   - Tgid: 1
   - Pid: 1
   - PPid: 0
   - TracerPid: 0
   - Uid: 0 0 0 0
   - Gid: 0 0 0 0
   - FDSize: 32
   - Groups:
   - VmSize: 1408 kB
   - VmLck: 0 kB
   - VmRSS: 496 kB
   - VmData: 148 kB
   - VmStk: 4 kB
   - VmExe: 28 kB
   - VmLib: 1204 kB
   - Threads: 1
   - SigPnd: 0000000000000000
   - ShdPnd: 0000000000000000
   - SigBlk: 0000000000000000
   - SigIgn: ffffffff57f0d8fc
   - SigCgt: 00000000280b2603
   - CapInh: 0000000000000000
   - CapPrm: 00000000ffffffff
   - CapEff: 00000000fffffeff
   The above data is held in a temporary buffer (lib_buf) and
   may be destroyed by other library functions. All entries of
   form xxxx: begin at left edge and are followed by a <tab>. The
   end of each entry is a <0ah> end of line character. No binary
   data is in lib_buf buffer.
   Open files are closed when end of process data is signaled by
   no more data. If walk does not reach the end, the open file
   handle "proc_handle" should be closed by caller.
 NOTES
   source file: process_walk.asm

------------------------------------------
118. random/random_dword
------------------------------------------
random_dword - generate random dword
 INPUTS
   none
 OUTPUT
   eax = random value
 NOTES
   source file: random2.asm

------------------------------------------
119. random/random_seed
------------------------------------------
random_seed - get low clock bits to use as random number
 INPUTS
   none
 OUTPUT
   eax = microseconds counter,
 NOTES
   source file random3.asm

------------------------------------------
120. random/scale_word
------------------------------------------
scale_word - adjust random number to fit in range
 INPUTS
   bx = low value of range
   bp = high value of range
   ax = number to scale
 OUTPUT
   ax = scalled number
 NOTES
   source file: random1.asm
   - The number is scaled using the formula
   -
   - input value x
   - ----------- = -----------------------
   - 0ffffh (high range - low range)
   -
   - scaled number = x + low range
   -

------------------------------------------
121. sort/sort_bubble
------------------------------------------
sort_bubble - bubble sort a list of ptr to text blocks
 INPUTS
   ebp = ptr to list of record pointers, terminated by zero ptr
 OUTPUT
   pointer list reordered
 NOTES
   file: sort_bubble.asm

------------------------------------------
122. sort/sort_selection
------------------------------------------
sort_selection - use selection sort with ptr list
 INPUTS
   ebp - pointer to pointers for each record
   - last pointer equals zero
   edx = column to use as sort data
   ecx = length of sort
 OUTPUT
   pointers ordered by decending records
 NOTES
   file:
   The index must have at least one entry.

------------------------------------------
123. str/str_insert
------------------------------------------
str_insert - inserts string into string
 INPUTS
   esi = ptr to string1
   edi = ptr to string 2
   eax = ptr to insert point in string2
 OUTPUT
   string1 is inserted into string2
 NOTES
   source file: srt_insert.asm

------------------------------------------
124. str/str_join
------------------------------------------
   str_join - join two strings
 INPUTS
   edi = string1
   ebx = string1 length
   esi = string2
   edx = string2 length
 OUTPUT
   edi points at new string
   ecx is lenght of new string
 NOTES
   source file: str_join.asm

------------------------------------------
125. str/str_len
------------------------------------------
str_len - find length of asciiz string
 INPUTS
   esi = input string ptr (asciiz)
 OUTPUT
   ecx = string length
   all other registers unchanged.
 NOTES

------------------------------------------
126. str/str_move
------------------------------------------
str_move - move asciiz string
 INPUTS
   esi = input string ptr (asciiz)
   edi = destination ptr
 OUTPUT
   edi points at zero (end of moved asciiz string)
 NOTES
   file str_move.asm

------------------------------------------
127. str/str_move
------------------------------------------
str_move - move asciiz string
 INPUTS
   esi = input string ptr (asciiz)
   edi = destination ptr
 OUTPUT
   edi points at zero (end of moved asciiz string)
 NOTES
   file str_move.asm

------------------------------------------
128. str/str_replace
------------------------------------------
   str_replace - replace first occurance of str1 in str2
 INPUTS
   esi = str1 -asciiz string ending with any char 0h-6h
   edi = str2 -asciiz string ending with any char 0h-6h
   eax = ptr to replacement string
 OUTPUT
   carry set if replacement occured
   if no carry - ebp = new str2 end point
   if no carry - edi = ptr to end of inserted string
 NOTES
   source file: str_replace.asm

------------------------------------------
129. str/str_replace_all
------------------------------------------
   str_replace_all - replace all occurances of str1 in str2
 INPUTS
   esi = str1 -asciiz string ending with any char 0h-6h
   edi = str2 -asciiz string ending with any char 0h-6h
   eax = ptr to replacement string
 OUTPUT
   carry set if replacement occured
   if no carry - ebp = new str2 end point
   if no carry - edi = ptr to end of inserted string
 NOTES
   source file: str_replace_all.asm

------------------------------------------
130. str/str_search
------------------------------------------
str_search - search string for match
 INPUTS
   esi = input asciiz string terminated with 0-9h
   edi = string to search, terminated with 0-9h
 OUTPUT
   carry set if no match
   no carry if match and registers =
   - esi - points to end of matching string
   - edi - points to end of matched string
   - edx - points to start of matching string
   - ebx - points to start of matched string
 NOTES
   source file: str_search.asm

------------------------------------------
131. str/strlen1
------------------------------------------
strlen1 - get lenght of esi string
 INPUTS
   esi = pointer to asciiz string
 OUTPUT
   ecx = lenght of string
   all registers restored except for ecx
 NOTES
   source file: srt_insert.asm

------------------------------------------
132. str/strlen2
------------------------------------------
strlen2 - get lenght of edi string
 INPUTS
   edi = pointer to asciiz string
 OUTPUT
   ecx = lenght of string
   all registers restored except ecx
 NOTES
   source file: srt_insert.asm

------------------------------------------
133. str_cmp/str_compare
------------------------------------------
str_compare - compare two strings, use case
 INPUTS
   esi = string1
   edi = string2
   assumes direction flag set to -cld- forward state
 OUTPUT
   flags set for je or jne
   esi & edi point at end of strings if match
 NOTES
   source file: str_compare.asm

------------------------------------------
134. str_conv/ascii_to_dword
------------------------------------------
ascii_to_dword - convert decimal ascii string to binary
 INPUTS
   esi = ptr to ascii string
 OUTPUT
   ecx = binary value
 NOTES
   file: ascii_to_dword.asm

------------------------------------------
135. str_conv/byte2hexascii
------------------------------------------
byte2hexascii - convert one byte to hex ascii and store
 INPUTS
   ebx = byte of data
   edi = storage point for ascii
 OUTPUT
   two ascii characters stored at [edi]
   - edi bumped by two
   - ebx is shifted right
 NOTES
   source file: hex2ascii.asm

------------------------------------------
136. str_conv/byte_to_hexascii
------------------------------------------
byte_to_hexascii - binary byte to hex ascii
 INPUTS
   al = binary hex byte
 OUTPUT
   ax = hex ascii
 NOTES
   file: byte_to_hexascii.asm

------------------------------------------
137. str_conv/dword2hexascii
------------------------------------------
dword2hexascii - convert dword to hex ascii and store
 INPUTS
   ebx = dword
   edi = storage point for ascii
 OUTPUT
   eight ascii character stored at [edi]
   - edi bumped by eight
   - ebx is shifted right
 NOTES
   source file: hex2ascii.asm

------------------------------------------
138. str_conv/dword_to_ascii
------------------------------------------
dword_to_ascii - convert binary dword to left justified ascii string
 INPUTS
   eax = binary value
   edi = start of storage area
 OUTPUT
   edi = ptr to end of stored string
   eax,ebx,ecx destroyed
 NOTES
   file: dword_to_ascii.asm

------------------------------------------
139. str_conv/dword_to_hexascii
------------------------------------------
dword_to_hexascii - binary byte to hex ascii
 INPUTS
   ecx = binary hex dword
   edi = ptr to storage area
 OUTPUT
   edi = ptr to end of stored string
   (string always contains 8 ascii characters)
 NOTES
   file: dword_to_hexascii.asm

------------------------------------------
140. str_conv/dword_to_l_ascii
------------------------------------------
dword_to_l_ascii - convert binary dword to left justified ascii string
 INPUTS
   eax = binary value
   edi = start of storage area
   esi = number of digets to store
 OUTPUT
   edi = ptr to end of stored string
   eax,ebx,ecx destroyed
 NOTES
   file: dword_to_l_ascii.asm

------------------------------------------
                 141. str_conv/dword_to_lpadded_ascii
------------------------------------------
dword_to_lpadded_ascii  - convert binary dword to left justified ascii
string
 INPUTS
   eax = binary value
   edi = start of storage area
   cl = number of bytes to store
   ch = pad character
 OUTPUT
   edi = ptr to end of stored string
   eax,ebx,ecx,ebp destroyed
 NOTES
   source file: dword_to_lpadded_ascii.asm

------------------------------------------
142. str_conv/dword_to_r_ascii
------------------------------------------
   dword_to_r_ascii - convert bin dword to right just ascii str
 INPUTS
   eax = binary valuel
   edi = end of storage area for ascii (decremented)
 OUTPUT
   edi = ptr to start of ascii string
   eax,ebx,ecx destroyed
 NOTES
   file: dword_to_r_ascii.asm

------------------------------------------
143. str_conv/hexascii2byte
------------------------------------------
hexascii2byte - convert two hex ascii char to byte
 INPUTS
   esi = ptr to hex ascii data
   ebx = zero or previous sum
 OUTPUT
   ebx = contains hex , the previous contents
   - are shifted left
 NOTES
   source file: ascii2hex.asm

------------------------------------------
144. str_conv/hexascii2dword
------------------------------------------
hexascii2dword - convert eight hex ascii char to dword
 INPUTS
   esi = ptr to hex ascii data
   ebx = zero or previous sum
 OUTPUT
   ebx = contains hex , the previous contents
   - are shifted left
 NOTES
   source file: ascii2hex.asm

------------------------------------------
145. str_conv/hexascii2nibble
------------------------------------------
hexascii2nibble - convert one hex ascii char to nibble
 INPUTS
   esi = ptr to hex ascii data
   ebx = zero or previous sum
 OUTPUT
   ebx = contains hex in low 4 bits, the previous contents
   - are shifted left by 4
 NOTES
   source file: ascii2hex.asm

------------------------------------------
146. str_conv/hexascii2word
------------------------------------------
hexascii2word - convert four hex ascii char to word
 INPUTS
   esi = ptr to hex ascii data
   ebx = zero or previous sum
 OUTPUT
   ebx = contains hex , the previous contents
   - are shifted left
 NOTES
   source file: ascii2hex.asm

------------------------------------------
147. str_conv/hexascii_to_byte
------------------------------------------
hexascii_to_byte - convert up to 2 hexascii to bin
 INPUTS
   esi = ptr to hex asciiz string
   (max string length is 2)
 OUTPUT
   al = binary value of hex string if no carry flag
   if carry flag set the input data is bad
 NOTES
   file: hexascii_to_bin.asm

------------------------------------------
148. str_conv/hexascii_to_dword
------------------------------------------
hexascii_to_dword - convert up to 8 hexascii to bin
 INPUTS
   esi = ptr to hex asciiz string
   (max string length is 8)
 OUTPUT
   ecx = binary value of hex string
 NOTES
   file: hexascii_to_bin.asm

------------------------------------------
                   149. str_conv/hexascii_to_nibble
------------------------------------------
hexascii_to_nibble - convert hexascii char to bin
 INPUTS
   al = contains one hexascii char
   ch = (accumulator for hex, will be shifted left)
 OUTPUT
   ch = hex nibble in lower 4 bits
   if carry flag set the input data is bad
 NOTES
   file: hexascii_to_bin.asm

------------------------------------------
150. str_conv/nibble2hexascii
------------------------------------------
nibble2hexascii - convert one nibble to hex ascii and store
 INPUTS
   ebx = nibble
   edi = storage point for ascii
 OUTPUT
   one ascii character stored at [edi]
   - edi bumped by one
   - ebx is shifted right
 NOTES
   source file: hex2ascii.asm

------------------------------------------
151. str_conv/word2hexascii
------------------------------------------
word2hexascii - convert one word to hex ascii and store
 INPUTS
   ebx = word
   edi = storage point for ascii
 OUTPUT
   four ascii characters stored at [edi]
   - edi bumped by four
   - ebx is shifted right
 NOTES
   source file: hex2ascii.asm

------------------------------------------
152. str_parse/read_setup
------------------------------------------
read_setup - read config file and move data
 INPUTS
   ebp = file name ptr, use $HOME as base
   edi = buffer to read file into, must be big enoug
   - to hold data
   esi = table with data move information.
   ebx = ptr to enviornment pointers
   - table format (esi):
   - ptr to name, ptr to destination, grouping code (4 ascii chars)
   - zero ptr to name indicates end of table
   - names terminated by space or any char 0-9h
   -  grouping  code  is  used  to  destinguish between two identical
   names,
   - this is useful when one name has multiple possible destinations.
   -
   - input file format (edi):
   - <ascii name>=<"string"> space <grouping code>
   - ascii name - variable length string without any spaces inside,
   - - ends with "=" char.
   -  string  -  any  ascii data enclosed in quotes, space after last
   quote
   -  grouping  code - any 4 ascii characters matching table grouping
   code
 OUTPUT
   if name and grouping match table then the "string" is
   - moved using table destination ptr.
   stored string is terminated with spaces unitl
   any char 0-9h encountered
   -
   if file not found read_setup returns sign bit set
   for js instruction.
   if file found and processed, then jns flag bit set
 NOTES
   source file: read_setup.asm

------------------------------------------
153. sys/sys_ex
------------------------------------------
   sys_ex - call execve kernel function
 INPUTS
   [enviro_ptrs] - global var set by function env_stack
   esi = ptr to input string
   - string byte 1 = separator character
   - string byte 2+ = full path ending with separator
   - string next = first parameter ending with separator
   - etc. (last parameter ends with zero)
   example: db "|/bin/name|parameter1|parameter2",0
 OUTPUT
   al = byte two of execve_status
   [execve_status] - contains results from execve
   - al = 0 success
   - al = 11 could not launch child
   - al = negative (system error code)
   - flags set for jz,js,jnz,jns jumps
   note: input string modified by replacing separator
   - characters with value of zero, thus, string
   - must be writable.
 NOTES
   source file: sys_ex.asm

------------------------------------------
154. sys/sys_ex_home
------------------------------------------
   sys_ex_home - launches executable from $HOME/name
 INPUTS
   esi = ptr to command line as follows:
   - separator,name,parameter1,parameter2,... end
   - separator - single character used in rest of
   - line to separate fields
   - name - executable name
   - paramaterx - any string with "separator at start
   - and end.
   - end - a zero byte.
   buffer "lib_buf" is used to build path
   example: db "|/bin/name|parameter1|parameter2",0
   - looks for bin directory in $HOME with file "name"
   - note, the "name" must start with a "/" and can not
   - be in the system root directory.
 OUTPUT
   al = byte two of execve_status
   [execve_status] - contains results from execve
   - al = 0 success
   - al = 11 could not launch child
   - al = 12 name not found on path
   - al = negative (system error code)
   - flags set for jz,js,jnz,jns jumps
 NOTES
   source file: sys_ex_home.asm
   -
   sys_ex_home begins by searching the evn for "HOME". If
   found the full path is built in lib_buf and sys_ex called.

------------------------------------------
155. sys/sys_ex_path
------------------------------------------
   sys_ex_path - launches executable by searching path
 INPUTS
   esi = ptr to command line as follows:
   - separator,name,parameter1,parameter2,... end
   - separator - single character used in rest of
   - line to separate fields
   - name - executable name
   - paramaterx - any string with "separator at start
   - and end.
   - end - a zero byte.
   example: db "|bin/name|parameter1|parameter2",0
   buffer "lib_buf" is used to build path
 OUTPUT
   al = byte two of execve_status
   [execve_status] - contains results from execve
   - al = 0 success
   - al = 11 could not launch child
   - al = 12 name not found on path
   - al = negative (system error code)
   - flags set for jz,js,jnz,jns jumps
 NOTES
   source file: sys_ex_path.asm
   -
   sys_ex_path begins by searching the path for "name". If
   found the full path is built in lib_buf and sys_ex called.

------------------------------------------
156. sys/sys_launch
------------------------------------------
   sys_launch - launch executables from standard locations
 INPUTS
   eax = ptr to executable name
   ebx = (base) directory at $HOME to search, if zero
   - $HOME will be searched for executable.
   - define as "/filepath" with "/" infront of name
   global variables (setup before calling)
   [enviro_ptrs] (dword) ptr to env pointers on stack
 OUTPUT
   carry set if launch failed
   no carry = program launched and we waited till it completed.
 NOTES
   source file: sys_launch.asm
   This function is obsolete, use sys_ex_xxxx functions first
   Processing: The search for programs as follows
   - 1. look in current directory & execute if found
   - 2. look in $HOME/base and execute if found
   - 3. search the path and execute if found

------------------------------------------
157. sys/sys_launch_engine
------------------------------------------
   sys_launch_engine - launch executable program
 INPUTS
   eax = ptr to executable name
   ebx = (base) directory at $HOME to search, if zero
   $HOME will be searched for executable.
   global variables
   path_flag (byte) 0=local executable (in current working dir)
   1=search executable path for name, needs entry_stack
   2=ename_ptr has path + name + parameters
   3=ename_ptr has name + parameters and pname has path
   4=ename_ptr has name + path base is $HOME/[base]
   launch_flag  (byte) 0=launch and wait for completion, 1=launch and
   continue
   2=launch and die
   enviro_ptrs (dword) ptr to env pointers on stack
   ename_ptr (dword) pointer to executable program name + parameters
   pname_ptr (dword) ponter to path, only needed if path_flag=3
 OUTPUT
   carry set if launch failed
   no carry = program launched and we waited till it completed.
NOTE     source  file: sys_launch.asm * This function is obsolete, use
sys_ex_xxxx functions first *
----------------------------------------------

------------------------------------------
158. sys/sys_launch_path
------------------------------------------
   sys_launch_path - launch executables from known location
 INPUTS
   eax = ptr to full path for executable
 OUTPUT
   carry set if launch failed
   no carry = program launched and we waited till it completed.
 NOTES
   source file: sys_launch.asm
   sys_launch_path is a legacy function, the sys_ex_xxxx functions
   - are prefered.

------------------------------------------
159. sys/sys_pipe_capture
------------------------------------------
sys_pipe_capture - get our process information
 INPUTS
   [enviro_ptrs] - global set by calling env_stack
   eax = ptr to program string
   - this is normal shell command string
   ebx = buffer to hold output from program
   ecx = size of buffer
 OUTPUT
   eax = shell program exit status (in -al-)
   - (if eax negative an error occured)
   ebx = updated buffer ptr after data stored.
 NOTES
   source file: sys_pipe_capture.asm

------------------------------------------
160. sys/sys_pipe_feed
------------------------------------------
sys_pipe_feed - launch program and pipe to it's STDIN
 INPUTS
   eax = ptr to program string
   - this is an ELF executable.
   - Not all programs accept a pipe for STDIN
   ebx = pointer to function that will feed characters
   - to ELF executable in eax
   - The feed program recieves child pid in eax
   - and write pipe (fd) in ebx.
   a simple feed program to watch for ESC key:
   - feed_keys:
   - mov [fk_pid],eax ;save child pid
   - mov [fk_pipe],ebx ;save output pipe
   - key_loop:
   - call key_mouse2
   -
   - or al,al
   - jz feed_keys ;jmp if zero read
   -
   - cmp word [kbuf],001bh
   - je fk_done ;if esc pressed exit
   -
   - mov ebx,[child_pid]
   - call check_pid
   - cmp al,'Z' ;zombie?
   - je fk_done
   - cmp al,'T' ;stopped?
   - je fk_done
   -
   - mov ebx,[fk_pipe]
   - mov ecx,kbuf
   - ; now pipe (feed) key to our child
   - char_loop:
   - mov edx,1
   - mov eax,4
   - int 80h
   -
   - or eax,eax
   - js fk_done
   - inc ecx
   - cmp byte [ecx],0
   - jne char_loop
   - jmp key_loop
   - fk_done:
   - ret
   - ;--------------
   - [section .data]
   - fk_pid: dd 0
   - fk_pipe: dd 0
   - [section .text]
 OUTPUT
   eax = shell program exit status (in -al-)
   - (if eax negative an error occured)
 NOTES
   source file: sys_pipe_feed.asm

------------------------------------------
161. sys/sys_shell
------------------------------------------
   sys_shell - launches local shell
 INPUTS
   [enviro_ptrs] - global var set by function env_stack
   the global buffer "lib_buf" is used to build path
 OUTPUT
   The enviornment varialbe SHELL is used to find shell
   and it is launched. The screen is not cleared and
   the shell inherits the path of parent.
   -
   al = byte two of execve_status
   [execve_status] - contains results from execve
   - al = 0 success
   - al = 11 could not launch child
   - al = negative (system error code)
   - flags set for jz,js,jnz,jns jumps
 NOTES
   source file: sys_shell.asm

------------------------------------------
162. sys/sys_shell_alt
------------------------------------------
   sys_shell_alt - launches local shell in alternate window
 INPUTS
   [enviro_ptrs] - global var set by function env_stack
   the global buffer "lib_buf" is used to build path
 OUTPUT
   The enviornment varialbe SHELL is used to find shell
   and it is launched. The screen is not cleared and
   the shell inherits the path of parent.
   -
   al = byte two of execve_status
   [execve_status] - contains results from execve
   - al = 0 success
   - al = 11 could not launch child
   - al = negative (system error code)
   - flags set for jz,js,jnz,jns jumps
 NOTES
   source file: sys_shell_alt.asm

------------------------------------------
163. sys/sys_shell_cmd
------------------------------------------
   sys_shell_cmd - launches local shell
 INPUTS
   [enviro_ptrs] - global var set by function env_stack
   esi = ptr to shell commands
   - example: db "ls -a;ls",0
   the global buffer "lib_buf" is used to build path
 OUTPUT
   The enviornment varialbe SHELL is used to find shell
   and it is launched. The screen is not cleared and
   the shell inherits the path of parent.
   -
   al = byte two of execve_status
   [execve_status] - contains results from execve
   - al = 0 success
   - al = 11 could not launch child
   - al = negative (system error code)
   - flags set for jz,js,jnz,jns jumps
 NOTES
   source file: sys_shell_cmd.asm

------------------------------------------
164. sys/sys_win_alt
------------------------------------------
   sys_win_alt - switches to Vt100 alt windows
 INPUTS
   [terminal_type] - set by crt_type
 OUTPUT
   alternate terminal window selected
 NOTES
   source file: sys_shell_alt.asm

------------------------------------------
165. sys/sys_win_normal
------------------------------------------
   sys_win_normal - selects normal Vt100 windows
 INPUTS
   [terminal_type] - set by crt_type
 OUTPUT
   normal terminal window selected
 NOTES
   source file: sys_shell_alt.asm

------------------------------------------
166. sys/sys_wrap
------------------------------------------
sys_wrap  - wrap around an executable and capture in/out - Executables
that  put  keyboard  in "raw" mode can - be captured by this function.
Only programs that - require the <enter> key to complete a line will -
fail. Most programs that uses single key commands - will work.
 INPUTS
   eax = ptr to shell command string
   ebx = ptr to optional input (feed) process (see notes)
   ecx = ptr to optional output capture process (see notes)
   env_stack function must be called prior to using this function
 OUTPUT
   none
 NOTES
   file sys_wrap.asm
   -
   The optional feed process can be set to zero if not needed.
   If a feed process adress is given, it is called after a key
   has been read to "fbuf" and before it is sent to child/slave.
   The feed process can change the contents of kbuf or set eax
   negative forcing an abort of child. The data in kbuf is terminated
   by a zero byte and can be cleared to ignore a keystroke.
   -
   The optional capture process is passed a buffer (ecx) and count
   (eax) of bytes read from child/slave. The data can be changed
   or the child aborted. The eax register is set negative to abort
   child. If "capture" exits with eax positive the buffer contents
   will be written to stdout. At exit eax has count of bytes in
   buffer. It can be zero to ignore buffer contents.
   -
   The input key buffer (kbuf) and output capture buffer (lib_buf)
   are used to pass data. kbuf is 10 bytes long and lib_buf
   is 600 bytes long.

------------------------------------------
167. sys/wait_event
------------------------------------------
wait_event - poll fd input/output status
 INPUTS
   esi = array of dword fd's terminated by -1
   eax = max wait time, or zero to wait forever, and
   - minus 1 for immediate return of status
 OUTPUT
   eax = 0 child has died
   - = negative, then error/signal active(-4)
   - = positive number of events pending
   ecx = ptr to array of bits set for each fd with
   - pending actions, bit 1 represents stdin (fd 0)
 NOTES
   file wait_event.asm
   note: see bit_test, bit_set_list

------------------------------------------
168. sys/write_setup
------------------------------------------
write_setup - write config file
 INPUTS
   ebp = file name ptr, use $HOME as base
   edi = buffer to build file
   ebx = table with data move information.
   eax = enviornment ptr to ptrs
   - table format:
   - ptr to name, ptr to destination, grouping code
   - zero indicates end of table pairs.
   - names terminated by space or any char 0-9h
   - grouping code is 4 ascii digits used too
   - - destinguish between identical names.
*
 OUTPUT
   the file name in ebp is written to $HOME dir
   with: <name>=<destination data><space><grouping code><0ah>
 NOTES
   source file: write_setup.asm
   see file read_setup.asm

------------------------------------------
169. widget/edit_file_in_box
------------------------------------------
edit_file_in_box - edit small file inside box
 INPUTS
   ebx = ptr to full path of file or local file
   ecx = buffer size needed for file
   esi = pointer to structure below
   - dd window color (see notes)
   - dd data pointer. (set by edit_file_in_box )
   - dd end of data ptr, beyond last display char.
   - (end of data is set by edit_file_in_box )
   - dd initial scroll left/right position
   - db columns inside box
   - db rows inside box
   - db starting row (upper left corner row)
   - db starting column (upper left corner column)
   - dd outline box color (see notes)
   - (set to zero to disable outline)
   lib_buf is used to build display lines
   keyboard is assumed to be in "raw" mode, see: crt_open
   -
   example:
   - call crt_open
   - mov ebx,filename
   - mov ecx,1024 ;file buffer size
   - mov esi,boxplus ;parameter block
   - call edit_file_in_box
   - call crt_close
   - mov eax,1
   - int 80h
   -
   - [section .data]
   - filename: db 'local_file',0
   -
   - boxplus:
   - dd 30003436h ;window color
   - dd 0 ;filled in
   - dd 0 ;filled in
   - dd 0 ;scroll
   - db 50 ;columns
   - db 10 ;rows
   - db 3 ;starting row
   - db 3 ;starting column
   - dd 30003131h ;color for outline box
   -
 OUTPUT
   eax = negative system error# or positive if success
 NOTES
   source file edit_file_in_box.asm
   if the file path is relative to callers home directory
   then function env_stack must be called sometime prior
   to calling this function.
   -
   The current window width is not checked, edit_file_in_box
   will attempth display even if window size too small.
   -
   color = aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brn 34-blu 35-purple 36-cyan 37-gry
   attributes 30-normal 31-bold 34-underscore 37-inverse

------------------------------------------
170. widget/edit_text_in_box
------------------------------------------
edit_text_in_box - edit supplied string in a box
 INPUTS
   ecx = buffer end ptr
   esi = pointer to structure below
   - dd window color (see notes)
   - dd data pointer. ptr to start of string
   - dd end of data ptr, beyond last display char.
   - (a nl will be stored here by edit_text_in_box)
   - dd initial scroll left/right position
   - db columns inside box
   - db rows inside box
   - db starting row (upper left corner row)
   - db starting column (upper left corner column)
   - dd outline box color (see notes)
   - (set to zero to disable outline)
   lib_buf is used to build display lines
   keyboard is assumed to be in "raw" mode, see: crt_open
   -
   example:
   - call crt_open
   - mov ecx,buf_end ;file buffer size
   - mov esi,boxplus ;parameter block
   - call edit_file_in_box
   - call crt_close
   - mov eax,1
   - int 80h
   -
   - [section .data]
   - filename: db 'local_file',0
   -
   - boxplus:
   - dd 30003436h ;window color
   - dd box_msg ;edit data pointer
   - dd box_msg_end ;end of edit data
   - dd 0 ;scroll right/left (usually zero)
   - db 50 ;columns
   - db 10 ;rows
   - db 3 ;starting row
   - db 3 ;starting column
   - dd 30003131h ;color for outline box
   -
   - box_msg: db 'hi there im a box',0ah
   - box_msg_end: db 0ah
   - db 0,0
   - buf_end: db 0ah
   -
 OUTPUT
   eax = negative system error# or positive if success
   ebx = end of data ptr
 NOTES
   source file edit_text_in_box.asm
   -
   The current window width is not checked, edit_text_in_box
   will attempth display even if window size too small.
   -
   color = aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brn 34-blu 35-purple 36-cyan 37-gry
   attributes 30-normal 31-bold 34-underscore 37-inverse

------------------------------------------
171. widget/form
------------------------------------------
form - display and accept user inputs to fill form
 INPUTS
   esi = ptr to list of pointers:
   dd aux_process ;user process, called after each display
   dd edit_color ;colors, list of colors
   dd string_block1 ;strings, list of string fields on screen
   dd display_tbl ;display table, screen format table
   -
   A form uses one screen. It is defined by normal ascii
   text with embedded control characters. The control characters
   are:
   0 - end of table 5 - blank rest of screen
   1 - color normal 6 - string, block# follows
   2 - color field 7 - key, key# follows
   3 - color active field 8 - process, process# follows
   4 - color button 9 - end of line (eol)
   -
   -
   As the user types or moves the mouse to fill out the
   form, all data is stored in the form. Upon exit the
   form can be scanned by caller to obtain the data.
   -
   string data will be stored in the table as entered.
   button selection is indicated by color code. When selected
   the code "3" will indicate this button was selected.
   -
   table codes use negative byte values in secondary
   fields, thus, ascii characters in range of 80h+ are not available
   as text.
 OUTPUT
   eax = negative error# if problems
   eax = positive, form is filled out
   see example form file form_samp.asm
 NOTES
   file: form.asm
   function crt_open must be called before using

------------------------------------------
172. widget/make_box
------------------------------------------
make_box - display box outline
 INPUTS
   esi = pointer to structure below
   - db columns inside box
   - db rows inside box
   - db starting row
   - db starting column
   - dd box color (see notes)
   lib_buf is used to build display lines
 OUTPUT
   eax = negative system error# or positive if success
 NOTES
   source file make_box.asm
   The current window width is not checked, make_box
   will attempth display even if window size too small.
   -
   color = aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brn 34-blu 35-purple 36-cyan 37-gry
   attributes 30-normal 31-bold 34-underscore 37-inverse

------------------------------------------
173. widget/message_box
------------------------------------------
message_box - display message and wait for key press
 INPUTS
   esi = pointer to structure below
   - dd window color (see notes)
   - dd data pointer.
   - dd end of data ptr, beyond last display char
   - dd initial scroll left/right position
   - db columns inside box
   - db rows inside box
   - db starting row
   - db starting column
   - dd outline box color (see notes)
   - (set to zero to disable outline)
   lib_buf is used to build display lines
 OUTPUT
   eax = return state of lib function key_mouse1
   [kbuf] contains key press
 NOTES
   source file message_box.asm
   The current window width is not checked, message_box
   will attempth display even if window size too small.
   -
   color = aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brn 34-blu 35-purple 36-cyan 37-gry
   attributes 30-normal 31-bold 34-underscore 37-inverse

------------------------------------------
174. widget/show_box
------------------------------------------
show_box - display boxed message with optional boarder
 INPUTS
   esi = pointer to structure below
   - dd window color (see notes)
   - dd data pointer.
   - dd end of data ptr, beyond last display char
   - dd initial scroll left/right position
   - db columns inside box
   - db rows inside box
   - db starting row
   - db starting column
   - dd outline box color (see notes)
   - (set to zero to disable outline)
   lib_buf is used to build display lines
 OUTPUT
   eax = negative system error# or positive if success
 NOTES
   source file show_box.asm
   The current window width is not checked, show_box
   will attempth display even if window size too small.
   -
   color = aaxxffbb aa-attr ff-foreground bb-background
   30-blk 31-red 32-grn 33-brn 34-blu 35-purple 36-cyan 37-gry
   attributes 30-normal 31-bold 34-underscore 37-inverse
