forked from kei-en/simple_shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.h
100 lines (77 loc) · 2.37 KB
/
shell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef SHELL_H
#define SHELL_H
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <ctype.h>
#define TRUE 1
#define FALSE 0
extern char **environ;
/**
* struct list_s - singly linked list
* @str: string - (malloc'ed string)
* @next: points to the next node
*
* Description: singly linked list node structure
*/
typedef struct list_s
{
char *str;
struct list_s *next;
} list_t;
/* Main function */
int loop(char **argv);
/*memory*/
int bfree(void **ptr);
/*Delim.c*/
char **strtow(char *str, char *delim);
char **strtow3(char *str, char d);
/* Builtin functions */
void shell_exit(char ***av, int ac, ssize_t *read);
void _env(char ***av, int ac);
/* Parser */
void nl_replace(char **buffer);
ssize_t _readline(char **buffer, char ***tokens);
void process_tokens(char ***tokens, char **buffer, int count_token);
int tokens_len(ssize_t read_len, char **buffer);
/* Executer */
int _exec(char **buffer, char ***av, char *full_path, int *st);
void check_path(char ***tokens, char **path, char **av, int *cnt, int *err);
/* String tools */
int _strlen(const char *s);
char *_strcpy(char *dest, const char *src);
char *_strcat(char *dest, const char *src);
char *_strncat(char *dest, const char *src, size_t n);
char *_strdup(char *str);
int _strcmp(char *s1, char *s2);
/* Print linked list*/
void free_list(list_t *head);
size_t print_list(const list_t *h);
/* Function to get the data in the interactive shell */
int _getchar(void);
ssize_t _getline(char **lineptr, size_t *n, FILE *stream);
/* Get the value of a entorn variable */
char *_getenv(const char *name);
char *_getenv_local(const char *name, char **environ);
/*int _setenv(const char *name, const char *value, int overwrite);*/
/* Get a linked list of a current entorn variable */
list_t *_getpath(char *path, char **path_cpy);
/* Get the path into a linked list */
list_t *list_path(char **path_cpy);
/* Return the path if found an executable */
char *add_path(char ***tokens, list_t *path);
/* Prints */
void pfError(char *av, char *count, char *firstOne, char *message);
void print_err(char *str);
void _puts(int fd, char *str);
/* string-tools-adv */
char *itoa(int value, char *buffer, int base);
/*loop*/
void check_dir(char ***tokens, char **path, char **av, int *count, int *error);
#endif