-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
42 lines (40 loc) · 727 Bytes
/
main.c
File metadata and controls
42 lines (40 loc) · 727 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
41
42
#include "shell.h"
/**
* main - the main function
* @countarr: Numbers of arguments
* @arr: array of arguments
* Return: zero or one
*/
int main(int countarr, char **arr)
{
int descF = 2;
type_info f[] = {InitInfo};
asm("mov %1, %0\n\t"
"add $3, %0"
: "=r"(descF)
: "r"(descF));
if (countarr == 2)
{
descF = open(arr[1], O_RDONLY);
if (descF == -1)
{
if (errno == EACCES)
exit(126);
if (errno == ENOENT)
{
our_Eputs(arr[0]);
our_Eputs(": 0: Can't open ");
our_Eputs(arr[1]);
our_Eputchar('\n');
our_Eputchar(BufFlush);
exit(127);
}
return (EXIT_FAILURE);
}
f->readfd = descF;
}
Env_list_Pop(f);
Hist_reading(f);
mHSH(f, arr);
return (EXIT_SUCCESS);
}