src/findlib/match.c
void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
{
   int len, j;
   struct s_included_file *inc;
   char *p;
   const char *rp;

   len = strlen(fname);

   inc =(struct s_included_file *)bmalloc(sizeof(struct s_included_file) + len + 1);
   inc->options = 0;
   inc->VerifyOpts[0] = 'V';
   inc->VerifyOpts[1] = ':';
   inc->VerifyOpts[2] = 0;

   /* prefixed = preceded with options */
   if (prefixed) {
      for (rp=fname; *rp && *rp != ' '; rp++) {
         switch (*rp) {
         case 'a':                 /* alway replace */
         case '0':                 /* no option */
            break;
         case 'f':
            inc->options |= FO_MULTIFS;
            break;
         case 'h':                 /* no recursion */
            inc->options |= FO_NO_RECURSION;
            break;
         case 'M':                 /* MD5 */
            inc->options |= FO_MD5;
            break;
         case 'n':
            inc->options |= FO_NOREPLACE;
            break;
         case 'p':                 /* use portable data format */
            inc->options |= FO_PORTABLE;
            break;
         case 'r':                 /* read fifo */
            inc->options |= FO_READFIFO;
            break;
         case 'S':
            inc->options |= FO_SHA1;
            break;
         case 's':
            inc->options |= FO_SPARSE;
            break;
         case 'm':
            inc->options |= FO_MTIMEONLY;
            break;
         case 'k':
            inc->options |= FO_KEEPATIME;
            break;
         case 'V':                  /* verify options */
            /* Copy Verify Options */
            for (j=0; *rp && *rp != ':'; rp++) {
               inc->VerifyOpts[j] = *rp;
               if (j < (int)sizeof(inc->VerifyOpts) - 1) {
                  j++;
               }
            }
            inc->VerifyOpts[j] = 0;
            break;
         case 'w':
            inc->options |= FO_IF_NEWER;
            break;
         case 'A':
            inc->options |= FO_ACL;
            break;
         case 'Z':                 /* compression */
            rp++;                   /* skip Z */
            if (*rp >= '0' && *rp <= '9') {
               inc->options |= FO_COMPRESS;
               inc->algo = COMPRESS_GZIP;
               inc->Compress_level = *rp - '0';
            }
               else if (*rp == 'o') {
               inc->options |= FO_COMPRESS;
               inc->algo = COMPRESS_LZO1X;
               inc->Compress_level = 1; /* not used with LZO */
            }
            Dmsg2(200, "Compression alg=%d level=%d\n", inc->algo, inc->Compress_level);
            break;
         case 'K':
            inc->options |= FO_NOATIME;
            break;
         case 'X':
            inc->options |= FO_XATTR;
            break;
         default:
            Emsg1(M_ERROR, 0, _("Unknown include/exclude option: %c\n"), *rp);
            break;
         }
      }
      /* Skip past space(s) */
      for ( ; *rp == ' '; rp++)
         {}
   } else {
      rp = fname;
   }

   strcpy(inc->fname, rp);
   p = inc->fname;
   len = strlen(p);
   /* Zap trailing slashes.  */
   p += len - 1;
   while (p > inc->fname && IsPathSeparator(*p)) {
      *p-- = 0;
      len--;
   }
   inc->len = len;
   /* Check for wild cards */
   inc->pattern = 0;
   for (p=inc->fname; *p; p++) {
      if (*p == '*' || *p == '[' || *p == '?') {
         inc->pattern = 1;
         break;
      }
   }
#if defined(HAVE_WIN32)
   /* Convert any \'s into /'s */
   for (p=inc->fname; *p; p++) {
      if (*p == '\\') {
         *p = '/';
      }
   }
#endif
   inc->next = NULL;
   /* Chain this one on the end of the list */
   if (!ff->included_files_list) {
      /* First one, so set head */
      ff->included_files_list = inc;
   } else {
      struct s_included_file *next;
      /* Walk to end of list */
      for (next=ff->included_files_list; next->next; next=next->next)
         { }
      next->next = inc;
   }
   Dmsg4(100, "add_fname_to_include prefix=%d compres=%d alg= %d fname=%s\n",
         prefixed, !!(inc->options & FO_COMPRESS), inc->algo, inc->fname);
}
/*
 * Add a filename to list of included files
 */
