-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshell.h
More file actions
92 lines (92 loc) · 2.63 KB
/
shell.h
File metadata and controls
92 lines (92 loc) · 2.63 KB
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
#ifndef _SHELL_H
#define _SHELL_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
extern char **environ;
/**
* struct buses - carries auxiliar variables
* @stat: exit status
* @count: counts promts pinted
* @arg0: argv[0]
*
* Description: carries variables through the program
*
*/
typedef struct buses
{
int stat;
int count;
char *arg0;
} bus_t;
/**
* struct builtin - built-in functions
* @input: string - function name (built-in)
* @type: pointer ti built-in function
*
* Description: holds and match names with built-in
* functions
*/
typedef struct builtin
{
char *input;
int (*type)(char **argv, char *line, bus_t *bus);
} built_t;
/**
* struct paths - singly linked list
* @path: string - (malloc'ed string) - single path
* @len: length of the string
* @next: points to the next node
*
* Description: singly linked list node structure
* holds single paths from variable PATH
*/
typedef struct paths
{
char *path;
int len;
struct paths *next;
} path_t;
int print_env(int i);
void ignore_comments(char *line);
/*ssize_t read_textfile(const char *filename, size_t letters);*/
void print_exit_error2(char **argv, bus_t *bus);
int _strlen(char *s);
int _atoi(char *s);
int print_notfound(char **argv, char **argvex, bus_t *bus, char *line);
char *_realloc(char *ptr, unsigned int old_size, unsigned int new_size);
char **create_argv(char *str, int len);
char **_strtok(char *str, char *delim);
int cmpstr(char *haystack, char *needle);
void rmstr(char *str, char *substr);
char *str_concat(char *s1, char *s2);
char *_strdup(char *str);
char *_getenv(char *str);
int check_bltin(char **argv, char *line, bus_t *bus);
int f_exit(char **argv, char *line, bus_t *bus);
int f_env(char **argv, char *line, bus_t *bus);
int f_setenv(char **argv, char *line, bus_t *bus);
int _strcmp(char *s1, char *s2);
ssize_t getstdin(char **lineptr);
path_t *create_list(char *str);
int add_node_end(path_t **head, char *str);
size_t print_list(path_t *h);
void free_grid(char **grid);
void free_list(path_t *head_path);
int _putchar(char *c, unsigned int lenght);
int print_string(char *str);
char *number_to_string(int number, char base);
int print_integer(int number);
void reverse_str(char *str, int size, char keep_first);
int execute(char **argv, char *name, char *line);
int check_argv(char **argv, char **argvex, bus_t *bus, char *line);
void print_exit_error(char **argv, bus_t *bus, int argmt);
int cp_env(void);
int create_file(const char *filename, char *text_content);
int append_text_to_file(const char *filename, char *text_content);
#endif