-
Notifications
You must be signed in to change notification settings - Fork 0
/
printErr.c
46 lines (42 loc) · 892 Bytes
/
printErr.c
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
#include "main.h"
/**
* _print_error - print error.
* @data: data.
* @errorcode: errorcode.
*
* Return: return bytes.
*/
int _print_error(int errorcode, data_of_program *data)
{
char num_string[10] = {'\0'};
_long_to_string((long) data->exec_counter, num_string, 10);
if (errorcode == 2 || errorcode == 3)
{
_printe(data->program_name);
_printe(": ");
_printe(num_string);
_printe(": ");
_printe(data->tokens[0]);
if (errorcode == 2)
_printe(": Illegal number: ");
else
_printe(": can't cd to ");
_printe(data->tokens[1]);
_printe("\n");
}
else if (errorcode == 127)
{
_printe(data->program_name);
_printe(": No such file or directory\n");
}
else if (errorcode == 126)
{
_printe(data->program_name);
_printe(": ");
_printe(num_string);
_printe(": ");
_printe(data->command_name);
_printe(": Permission denied\n");
}
return (0);
}