Frecon code: frecon.pal
From PROSE Programming Language - Wiki
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % File Reconnaissance Tool % Author: Mark R. Bannister % Date: 6/Oct/2017 % % Maintains a simple database of file statistics under a given path % and provides some basic query functionality with them % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ~Module EQUS {[frecon]} ._init func/def [main], &[.main] func/def [get_enter], &[.get_enter] local/rtn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main entry-point % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .main % % Set-up pointers to commonly used objects and attributes % reg/load P14, ![.prose.sys.io.stdin], P15, ![.prose.sys.io.stdout] attr/load P12, [psStreamIn], P13, [psStreamOut] % % Change stdout to be unbuffered % attr/mod P15, [psStreamBufferMode], [IONBF] % % Load or create new database % func/bcall NULL, [db_load] % % Launch main menu % .main_loop local/jsr &[.display_banner] local/jsr &[.get_choice] % % Convert option number to index offset in functions segment % and call the appropriate function name % op/sub P0, P0, #1 reg/load P1, (&[~functions], P0) func/bcall NULL, P1 local/jmp &[.main_loop] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Display banner % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .display_banner reg/load PUSH, (&[~menu_header]) reg/load PUSH, (PULL) attr/add P15, P13, PULL var/addr PUSH, [db_name] attr/copy PUSH, PULL, [psString] attr/mvadd P15, P13, [ Database: ], PULL, [\n] func/bcall PUSH, [db_num_records] attr/mvadd P15, P13, [ # Records: ], PULL, [\n] attr/copy PUSH, ![-scan_dir], [psString] attr/mvadd P15, P13, [ Scan Path: ], PULL, [\n] reg/load PUSH, (&[~menu]) reg/load PUSH, (PULL) attr/add P15, P13, PULL local/rtn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Get a choice from stdin and return in P0 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .get_choice % % Display user prompt % reg/load PUSH, (&[~prompt]) reg/load PUSH, (PULL) attr/add P15, P13, PULL % % Grab one line of input % .get_stdin attr/copy P0, P14, P12 % % Test for Q/q after forcing to uppercase % reg/jmpeq &[.get_stdin], P0, NULL % Ignore Ctrl+D reg/load A, (P0, #0) opa/shr #0x18 opa/and #0x5f reg/jmpeq &[.quit], A, #0x51 % % Test for hidden D/d option to dump the nexus % reg/jmpeq &[.dump], A, #0x44 % % Convert to an index number % Any errors - go back to collect input again % reg/conv P0, P0, #10 reg/jmpeq &[.get_error], P0, #0 reg/jmpgt &[.get_error], P0, #9 % % Output a new line before returning % attr/add P15, P13, [\n] local/rtn .get_error % % Sound bell on error % attr/add P15, P13, [\a] local/jmp &[.get_choice] .dump % % Run tools.nxdump on the entire nexus, requires nxdump to have % been pre-loaded at start-up % func/bcall NULL, [tools.nxdump], ![.prose] local/jmp &[.get_choice] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Quit program % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .quit attr/add P15, P13, [\n] func/rtn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Prompt for user to press ENTER and wait % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .get_enter % % Display enter prompt % reg/load PUSH, (&[~enter]) reg/load PUSH, (PULL) attr/add ![.prose.sys.io.stdout], [psStreamOut], PULL % % Grab one line of input % attr/copy NULL, ![.prose.sys.io.stdin], [psStreamIn] func/rtn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Menu options % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ~menu_header EQUS {[\f \ ___\ \ ___\ \/ \ \/ \ | File | | ReCON | \_____/ \_____/ ]} ~menu EQUS {[ 1. Scan Filesystem 6. Newest Files 2. Biggest Files 7. Oldest Files 3. Smallest Files 8. File Changes 4. Owners Report 9. Dump Database 5. Groups Report q. Quit ]} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % User prompt % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ~prompt EQUS {[Please select (1-9, q): ]} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Press ENTER prompt % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ~enter EQUS {[\nPress ENTER to return to the menu.]} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function names to call in order of the menu items % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ~functions EQUS {[scan], [biggest], [smallest], [owners], [groups], [newest], [oldest], [changes], [dump]}