home *** CD-ROM | disk | FTP | other *** search
/ Dream 49 / Amiga_Dream_49.iso / beos / utils / mkisofs-1.000 / mkisofs-1.11-beos / match.c < prev    next >
C/C++ Source or Header  |  1997-04-09  |  1KB  |  57 lines

  1. /*
  2.  * 27-Mar-96: Jan-Piet Mens <jpm@mens.de>
  3.  * added 'match' option (-m) to specify regular expressions NOT to be included
  4.  * in the CD image.
  5.  */
  6.  
  7. static char rcsid[] ="$Id: match.c,v 1.2 1997/02/23 16:10:42 eric Rel $";
  8.  
  9. #include <stdio.h>
  10. #ifndef VMS
  11. #ifdef HAVE_MALLOC_H
  12. #include <malloc.h>
  13. #else
  14. #include <stdlib.h>
  15. #endif
  16. #endif
  17. #include <string.h>
  18. #include "match.h"
  19.  
  20. #define MAXMATCH 1000
  21. static char *mat[MAXMATCH];
  22.  
  23. void add_match(fn)
  24. char * fn;
  25. {
  26.   register int i;
  27.  
  28.   for (i=0; mat[i] && i<MAXMATCH; i++);
  29.   if (i == MAXMATCH) {
  30.     fprintf(stderr,"Can't exclude RE '%s' - too many entries in table\n",fn);
  31.     return;
  32.   }
  33.  
  34.  
  35.   mat[i] = (char *) malloc(strlen(fn)+1);
  36.   if (! mat[i]) {
  37.     fprintf(stderr,"Can't allocate memory for excluded filename\n");
  38.     return;
  39.   }
  40.  
  41.   strcpy(mat[i],fn);
  42. }
  43.  
  44. int matches(fn)
  45. char * fn;
  46. {
  47.   /* very dumb search method ... */
  48.   register int i;
  49.  
  50.   for (i=0; mat[i] && i<MAXMATCH; i++) {
  51.     if (fnmatch(mat[i], fn, FNM_FILE_NAME) != FNM_NOMATCH) {
  52.       return 1; /* found -> excluded filenmae */
  53.     }
  54.   }
  55.   return 0; /* not found -> not excluded */
  56. }
  57.