Basic Solution File System - BSFS
Loading...
Searching...
No Matches
browser_bsfs.h File Reference

Public interface for the interactive BSFS browser (shell). More...

Macros

#define PATH_MAX   4096

Functions

char * browser_read_line ()
 Read a single line from standard input.
char ** browser_split_line (char *line)
 Split a command line into whitespace-delimited tokens.
int browser_execute (FILE *file, superblock_t *sb, char **args)
 Dispatch a parsed command to its implementation.
void browser_loop (FILE *file, superblock_t *sb)
 Interactive read-eval-print loop (REPL) for the BSFS browser.

Detailed Description

Public interface for the interactive BSFS browser (shell).

Declares the main entry points used by the CLI program that allows users to interact with a BSFS-formatted image. The browser reads commands from standard input, tokenizes them and dispatches to the command table.

Key responsibilities:

  • Read user input lines (blocking) and split into tokens
  • Execute commands through the registered command table
  • Maintain the main REPL loop while updating the displayed prompt

Function Documentation

◆ browser_execute()

int browser_execute ( FILE * file,
superblock_t * sb,
char ** args )

Dispatch a parsed command to its implementation.

Looks up the command name in the built-in command table and invokes the matching function. Unknown commands print a short error message.

Parameters
fileOpen filesystem image.
sbLoaded superblock.
argsTokenized argv-like vector (args[0] is the command name).
Returns
0 to exit the REPL; 1 to continue.

◆ browser_loop()

void browser_loop ( FILE * file,
superblock_t * sb )

Interactive read-eval-print loop (REPL) for the BSFS browser.

Prints a prompt, reads input, tokenizes and executes commands until exit.

Parameters
fileOpen filesystem image.
sbLoaded superblock.

◆ browser_read_line()

char * browser_read_line ( )

Read a single line from standard input.

Allocates a buffer and returns a NUL-terminated line suitable for tokenizing. The caller is responsible for freeing the returned pointer.

Returns
Newly allocated string with the input line.

◆ browser_split_line()

char ** browser_split_line ( char * line)

Split a command line into whitespace-delimited tokens.

Tokenizes the given mutable buffer in-place and returns a NULL-terminated array of pointers to the tokens. The array itself must be freed by the caller; the token strings live inside the original buffer.

Parameters
lineWritable buffer containing the input line to split.
Returns
NULL-terminated argv-like vector of token pointers.