-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_error.c
More file actions
60 lines (51 loc) · 1.03 KB
/
Copy path_error.c
File metadata and controls
60 lines (51 loc) · 1.03 KB
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
#include "main.h"
/**
* _error - Function to print out message
* @msg: Message to display
* @argv: Argument vector to catch program name
* Return: No return value
*/
void _error(char *msg, char **argv)
{
_puts(argv[0]);
_puts(": ");
_puts(msg);
}
/**
* err_msg - Printing custom error message to stderr
* @fd: File descriptor
* @num_cmd: Number of commands written so far
* @s1: First string - name of program
* @s2: Name of command
* @s3: custom message to be printed
* Return: Void
*/
void err_msg(int fd, int num_cmd, char *s1, char *s2, char *s3)
{
char num_stat;
int temp = num_cmd;
while (*s1)
{
write(fd, &(*s1), 1), s1++;
}
write(fd, ": ", 2);
if (num_cmd < 10)
{
num_stat = num_cmd + '0';
write(fd, &(num_stat), 1);
}
else
{
num_stat = (num_cmd / 10) + '0';
write(fd, &(num_stat), 1);
num_stat = (temp % 10) + '0';
write(fd, &(num_stat), 1);
}
write(fd, ": ", 2);
while (*s2)
write(fd, &(*s2), 1), s2++;
write(2, ": ", 2);
while (*s3)
write(fd, &(*s3), 1), s3++;
write(fd, "\n", 1);
}