patch zlib check
[platform/upstream/cdrkit.git] / genisoimage / exclude.c
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)exclude.c        1.9 04/03/04 joerg */
14 /*
15  * 9-Dec-93 R.-D. Marzusch, marzusch@odiehh.hanse.de:
16  * added 'exclude' option (-x) to specify pathnames NOT to be included in
17  * CD image.
18  */
19
20 #include <mconfig.h>
21 #include <stdio.h>
22 #include <stdxlib.h>
23 #include <strdefs.h>
24 #include <standard.h>
25 #include <schily.h>
26
27
28 /* this allows for 1000 entries to be excluded ... */
29 #define MAXEXCL         1000
30
31 static char             *excl[MAXEXCL];
32
33 void    exclude(char *fn);
34 int     is_excluded(char *fn);
35
36
37 void
38 exclude(char *fn)
39 {
40         register int    i;
41
42         for (i = 0; excl[i] && i < MAXEXCL; i++)
43                 ;
44
45         if (i == MAXEXCL) {
46                 fprintf(stderr,
47                         "Can't exclude '%s' - too many entries in table\n",
48                                                                 fn);
49                 return;
50         }
51         excl[i] = (char *) malloc(strlen(fn) + 1);
52         if (excl[i] == NULL) {
53 #ifdef  USE_LIBSCHILY
54                 errmsg("Can't allocate memory for excluded filename\n");
55 #else
56                 fprintf(stderr,
57                         "Can't allocate memory for excluded filename\n");
58 #endif
59                 return;
60         }
61         strcpy(excl[i], fn);
62 }
63
64 int
65 is_excluded(char *fn)
66 {
67         register int    i;
68
69         /*
70          * very dumb search method ...
71          */
72         for (i = 0; excl[i] && i < MAXEXCL; i++) {
73                 if (strcmp(excl[i], fn) == 0) {
74                         return (1);     /* found -> excluded filenmae */
75                 }
76         }
77         return (0);     /* not found -> not excluded */
78 }