tiny-shell 0.2
A mini shell project aiming to gain knowledge about Win32 and Linux API
|
#include "args.h"
#include "../core/io_wrap.h"
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Macros | |
#define | QUOTATION_MARK_STR "\"" |
Enumerations | |
enum | { MAGIC_TOKEN = '!' , QUOTATION_MARK = '\"' } |
Functions | |
os_char * | transform_quotes (const os_char *str) |
Transform whitespaces inside quotes into MAGIC_TOKEN | |
void | split_by_whitespaces (const os_char *str, struct args *buffer) |
void | verify_background (struct args *args) |
void | re_transform_arg (os_char *arg) |
Transform MAGIC_TOKEN inside arg into space. | |
bool | args_init_from_str (struct args *obj, const os_char *input) |
Build args from an input string. | |
void | args_destroy (struct args *obj) |
struct args * | args_deep_copy (const struct args *obj) |
Deep copy the object, including arguments string. | |
void | args_deep_copy_init (struct args *obj, const struct args *source) |
Initialize the object by deep copying source | |
bool | is_whitespace (os_char c) |
! | |
#define QUOTATION_MARK_STR "\"" |
Definition at line 13 of file args.c.
Referenced by transform_quotes().
Deep copy the object, including arguments string.
Definition at line 145 of file args.c.
References args::argc, args::argv, and args::background.
Initialize the object by deep copying source
Definition at line 163 of file args.c.
References args::argc, args::argv, and args::background.
Referenced by cmd_init_from_str().
void args_destroy | ( | struct args * | obj | ) |
Definition at line 135 of file args.c.
References args::argc, and args::argv.
Referenced by cmd_destroy(), and cmd_init_from_str().
bool args_init_from_str | ( | struct args * | obj, |
const os_char * | input ) |
Build args
from an input string.
true
if initialization succeeded, false
otherwise Definition at line 117 of file args.c.
References args::argc, args::argv, args::background, re_transform_arg(), split_by_whitespaces(), transform_quotes(), and verify_background().
Referenced by cmd_init_from_str().
bool is_whitespace | ( | os_char | c | ) |
!
Helper function
Definition at line 177 of file args.c.
Referenced by split_by_whitespaces(), and transform_quotes().
void re_transform_arg | ( | os_char * | arg | ) |
Transform MAGIC_TOKEN
inside arg
into space.
Definition at line 108 of file args.c.
References MAGIC_TOKEN.
Referenced by args_init_from_str().
void split_by_whitespaces | ( | const os_char * | str, |
struct args * | buffer ) |
Definition at line 52 of file args.c.
References args::argc, args::argv, format_error(), is_whitespace(), and MAX_ARGC.
Referenced by args_init_from_str().
os_char * transform_quotes | ( | const os_char * | str | ) |
Transform whitespaces inside quotes into MAGIC_TOKEN
Definition at line 16 of file args.c.
References format_error(), is_whitespace(), MAGIC_TOKEN, QUOTATION_MARK, and QUOTATION_MARK_STR.
Referenced by args_init_from_str().
void verify_background | ( | struct args * | args | ) |
Definition at line 87 of file args.c.
References args::argc, args::argv, and args::background.
Referenced by args_init_from_str().