-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
57 lines (51 loc) · 1.08 KB
/
error.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
47
48
49
50
51
52
53
54
55
56
57
#include "main.h"
/**
* print_error - print error when shell cannot be executed
*
* @shell: first argument of the shell interpreter
*
* @cmd: command to execute
*
* @ncmd: number of the command to execute
*/
void print_error(char *shell, char *cmd, unsigned int ncmd)
{
char msg[1024];
char *istr, numstr[15];
istr = itoa(ncmd, numstr);
*istr = '\0';
_strcpy(msg, shell);
_strcat(msg, ": ");
_strcat(msg, numstr);
_strcat(msg, ": ");
_strcat(msg, cmd);
_strcat(msg, ": ");
_strcat(msg, "not found\n");
write(2, msg, _strlen(msg));
}
/**
* exit_error - print error when shell cannot be executed
*
* @argv: args
*
* @args: args
*
* @ncmd: number of the command to execute
*/
void exit_error(char **argv, char **args, unsigned int ncmd)
{
char msg[1024];
char *istr, numstr[15];
istr = itoa(ncmd, numstr);
*istr = '\0';
_strcpy(msg, argv[0]);
_strcat(msg, ": ");
_strcat(msg, numstr);
_strcat(msg, ": ");
_strcat(msg, args[0]);
_strcat(msg, ": ");
_strcat(msg, "Illegal number: ");
_strcat(msg, args[1]);
_strcat(msg, "\n");
write(2, msg, _strlen(msg));
}