-
Notifications
You must be signed in to change notification settings - Fork 12
/
exclude.c
55 lines (48 loc) · 1001 Bytes
/
exclude.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
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include <sys/stat.h>
extern char *exclude_list[512];
int
check_exclude_list(char *fname)
{
int i =0;
while(exclude_list[i])
if ( !strcmp(exclude_list[i++], fname))
return 1;
return 0;
}
void
verify_paths(char *list[])
{
int i=0;
struct stat f;
while(list[i]) {
if ( lstat( list[i], &f ) == -1 )
fprintf(stderr, "verify not found: %s", list[i]);
i++;
}
}
void
get_exclude_list(char* fname, char *list[])
{
FILE *fp;
char *a, buf[1024];
size_t len;
int i =0;
fp = fopen(fname, "r");
if ( fp == NULL ) {
fprintf(stderr, "could not open: %s\n", fname);
exit(1);
}
while(fgets(buf, 1024, (FILE*) fp)) {
len = strlen(buf);
buf[len-1] = '\0';
a = (char*)malloc(len);
list[i++] = strncpy(a, buf, len);
}
list[i] = NULL;
fclose(fp);
}