home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / cdrom / mkisofs.105 / source / exclude.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  1KB  |  56 lines

  1. #include "amigadef.h"
  2. /*
  3.  * 9-Dec-93 R.-D. Marzusch, marzusch@odiehh.hanse.de:
  4.  * added 'exclude' option (-x) to specify pathnames NOT to be included in 
  5.  * CD image.
  6.  */
  7.  
  8. #include <stdio.h>
  9. #ifndef VMS
  10. #ifdef HASMALLOC_H
  11. #include <malloc.h>
  12. #else
  13. #include <stdlib.h>
  14. #endif
  15. #endif
  16. #include <string.h>
  17.  
  18. /* this allows for 1000 entries to be excluded ... */
  19. #define MAXEXCL 1000
  20. static char * excl[MAXEXCL];
  21.  
  22. void exclude(fn)
  23. char * fn;
  24. {
  25.   register int i;
  26.  
  27.   for (i=0; excl[i] && i<MAXEXCL; i++);
  28.   if (i == MAXEXCL) {
  29.     fprintf(stderr,"Can't exclude '%s' - too many entries in table\n",fn);
  30.     return;
  31.   }
  32.  
  33.  
  34.   excl[i] = (char *) malloc(strlen(fn)+1);
  35.   if (! excl[i]) {
  36.     fprintf(stderr,"Can't allocate memory for excluded filename\n");
  37.     return;
  38.   }
  39.  
  40.   strcpy(excl[i],fn);
  41. }
  42.  
  43. int is_excluded(fn)
  44. char * fn;
  45. {
  46.   /* very dumb search method ... */
  47.   register int i;
  48.  
  49.   for (i=0; excl[i] && i<MAXEXCL; i++) {
  50.     if (strcmp(excl[i],fn) == 0) {
  51.       return 1; /* found -> excluded filenmae */
  52.     }
  53.   }
  54.   return 0; /* not found -> not excluded */
  55. }
  56.