Update of /cvsroot/radmind/radmind In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv23190 Modified Files: Makefile.in command.c fsdiff.c ktcheck.c lfdiff.c list.h transcript.c transcript.h twhich.c Log Message: Merged radmind-1-10-0-exclude-branch. Index: transcript.h =================================================================== RCS file: /cvsroot/radmind/radmind/transcript.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** transcript.h 30 May 2007 18:11:49 -0000 1.41 --- transcript.h 3 Nov 2007 15:25:45 -0000 1.42 *************** *** 10,14 **** #define T_NEGATIVE 2 #define T_SPECIAL 3 - #define T_EXCLUDE 4 #define T_MOVE_TRAN 1 --- 10,13 ---- *************** *** 34,37 **** --- 33,37 ---- extern int skip; extern int cksum; + extern int fs_minus; extern FILE *outtran; extern char *path_prefix; *************** *** 61,69 **** }; ! int transcript( char *, struct stat *, char *, struct applefileinfo * ); void transcript_init( char *kfile, int location ); struct transcript *transcript_select( void ); void transcript_parse( struct transcript * ); void transcript_free( void ); void t_print( struct pathinfo *, struct transcript *, int ); char *hardlink( struct pathinfo * ); --- 61,70 ---- }; ! int transcript( char *, struct stat *, char *, struct applefileinfo *, int ); void transcript_init( char *kfile, int location ); struct transcript *transcript_select( void ); void transcript_parse( struct transcript * ); void transcript_free( void ); + int t_exclude( char *path ); void t_print( struct pathinfo *, struct transcript *, int ); char *hardlink( struct pathinfo * ); Index: Makefile.in =================================================================== RCS file: /cvsroot/radmind/radmind/Makefile.in,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** Makefile.in 31 Jul 2007 14:15:21 -0000 1.106 --- Makefile.in 3 Nov 2007 15:25:45 -0000 1.107 *************** *** 59,63 **** FSDIFF_OBJ= version.o fsdiff.o argcargv.o transcript.o llist.o code.o \ hardlink.o cksum.o base64.o pathcmp.o radstat.o applefile.o \ ! list.o KTCHECK_OBJ= version.o ktcheck.o argcargv.o retr.o base64.o code.o \ --- 59,63 ---- FSDIFF_OBJ= version.o fsdiff.o argcargv.o transcript.o llist.o code.o \ hardlink.o cksum.o base64.o pathcmp.o radstat.o applefile.o \ ! list.o wildcard.o KTCHECK_OBJ= version.o ktcheck.o argcargv.o retr.o base64.o code.o \ *************** *** 80,84 **** LFDIFF_OBJ= version.o lfdiff.o argcargv.o connect.o retr.o cksum.o \ progress.o base64.o applefile.o code.o tls.o pathcmp.o \ ! transcript.o list.o radstat.o hardlink.o mkprefix.o REPO_OBJ= version.o repo.o report.o argcargv.o connect.o code.o tls.o --- 80,84 ---- LFDIFF_OBJ= version.o lfdiff.o argcargv.o connect.o retr.o cksum.o \ progress.o base64.o applefile.o code.o tls.o pathcmp.o \ ! transcript.o list.o radstat.o hardlink.o mkprefix.o wildcard.o REPO_OBJ= version.o repo.o report.o argcargv.o connect.o code.o tls.o *************** *** 86,90 **** TWHICH_OBJ= version.o twhich.o argcargv.o transcript.o llist.o code.o \ hardlink.o cksum.o base64.o pathcmp.o radstat.o applefile.o \ ! list.o LSORT_OBJ= version.o lsort.o pathcmp.o code.o argcargv.o --- 86,90 ---- TWHICH_OBJ= version.o twhich.o argcargv.o transcript.o llist.o code.o \ hardlink.o cksum.o base64.o pathcmp.o radstat.o applefile.o \ ! list.o wildcard.o LSORT_OBJ= version.o lsort.o pathcmp.o code.o argcargv.o Index: twhich.c =================================================================== RCS file: /cvsroot/radmind/radmind/twhich.c,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** twhich.c 14 Apr 2006 21:17:13 -0000 1.42 --- twhich.c 3 Nov 2007 15:25:45 -0000 1.43 *************** *** 19,22 **** --- 19,23 ---- #include "pathcmp.h" #include "list.h" + #include "wildcard.h" const EVP_MD *md; *************** *** 38,41 **** --- 39,43 ---- extern struct transcript *tran_head; extern struct list *special_list; + extern struct list *exclude_list; int cmp = 0, match = 0; *************** *** 56,59 **** --- 58,76 ---- } + /* check exclude list */ + if ( exclude_list->l_count > 0 ) { + for ( node = list_pop_head( exclude_list ); node != NULL; + node = list_pop_head( exclude_list )) { + if ( wildcard( node->n_path, pattern, case_sensitive )) { + printf( "# Exclude\n" ); + printf( "# exclude pattern: %s\n", node->n_path ); + if ( !displayall ) { + goto done; + } + } + free( node ); + } + } + for ( tran = tran_head; tran->t_next != NULL; tran = tran->t_next ) { Index: transcript.c =================================================================== RCS file: /cvsroot/radmind/radmind/transcript.c,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** transcript.c 31 Aug 2007 15:28:54 -0000 1.120 --- transcript.c 3 Nov 2007 15:25:45 -0000 1.121 *************** *** 27,30 **** --- 27,31 ---- #include "largefile.h" #include "list.h" + #include "wildcard.h" int read_kfile( char *kfile, int location ); *************** *** 40,43 **** --- 41,45 ---- static struct list *kfile_list; struct list *special_list; + struct list *exclude_list; char *path_prefix = NULL; *************** *** 45,48 **** --- 47,52 ---- int skip; int cksum; + int fs_minus; + int exclude_warnings = 0; FILE *outtran; *************** *** 255,258 **** --- 259,264 ---- if ( print_minus ) { + /* set fs_minus so we can handle excluded files in dirs to be deleted */ + fs_minus = 1; fprintf( outtran, "- " ); } *************** *** 549,552 **** --- 555,574 ---- } + int + t_exclude( char *path ) + { + struct node *cur; + + if ( list_size( exclude_list ) > 0 ) { + for ( cur = exclude_list->l_head; cur != NULL; cur = cur->n_next ) { + if ( wildcard( cur->n_path, path, case_sensitive )) { + return( 1 ); + } + } + } + + return( 0 ); + } + /* * Loop through the list of transcripts and compare each *************** *** 610,614 **** int ! transcript( char *path, struct stat *st, char *type, struct applefileinfo *afinfo ) { struct pathinfo pi; --- 632,637 ---- int ! transcript( char *path, struct stat *st, char *type, ! struct applefileinfo *afinfo, int parent_minus ) { struct pathinfo pi; *************** *** 619,622 **** --- 642,647 ---- struct transcript *tran = NULL; + fs_minus = 0; + /* * path is NULL when we've been called after the filesystem has been *************** *** 624,627 **** --- 649,671 ---- */ if ( path != NULL ) { + /* + * check for exclude match first to avoid any unnecessary work. + * special files still have highest precedence. + */ + if ( t_exclude( path ) && !parent_minus ) { + if ( list_size( special_list ) <= 0 + || list_check( special_list, path ) == 0 ) { + if ( exclude_warnings ) { + fprintf( stderr, "Warning: excluding %s\n", path ); + } + + /* move the transcripts ahead */ + tran = transcript_select(); + transcript_parse( tran ); + + return( 0 ); + } + } + strcpy( pi.pi_name, path ); pi.pi_stat = *st; *************** *** 711,718 **** break; - case T_EXCLUDE : - /* read the whole file, keep a list of possibly wild pathnames */ - break; - default : break; --- 755,758 ---- *************** *** 826,829 **** --- 866,873 ---- exit( 2 ); } + if (( exclude_list = list_new()) == NULL ) { + perror( "list_new" ); + exit( 2 ); + } if ( read_kfile( kfile, location ) != 0 ) { exit( 2 ); *************** *** 969,975 **** case 'x': /* exclude */ if ( minus ) { ! t_remove( T_EXCLUDE, av[ 1 ] ); } else { ! t_new( T_EXCLUDE, fullpath, av[ 1 ], kfile ); } break; --- 1013,1024 ---- case 'x': /* exclude */ if ( minus ) { ! list_remove( exclude_list, av[ 1 ] ); } else { ! if ( !list_check( exclude_list, av[ 1 ] )) { ! if ( list_insert( exclude_list, av[ 1 ] ) != 0 ) { ! perror( "list_insert" ); ! return( -1 ); ! } ! } } break; *************** *** 1015,1019 **** * filesystem to compare against. */ ! transcript( NULL, NULL, NULL, NULL ); while ( tran_head != NULL ) { --- 1064,1068 ---- * filesystem to compare against. */ ! transcript( NULL, NULL, NULL, NULL, 0 ); while ( tran_head != NULL ) { Index: list.h =================================================================== RCS file: /cvsroot/radmind/radmind/list.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** list.h 29 May 2007 23:17:48 -0000 1.6 --- list.h 3 Nov 2007 15:25:45 -0000 1.7 *************** *** 18,22 **** }; ! #define list_size( list ) ((list)->l_count) struct list * list_new( void ); --- 18,22 ---- }; ! #define list_size( list ) ((list) ? (list)->l_count : 0 ) struct list * list_new( void ); Index: command.c =================================================================== RCS file: /cvsroot/radmind/radmind/command.c,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** command.c 30 May 2007 18:11:49 -0000 1.138 --- command.c 3 Nov 2007 15:25:45 -0000 1.139 *************** *** 1403,1406 **** --- 1403,1407 ---- case 's': + case 'x': break; Index: fsdiff.c =================================================================== RCS file: /cvsroot/radmind/radmind/fsdiff.c,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** fsdiff.c 6 May 2006 22:13:18 -0000 1.78 --- fsdiff.c 3 Nov 2007 15:25:45 -0000 1.79 *************** *** 28,36 **** void fs_walk( char *, struct stat *, char *, struct applefileinfo *, ! int, int ); int dodots = 0; int dotfd; int lastpercent = -1; int case_sensitive = 1; const EVP_MD *md; --- 28,37 ---- void fs_walk( char *, struct stat *, char *, struct applefileinfo *, ! int, int, int ); int dodots = 0; int dotfd; int lastpercent = -1; int case_sensitive = 1; + extern int exclude_warnings; const EVP_MD *md; *************** *** 80,84 **** void fs_walk( char *path, struct stat *st, char *type, struct applefileinfo *afinfo, ! int start, int finish ) { DIR *dir; --- 81,85 ---- void fs_walk( char *path, struct stat *st, char *type, struct applefileinfo *afinfo, ! int start, int finish, int pdel ) { DIR *dir; *************** *** 87,90 **** --- 88,92 ---- int len; int count = 0; + int del_parent; float chunk, f = start; char temp[ MAXPATHLEN ]; *************** *** 99,103 **** /* call the transcript code */ ! switch ( transcript( path, st, type, afinfo )) { case 2 : /* negative directory */ for (;;) { --- 101,105 ---- /* call the transcript code */ ! switch ( transcript( path, st, type, afinfo, pdel )) { case 2 : /* negative directory */ for (;;) { *************** *** 126,130 **** } ! fs_walk( temp, &st0, &type0, &afinfo0, start, finish ); } else { return; --- 128,132 ---- } ! fs_walk( temp, &st0, &type0, &afinfo0, start, finish, pdel ); } else { return; *************** *** 144,147 **** --- 146,161 ---- } + /* + * store whether object is to be deleted. if we get here, object + * is a directory, which should mean that if fs_minus == 1 all + * child objects should be removed as well. tracking this allows + * us to zap excluded objects whose parent dir will be deleted. + * + * del_parent is passed into subsequent fs_walk and transcript + * calls, where * it's checked when considering whether to + * exclude an object. + */ + del_parent = fs_minus; + if ( case_sensitive ) { cmp = strcmp; *************** *** 223,227 **** fs_walk( temp, &cur->fl_stat, &cur->fl_type, &cur->fl_afinfo, ! (int)f, (int)( f + chunk )); f += chunk; --- 237,241 ---- fs_walk( temp, &cur->fl_stat, &cur->fl_type, &cur->fl_afinfo, ! (int)f, (int)( f + chunk ), del_parent ); f += chunk; *************** *** 252,256 **** outtran = stdout; ! while (( c = getopt( argc, argv, "%1ACc:IK:o:Vv" )) != EOF ) { switch( c ) { case '%': --- 266,270 ---- outtran = stdout; ! while (( c = getopt( argc, argv, "%1ACc:IK:o:VvW" )) != EOF ) { switch( c ) { case '%': *************** *** 302,305 **** --- 316,323 ---- exit( 0 ); + case 'W': /* print a warning when excluding an object */ + exclude_warnings = 1; + break; + case '?': printf( "bad %c\n", c ); *************** *** 329,333 **** if ( errflag || ( argc - optind != 1 )) { ! fprintf( stderr, "usage: %s { -C | -A | -1 } [ -IV ] ", argv[ 0 ] ); fprintf( stderr, "[ -K command ] " ); fprintf( stderr, "[ -c checksum ] [ -o file [ -%% ] ] path\n" ); --- 347,351 ---- if ( errflag || ( argc - optind != 1 )) { ! fprintf( stderr, "usage: %s { -C | -A | -1 } [ -IVW ] ", argv[ 0 ] ); fprintf( stderr, "[ -K command ] " ); fprintf( stderr, "[ -c checksum ] [ -o file [ -%% ] ] path\n" ); *************** *** 355,359 **** transcript_init( kfile, K_CLIENT ); ! fs_walk( path_prefix, &st, &type, &afinfo, 0, finish ); if ( finish > 0 ) { --- 373,377 ---- transcript_init( kfile, K_CLIENT ); ! fs_walk( path_prefix, &st, &type, &afinfo, 0, finish, 0 ); if ( finish > 0 ) { Index: ktcheck.c =================================================================== RCS file: /cvsroot/radmind/radmind/ktcheck.c,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** ktcheck.c 31 Jul 2007 02:55:36 -0000 1.125 --- ktcheck.c 3 Nov 2007 15:25:45 -0000 1.126 *************** *** 1022,1025 **** --- 1022,1029 ---- } break; + + case 'x': + /* exclude patterns have no associated transcript */ + break; } } Index: lfdiff.c =================================================================== RCS file: /cvsroot/radmind/radmind/lfdiff.c,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** lfdiff.c 31 Jul 2007 02:55:36 -0000 1.61 --- lfdiff.c 3 Nov 2007 15:25:45 -0000 1.62 *************** *** 38,41 **** --- 38,42 ---- #include "transcript.h" #include "code.h" + #include "wildcard.h" void (*logger)( char * ) = NULL; *************** *** 48,51 **** --- 49,53 ---- int create_prefix = 0; int quiet = 1; + int excluded = 0; const EVP_MD *md; SSL_CTX *ctx; *************** *** 57,64 **** { extern struct transcript *tran_head; - extern struct list *special_list; struct stat st; struct transcript *tran; - struct node *node; int cmp = 0; --- 59,64 ---- *************** *** 74,91 **** outtran = stdout; ! /* identical to code in twhich.c */ ! ! /* check special list */ ! if ( special_list->l_count > 0 ) { ! for ( node = list_pop_head( special_list ); node != NULL; ! node = list_pop_head( special_list )) { ! if ( pathcasecmp( node->n_path, file, case_sensitive ) == 0 ) { ! printf( "# Special\n" ); ! printf( "special.T:\n" ); ! printf( "%s\n", node->n_path ); ! free( node ); ! break; ! } ! } } --- 74,81 ---- outtran = stdout; ! /* check exclude list */ ! if ( t_exclude( file )) { ! excluded = 1; ! return( NULL ); } *************** *** 157,161 **** while (( c = getopt ( argc, argv, ! "h:Ip:P:rST:u:Vvw:x:y:z:Z:bitcefnC:D:sX:" )) != EOF ) { switch( c ) { case 'I': --- 147,151 ---- while (( c = getopt ( argc, argv, ! "h:IK:p:P:rST:u:Vvw:x:y:z:Z:bitcefnC:D:sX:" )) != EOF ) { switch( c ) { case 'I': *************** *** 167,170 **** --- 157,164 ---- break; + case 'K': + kfile = optarg; + break; + case 'p': if (( port = htons ( atoi( optarg ))) == 0 ) { *************** *** 310,314 **** if (( tran = precedent_transcript( kfile, file, K_CLIENT )) == NULL ) { ! fprintf( stderr, "%s not found in any transcript\n", file ); exit( 2 ); } --- 304,312 ---- if (( tran = precedent_transcript( kfile, file, K_CLIENT )) == NULL ) { ! if ( excluded ) { ! fprintf( stderr, "%s: excluded\n", file ); ! } else { ! fprintf( stderr, "%s not found in any transcript\n", file ); ! } exit( 2 ); } |