WKern
Loading...
Searching...
No Matches
shell.c File Reference
#include <KShell/filecmds.h>
#include <KShell/shell.h>
#include <fileio/fileio.h>
#include <global.h>
#include <io/kio.h>
#include <mem/kmem.h>
#include <net/virtnet.h>
#include <utils/util.h>
#include <wex/stdwex.h>

Go to the source code of this file.

Data Structures

struct  CommandEntry
 Represents an individual shell command. More...

Macros

#define NUM_COMMANDS   (sizeof(commands) / sizeof(CommandEntry))
 Number of commands available in the shell.

Typedefs

typedef void(* CommandFunc) (const char *argv[], int argc)
 Command function pointer type.

Functions

void CmdCmp (const char *argv[], int argc)
 Compares two strings using the internal shell comparison function.
void CmdHelp (const char *argv[], int argc)
 Displays built-in help information.
void CmdTst (const char *argv[], int argc)
 Executes a test WEX executable.
void CmdClear (const char *argv[], int argc)
 Clears the shell screen.
void CmdLs (const char *argv[], int argc)
 Lists FAT16 filesystem contents.
void CmdUser (const char *argv[], int argc)
 Prints the current username.
void CmdRegex (const char *argv[], int argc)
 Runs the regex test utility.
void CmdRecvPack (const char *argv[], int argc)
 Receives network packets from VirtNet (on keypress).
void CmdShutdown (const char *argv[], int argc)
 Sends shutdown signal when running under QEMU.
void CmdSetName (const char *argv[], int argc)
 Sets the username used in the shell.
void Sh ()
 The main interactive WKern shell loop.

Variables

CommandEntry commands []
 Array of all available shell commands.

Macro Definition Documentation

◆ NUM_COMMANDS

#define NUM_COMMANDS   (sizeof(commands) / sizeof(CommandEntry))

Number of commands available in the shell.

Definition at line 129 of file shell.c.

Typedef Documentation

◆ CommandFunc

typedef void(* CommandFunc) (const char *argv[], int argc)

Command function pointer type.

All shell commands must follow this function signature.

Parameters
argvArgument list
argcArgument count

Definition at line 37 of file shell.c.

Function Documentation

◆ CmdClear()

void CmdClear ( const char * argv[],
int argc )

Clears the shell screen.

Definition at line 59 of file shell.c.

◆ CmdCmp()

void CmdCmp ( const char * argv[],
int argc )

Compares two strings using the internal shell comparison function.

Definition at line 48 of file shell.c.

◆ CmdHelp()

void CmdHelp ( const char * argv[],
int argc )

Displays built-in help information.

Definition at line 50 of file shell.c.

◆ CmdLs()

void CmdLs ( const char * argv[],
int argc )

Lists FAT16 filesystem contents.

Definition at line 63 of file shell.c.

◆ CmdRecvPack()

void CmdRecvPack ( const char * argv[],
int argc )

Receives network packets from VirtNet (on keypress).

Definition at line 76 of file shell.c.

◆ CmdRegex()

void CmdRegex ( const char * argv[],
int argc )

Runs the regex test utility.

Definition at line 72 of file shell.c.

◆ CmdSetName()

void CmdSetName ( const char * argv[],
int argc )

Sets the username used in the shell.

Parameters
argv[0] = "setname", [1] = new name
argcMust be >= 2

Definition at line 98 of file shell.c.

◆ CmdShutdown()

void CmdShutdown ( const char * argv[],
int argc )

Sends shutdown signal when running under QEMU.

Definition at line 85 of file shell.c.

◆ CmdTst()

void CmdTst ( const char * argv[],
int argc )

Executes a test WEX executable.

Definition at line 54 of file shell.c.

◆ CmdUser()

void CmdUser ( const char * argv[],
int argc )

Prints the current username.

Definition at line 68 of file shell.c.

◆ Sh()

void Sh ( )

The main interactive WKern shell loop.

This loop:

  • Prompts the user for input
  • Tokenizes input into arguments
  • Looks up matching command in the command table
  • Executes the corresponding command

On failure, prints an unknown command message.

Note
This loop never exits.

Definition at line 144 of file shell.c.

Variable Documentation

◆ commands

CommandEntry commands[]
Initial value:
= {
{"cmp", CmdCmp},
{"help", CmdHelp},
{"tst", CmdTst},
{"clear", CmdClear},
{"ls", CmdLs},
{"read", Readf},
{"user", CmdUser},
{"mKfile", Mkf},
{"rm", Rm},
{"write", Writef},
{"regex", CmdRegex},
{"recvpacK", CmdRecvPack},
{"shutdown", CmdShutdown},
{"setname", CmdSetName},
}
void Readf(const char *argv[], int argc)
Read and display contents of a file from the FAT16 filesystem.
Definition filecmds.c:108
void Rm(const char *argv[], int argc)
Delete a file from the FAT16 filesystem.
Definition filecmds.c:31
void Writef(const char *argv[], int argc)
Write data to a file in the FAT16 filesystem from user input.
Definition filecmds.c:68
void Mkf(const char *argv[], int argc)
Create a new empty file on the FAT16 filesystem.
Definition filecmds.c:48
void CmdRecvPack(const char *argv[], int argc)
Receives network packets from VirtNet (on keypress).
Definition shell.c:76
void CmdHelp(const char *argv[], int argc)
Displays built-in help information.
Definition shell.c:50
void CmdShutdown(const char *argv[], int argc)
Sends shutdown signal when running under QEMU.
Definition shell.c:85
void CmdUser(const char *argv[], int argc)
Prints the current username.
Definition shell.c:68
void CmdLs(const char *argv[], int argc)
Lists FAT16 filesystem contents.
Definition shell.c:63
void CmdCmp(const char *argv[], int argc)
Compares two strings using the internal shell comparison function.
Definition shell.c:48
void CmdClear(const char *argv[], int argc)
Clears the shell screen.
Definition shell.c:59
void CmdTst(const char *argv[], int argc)
Executes a test WEX executable.
Definition shell.c:54
void CmdSetName(const char *argv[], int argc)
Sets the username used in the shell.
Definition shell.c:98
void CmdRegex(const char *argv[], int argc)
Runs the regex test utility.
Definition shell.c:72

Array of all available shell commands.

Definition at line 109 of file shell.c.