-
Notifications
You must be signed in to change notification settings - Fork 0
/
holberton.h
88 lines (72 loc) · 2.1 KB
/
holberton.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
#ifndef _SHELL_HOLBERTON_
#define _SHELL_HOLBERTON_
#define UNUSED(x) (void)(x)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <limits.h>
#include <signal.h>
/**** Estructura con las posibles variables que vamos a usar ****/
/**
* struct variables - variables
* @array_tokens: array of tokens(arguments)
* @buffer: buffer of command
* @status: to handle exit status
* @argv: gets arguments at opening of shell
* @counter: counts commands entered
*/
typedef struct variables
{
char **array_tokens;
char *buffer;
int status;
char **argv;
int counter;
char **env;
} vars_t;
/**
* struct builtins - struct for the builtin functions
* @name: name of builtin command
* @f: function for corresponding builtin
*/
typedef struct builtins
{
char *name;
void (*f)(vars_t *);
} builtins_t;
/******Some String operations and manipulation******/
char *_strdup(char *strtodup);
int _strcmpr(char *strcmp1, char *strcmp2);
char *_strcat(char *strc1, char *strc2);
ssize_t _puts(char *str);
int _strlen(char *str);
void print_str(char *str, int new_line);
int _write_char(char c);
int print_number(int n);
/*** BUILTINGS PROTOTYPES ****/
void (*check_for_builtins(vars_t *vars))(vars_t *vars);
void new_exit(vars_t *vars);
void _env(vars_t *vars);
void new_setenv(vars_t *vars);
void new_unsetenv(vars_t *vars);
/** functions related to tokenizer **/
char **tokenizer(char *buffer, char *delimiter);
unsigned int check_if_match(char c, const char *str);
char **_realloc(char **ptr, size_t *size);
char *new_strtok(char *str, const char *delim);
/** functions related ask external shell, ask the path**/
void check_for_path(vars_t *vars);
/** function to handle error messages, used to help exit function*/
void _puts_error(char *str);
void prints_error_msg(vars_t *vars, char *msg);
char *integer_converter(unsigned int count);
/** function to help exit builting*/
int _atoi(char *str);
/** functions de help env builting*/
/*this to get enviroment*/
char **make_enviroment(char **env);
#endif /* _SHELL_HOLBERTON_ */