-
Notifications
You must be signed in to change notification settings - Fork 1
/
aux_error2.c
executable file
·69 lines (64 loc) · 1.48 KB
/
aux_error2.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
62
63
64
65
66
67
68
69
#include "main.h"
/**
* error_env - error message for env in get_env.
* @datash: data relevant (counter, arguments)
* Return: error message.
*/
char *error_env(data_shell *datash)
{
int length;
char *error;
char *ver_str;
char *msg;
ver_str = aux_itoa(datash->counter);
msg = ": Unable to add/remove from environment\n";
length = _strlen(datash->av[0]) + _strlen(ver_str);
length += _strlen(datash->args[0]) + _strlen(msg) + 4;
error = malloc(sizeof(char) * (length + 1));
if (error == 0)
{
free(error);
free(ver_str);
return (NULL);
}
_strcpy(error, datash->av[0]);
_strcat(error, ": ");
_strcat(error, ver_str);
_strcat(error, ": ");
_strcat(error, datash->args[0]);
_strcat(error, msg);
_strcat(error, "\0");
free(ver_str);
return (error);
}
/**
* error_path_126 - error message for path and failure denied permission.
* @datash: data relevant (counter, arguments).
*
* Return: The error string.
*/
char *error_path_126(data_shell *datash)
{
int length;
char *ver_str;
char *error;
ver_str = aux_itoa(datash->counter);
length = _strlen(datash->av[0]) + _strlen(ver_str);
length += _strlen(datash->args[0]) + 24;
error = malloc(sizeof(char) * (length + 1));
if (error == 0)
{
free(error);
free(ver_str);
return (NULL);
}
_strcpy(error, datash->av[0]);
_strcat(error, ": ");
_strcat(error, ver_str);
_strcat(error, ": ");
_strcat(error, datash->args[0]);
_strcat(error, ": Permission denied\n");
_strcat(error, "\0");
free(ver_str);
return (error);
}