-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.c
More file actions
40 lines (36 loc) · 940 Bytes
/
main.c
File metadata and controls
40 lines (36 loc) · 940 Bytes
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
/*
** EPITECH PROJECT, 2020
** Bistromatic
** File description:
** main
*/
#include "./include/my.h"
#include <stdlib.h>
#include <unistd.h>
void sign_error(char *str);
void unique_symbol(char **av, char *buff);
int usage(void);
char *eval_expr(char const *str, char **av);
int main(int ac, char **av)
{
char buff[my_getnbr(av[3]) + 1];
int offset = 0;
int len;
if (ac == 2 && my_strcmp(av[1], "-h") == 0)
return (usage());
if (ac == 4 && my_strlen(av[2]) == 7) {
while ((len = read(0, buff + offset, my_getnbr(av[3]) - offset)) > 0)
offset = offset + len;
buff[offset] = '\0';
if (len < 0) {
my_putstr_error(SYNTAX_ERROR_MSG);
return (EXIT_READ);
}
unique_symbol(av, buff);
sign_error(buff);
my_putstr(eval_expr(buff, av));
return (0);
}
my_putstr_error(SYNTAX_ERROR_MSG);
return (EXIT_BASE);
}