OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
kshell.c File Reference
#include "kshell.h"
#include <ctype.h>
#include <stddef.h>
#include "console.h"
#include "io.h"
#include "keyboard.h"
#include "keymap.h"
#include "kshell_cmds.h"
#include "string.h"

Macros

#define KSHELL_MAX_ARGS   64
 The maximum number of arguments.
 
#define KSHELL_MAX_ARG_LEN   256
 The maximum length of an argument.
 
#define KSHELL_MAX_LINE_LEN   80
 The maximum length of a command line.
 
#define KSHELL_MAX_HISTORY_LEN   1000
 The shell's maximum history length.
 

Functions

static void parse_cmd (putchar putc, char *line)
 Processes a line.
 
static void process_line (putchar putc)
 Reads a line and processes it.
 
void shell_loop (putchar putc)
 Runs the shell loop.
 
void putchars (putchar putc, const char *str)
 Writes a string of characters to the console.
 

Variables

static const char * WHITESPACES = " \t\n\r"
 
static char kshell_history [KSHELL_MAX_HISTORY_LEN]
 
static uint16_t kshell_history_length = 0
 

Macro Definition Documentation

◆ KSHELL_MAX_ARG_LEN

#define KSHELL_MAX_ARG_LEN   256

The maximum length of an argument.

◆ KSHELL_MAX_ARGS

#define KSHELL_MAX_ARGS   64

The maximum number of arguments.

◆ KSHELL_MAX_HISTORY_LEN

#define KSHELL_MAX_HISTORY_LEN   1000

The shell's maximum history length.

◆ KSHELL_MAX_LINE_LEN

#define KSHELL_MAX_LINE_LEN   80

The maximum length of a command line.

Function Documentation

◆ parse_cmd()

static void parse_cmd ( putchar  putc,
char *  line 
)
static

Processes a line.

Parameters
putcThe putchar function.
lineLine to be parsed.
Note
Arbitrary choice of max arguments and token sizes, should be rewritten later (when we have malloc?)

◆ process_line()

static void process_line ( putchar  putc)
static

Reads a line and processes it.

Parameters
putcThe putchar function.

◆ putchars()

void putchars ( putchar  putc,
const char *  str 
)

Writes a string of characters to the console.

Parameters
putcThe putchar function.
strString to be written.

◆ shell_loop()

void shell_loop ( void(*)(char)  putc)

Runs the shell loop.

Parameters
putcThe putchar function.

Variable Documentation

◆ kshell_history

char kshell_history[KSHELL_MAX_HISTORY_LEN]
static

◆ kshell_history_length

uint16_t kshell_history_length = 0
static

◆ WHITESPACES

const char* WHITESPACES = " \t\n\r"
static