-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_functions.c
61 lines (55 loc) · 1.23 KB
/
add_functions.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
58
59
60
61
#include "holberton.h"
/**
* _strcmp - compares two strings
* @s1: First string
* @s2: Second string
* Return: 0 if strings match. -1 Otherwise.
*/
int _strcmp(char *s1, char *s2)
{
int i;
if (_strlen(s1) != _strlen(s2))
return (-1);
for (i = 0; s1[i] != '\0'; i++)
{
if (s1[i] != s2[i])
return (-1);
}
return (0);
}
/**
* error_printing - Prints a message error when a comand is not found.
* @count: A counter keeping track of the number of commands run on the shell.
* @av: The name of the program running the shell.
* @command: The specific command not being found.
*/
void error_printing(char *av, int count, char *command)
{
print_str(av, 1);
print_str(": ", 1);
print_number(count);
print_str(": ", 1);
print_str(command, 1);
}
/**
* exec_error - Prints exec errors.
* @av: The name of the program running the shell.
* @count: Keeps track of how many commands have been entered.
* @tmp_command: The command that filed.
*/
void exec_error(char *av, int count, char *tmp_command)
{
error_printing(av, count, tmp_command);
print_str(": ", 1);
perror("");
exit(1);
}
/**
* simple_error - Prints and exec simple error.
* Return: always void.
*/
void simple_error(void)
{
perror("Fatal Error");
exit(100);
}