LF OS
Hobby operating system for amd64 with high ambitions
Loading...
Searching...
No Matches
shell.c File Reference
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "input.h"
#include "history.h"
#include "variables.h"
#include <unistd.h>
#include <dirent.h>
+ Include dependency graph for shell.c:

Go to the source code of this file.

Data Structures

struct  command
 

Macros

#define BUILT_IN(name)   { #name, name ## _built_in}
 

Functions

void DBG (char *m)
 
char * prog_in_path (char *p, char *path)
 
int version_built_in (int argc, char **argv)
 
int exit_built_in (int argc, char **argv)
 
int cmd_not_found_built_in (int argc, char **argv)
 
int echo_built_in (int argc, char **argv)
 
int parse_argv (char **argv, char *raw)
 
int built_in_exec (int argc, char **argv)
 
int klsh_main ()
 

Variables

command command_list []
 

Macro Definition Documentation

◆ BUILT_IN

#define BUILT_IN (   name)    { #name, name ## _built_in}

Definition at line 64 of file shell.c.

Function Documentation

◆ built_in_exec()

int built_in_exec ( int  argc,
char **  argv 
)

Definition at line 224 of file shell.c.

References command_list, command::handler, and strcmp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmd_not_found_built_in()

int cmd_not_found_built_in ( int  argc,
char **  argv 
)

Definition at line 80 of file shell.c.

◆ DBG()

void DBG ( char *  m)

Definition at line 13 of file shell.c.

◆ echo_built_in()

int echo_built_in ( int  argc,
char **  argv 
)

Definition at line 86 of file shell.c.

◆ exit_built_in()

int exit_built_in ( int  argc,
char **  argv 
)

Definition at line 76 of file shell.c.

◆ klsh_main()

int klsh_main ( )

Definition at line 237 of file shell.c.

References add_hist_entry(), assign_variable(), built_in_exec(), free(), get_raw_buffer(), hist_push(), memset(), shell_variable::name, parse_argv(), prog_in_path(), shell_variable_add(), shell_variable_get(), strlen(), and shell_variable::value.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_argv()

int parse_argv ( char **  argv,
char *  raw 
)

Definition at line 107 of file shell.c.

References malloc(), memcpy(), memset(), shell_variable_get(), and strlen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prog_in_path()

char * prog_in_path ( char *  p,
char *  path 
)

Definition at line 21 of file shell.c.

References free(), malloc(), memset(), strcmp(), strcpy(), and strlen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ version_built_in()

int version_built_in ( int  argc,
char **  argv 
)

Definition at line 70 of file shell.c.

Variable Documentation

◆ command_list

command command_list[]
Initial value:
= {
BUILT_IN(echo),
BUILT_IN(exit),
}
char * history[64]
Definition history.c:10
uint32_t version
Definition elf.h:13
#define BUILT_IN(name)
Definition shell.c:64

Definition at line 97 of file shell.c.