tiny-shell 0.2
A mini shell project aiming to gain knowledge about Win32 and Linux API
Loading...
Searching...
No Matches
env.h File Reference
#include "../os/type.h"
#include "res.h"
Include dependency graph for env.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

enum run_result run_set_env (const os_char *name, const os_char *val)
 Set current process's environment variable.
 
enum run_result run_unset_env (const os_char *name)
 Unset current process's environment variable.
 
enum run_result run_get_all_env ()
 Set current process's environment variable.
 
enum run_result run_get_env (const os_char *name)
 Set current process's environment variable.
 

Function Documentation

◆ run_get_all_env()

enum run_result run_get_all_env ( )

Set current process's environment variable.

Definition at line 15 of file env.c.

15 {
16 os_char *env = get_all_shell_env_display();
17 if(!env) {
18 return RUN_FAILED;
19 } else {
20 format_output("%s\n", env);
21 free(env);
22 return RUN_OK;
23 }
24}
void format_output(char *fmt,...)
Used format_xxx instead of printf and such for uniform output.
Definition io_wrap.c:80
os_char * get_all_shell_env_display()
Get all current environment variable.
@ RUN_OK
Definition res.h:7
@ RUN_FAILED
Definition res.h:9

References format_output(), get_all_shell_env_display(), RUN_FAILED, and RUN_OK.

Referenced by invoke_runner().

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

◆ run_get_env()

enum run_result run_get_env ( const os_char * name)

Set current process's environment variable.

Definition at line 26 of file env.c.

26 {
27 os_char buffer[ENV_VAR_BUFFER_SIZE];
28 if(!get_shell_env(name, ENV_VAR_BUFFER_SIZE, buffer)) {
29 return RUN_FAILED;
30 }
31 format_output("%s\n", buffer);
32 return RUN_OK;
33}
#define ENV_VAR_BUFFER_SIZE
Definition config.h:8
bool get_shell_env(const os_char *var, unsigned int buffer_size, os_char *buffer)
Get value of an an environment variable.

References ENV_VAR_BUFFER_SIZE, format_output(), get_shell_env(), RUN_FAILED, and RUN_OK.

Referenced by invoke_runner().

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

◆ run_set_env()

enum run_result run_set_env ( const os_char * name,
const os_char * val )

Set current process's environment variable.

Definition at line 7 of file env.c.

7 {
8 return set_shell_env(name, val) ? RUN_OK : RUN_FAILED;
9}
bool set_shell_env(const os_char *name, const os_char *val)
Set environment variable of the shell process.

References RUN_FAILED, RUN_OK, and set_shell_env().

Referenced by invoke_runner().

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

◆ run_unset_env()

enum run_result run_unset_env ( const os_char * name)

Unset current process's environment variable.

Definition at line 11 of file env.c.

11 {
12 return unset_shell_env(name) ? RUN_OK : RUN_FAILED;
13}
bool unset_shell_env(const os_char *name)
Unset environment variable of the shell process.

References RUN_FAILED, RUN_OK, and unset_shell_env().

Referenced by invoke_runner().

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