-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstr_token.c
More file actions
69 lines (63 loc) · 1.17 KB
/
str_token.c
File metadata and controls
69 lines (63 loc) · 1.17 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
61
62
63
64
65
66
67
68
69
#include "shell.h"
/**
* _strtok - .
* @str: .
* @delimiters: .
* Return: .
*/
char *_strtok(char *str, const char *delimiters)
{
return (strtok(str, delimiters));
}
/**
* _chrCheck - .
* @c: .
* @str: .
* Return: .
*/
unsigned int _chrCheck(char c, const char *str)
{
unsigned int i;
for (i = 0; str[i] != '\0'; i++)
{
if (c == str[i])
return (1);
}
return (0);
}
/**
* free_l_v - Entry point to the shell
* @line: arguements count
* @line_vector: arguements values
*/
void free_l_v(char *line, char **line_vector)
{
free(line);
free_vector(line_vector);
}
/**
* is_dir - Entry point to the shell
* @line: arguements count
* @argv: arguements count
* @counter: arguements count
* @line_vector: arguements count
* @status: arguements count
* @old_line: arguements count
* Return: is dir or not
*/
int is_dir(char *line, char **argv, int counter, char **line_vector,
int *status, char *old_line)
{
struct stat st;
if (stat(line, &st) == 0)
{
if (S_ISDIR(st.st_mode))
{
print_error(argv[0], counter, line_vector[0], PERMISSION_DENIED);
*status = PERMISSION_DENIED;
free_l_v(old_line, line_vector);
return (0);
}
}
return (-1);
}