Add a filename to list of included files
Add a filename to list of included files
void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
{
   int len, j;
   struct s_included_file *inc;
   char *p;
   const char *rp;
   len = strlen(fname);
   inc =(struct s_included_file *)bmalloc(sizeof(struct s_included_file) + len + 1);
   inc->options = 0;
   inc->VerifyOpts[0] = 'V';
   inc->VerifyOpts[1] = ':';
   inc->VerifyOpts[2] = 0;
   if (prefixed) {
      for (rp=fname; *rp && *rp != ' '; rp++) {
         switch (*rp) {
         case 'a':                 
         case '0':                 
            break;
         case 'f':
            inc->options |= FO_MULTIFS;
            break;
         case 'h':                 
            inc->options |= FO_NO_RECURSION;
            break;
         case 'M':                 
            inc->options |= FO_MD5;
            break;
         case 'n':
            inc->options |= FO_NOREPLACE;
            break;
         case 'p':                 
            inc->options |= FO_PORTABLE;
            break;
         case 'r':                 
            inc->options |= FO_READFIFO;
            break;
         case 'S':
            inc->options |= FO_SHA1;
            break;
         case 's':
            inc->options |= FO_SPARSE;
            break;
         case 'm':
            inc->options |= FO_MTIMEONLY;
            break;
         case 'k':
            inc->options |= FO_KEEPATIME;
            break;
         case 'V':                  
            for (j=0; *rp && *rp != ':'; rp++) {
               inc->VerifyOpts[j] = *rp;
               if (j < (int)sizeof(inc->VerifyOpts) - 1) {
                  j++;
               }
            }
            inc->VerifyOpts[j] = 0;
            break;
         case 'w':
            inc->options |= FO_IF_NEWER;
            break;
         case 'A':
            inc->options |= FO_ACL;
            break;
         case 'Z':                 
            rp++;                   
            if (*rp >= '0' && *rp <= '9') {
               inc->options |= FO_COMPRESS;
               inc->algo = COMPRESS_GZIP;
               inc->Compress_level = *rp - '0';
            }
               else if (*rp == 'o') {
               inc->options |= FO_COMPRESS;
               inc->algo = COMPRESS_LZO1X;
               inc->Compress_level = 1; 
            }
            Dmsg2(200, "Compression alg=%d level=%d\n", inc->algo, inc->Compress_level);
            break;
         case 'K':
            inc->options |= FO_NOATIME;
            break;
         case 'X':
            inc->options |= FO_XATTR;
            break;
         default:
            Emsg1(M_ERROR, 0, _("Unknown include/exclude option: %c\n"), *rp);
            break;
         }
      }
      for ( ; *rp == ' '; rp++)
         {}
   } else {
      rp = fname;
   }
   strcpy(inc->fname, rp);
   p = inc->fname;
   len = strlen(p);
   p += len - 1;
   while (p > inc->fname && IsPathSeparator(*p)) {
      *p-- = 0;
      len--;
   }
   inc->len = len;
   inc->pattern = 0;
   for (p=inc->fname; *p; p++) {
      if (*p == '*' || *p == '[' || *p == '?') {
         inc->pattern = 1;
         break;
      }
   }
#if defined(HAVE_WIN32)
   for (p=inc->fname; *p; p++) {
      if (*p == '\\') {
         *p = '/';
      }
   }
#endif
   inc->next = NULL;
   if (!ff->included_files_list) {
      ff->included_files_list = inc;
   } else {
      struct s_included_file *next;
      for (next=ff->included_files_list; next->next; next=next->next)
         { }
      next->next = inc;
   }
   Dmsg4(100, "add_fname_to_include prefix=%d compres=%d alg= %d fname=%s\n",
         prefixed, !!(inc->options & FO_COMPRESS), inc->algo, inc->fname);
}
void add_fname_to_include_list ( FF_PKT * ff , int prefixed , const char * fname ) { int len , j ; struct s_included_file * inc ; char * p ; const char * rp ; len = strlen ( fname ) ; inc = ( struct s_included_file * ) bmalloc ( sizeof ( struct s_included_file ) + len + 1 ) ; inc -> options = 0 ; inc -> VerifyOpts [ 0 ] = ' ' ; inc -> VerifyOpts [ 1 ] = ' ' ; inc -> VerifyOpts [ 2 ] = 0 ; if ( prefixed ) { for ( rp = fname ; * rp && * rp != ' ' ; rp ++ ) { switch ( * rp ) { case ' ' : case ' ' : break ; case ' ' : inc -> options |= FO_MULTIFS ; break ; case ' ' : inc -> options |= FO_NO_RECURSION ; break ; case ' ' : inc -> options |= FO_MD5 ; break ; case ' ' : inc -> options |= FO_NOREPLACE ; break ; case ' ' : inc -> options |= FO_PORTABLE ; break ; case ' ' : inc -> options |= FO_READFIFO ; break ; case ' ' : inc -> options |= FO_SHA1 ; break ; case ' ' : inc -> options |= FO_SPARSE ; break ; case ' ' : inc -> options |= FO_MTIMEONLY ; break ; case ' ' : inc -> options |= FO_KEEPATIME ; break ; case ' ' : for ( j = 0 ; * rp && * rp != ' ' ; rp ++ ) { inc -> VerifyOpts [ j ] = * rp ; if ( j < ( int ) sizeof ( inc -> VerifyOpts ) - 1 ) { j ++ ; } } inc -> VerifyOpts [ j ] = 0 ; break ; case ' ' : inc -> options |= FO_IF_NEWER ; break ; case ' ' : inc -> options |= FO_ACL ; break ; case ' ' : rp ++ ; if ( * rp >= ' ' && * rp <= ' ' ) { inc -> options |= FO_COMPRESS ; inc -> algo = COMPRESS_GZIP ; inc -> Compress_level = * rp - ' ' ; } else if ( * rp == ' ' ) { inc -> options |= FO_COMPRESS ; inc -> algo = COMPRESS_LZO1X ; inc -> Compress_level = 1 ; } Dmsg2 ( 200 , " \n " , inc -> algo , inc -> Compress_level ) ; break ; case ' ' : inc -> options |= FO_NOATIME ; break ; case ' ' : inc -> options |= FO_XATTR ; break ; default : Emsg1 ( M_ERROR , 0 , _ ( " \n " ) , * rp ) ; break ; } } for ( ; * rp == ' ' ; rp ++ ) { } } else { rp = fname ; } strcpy ( inc -> fname , rp ) ; p = inc -> fname ; len = strlen ( p ) ; p += len - 1 ; while ( p > inc -> fname && IsPathSeparator ( * p ) ) { * p -- = 0 ; len -- ; } inc -> len = len ; inc -> pattern = 0 ; for ( p = inc -> fname ; * p ; p ++ ) { if ( * p == ' ' || * p == ' ' || * p == ' ' ) { inc -> pattern = 1 ; break ; } } #if defined ( HAVE_WIN32 ) for ( p = inc -> fname ; * p ; p ++ ) { if ( * p == ' \\ ' ) { * p = ' ' ; } } #endif inc -> next = NULL ; if ( ! ff -> included_files_list ) { ff -> included_files_list = inc ; } else { struct s_included_file * next ; for ( next = ff -> included_files_list ; next -> next ; next = next -> next ) { } next -> next = inc ; } Dmsg4 ( 100 , " \n " , prefixed , ! ! ( inc -> options & FO_COMPRESS ) , inc -> algo , inc -> fname ) ; }
Add a filename to list of included files
Add a filename to list of included files
/* prefixed = preceded with options */ /* alway replace */ /* no option */ /* no recursion */ /* MD5 */ /* use portable data format */ /* read fifo */ /* verify options */ /* Copy Verify Options */ /* compression */ /* skip Z */ /* not used with LZO */ /* Skip past space(s) */ /* Zap trailing slashes.  */ /* Check for wild cards */ /* Convert any \'s into /'s */ /* Chain this one on the end of the list */ /* First one, so set head */ /* Walk to end of list */