--- generator.c	11 Jun 2004 07:40:51 -0000	1.87
+++ generator.c	15 Jun 2004 15:35:48 -0000
@@ -39,6 +39,7 @@ extern int opt_ignore_existing;
 extern int csum_length;
 extern int ignore_times;
 extern int size_only;
+extern OFF_T max_size;
 extern int io_timeout;
 extern int protocol_version;
 extern int always_checksum;
@@ -345,6 +346,10 @@ void recv_generator(char *fname, struct 
 		    && verbose && f_out != -1)
 			rprintf(FINFO,"%s/\n",fname);
 		return;
+	} else if (max_size && file->length > max_size) {
+		if (verbose > 1)
+			rprintf(FINFO, "%s is over max-size\n", fname);
+		return;
 	}
 
 	if (preserve_links && S_ISLNK(file->mode)) {
--- options.c	7 Jun 2004 22:05:22 -0000	1.156
+++ options.c	15 Jun 2004 15:35:48 -0000
@@ -90,6 +90,7 @@ int delete_after = 0;
 int only_existing = 0;
 int opt_ignore_existing = 0;
 int max_delete = 0;
+OFF_T max_size = 0;
 int ignore_errors = 0;
 int modify_window = 0;
 int blocking_io = -1;
@@ -139,6 +140,7 @@ char *batch_prefix = NULL;
 
 static int daemon_opt;   /* sets am_daemon after option error-reporting */
 static int modify_window_set;
+static char *max_size_arg;
 
 /** Local address to bind.  As a character string because it's
  * interpreted by the IPv6 layer: should be a numeric IP4 or ip6
@@ -310,7 +312,7 @@ void usage(enum logcode F)
 enum {OPT_VERSION = 1000, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
       OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED, OPT_LINK_DEST,
       OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
-      OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT,
+      OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT, OPT_MAX_SIZE,
       OPT_REFUSED_BASE = 9000};
 
 static struct poptOption long_options[] = {
@@ -364,6 +366,7 @@ static struct poptOption long_options[] 
   {"rsh",             'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
   {"block-size",      'B', POPT_ARG_INT,    &block_size, 0, 0, 0 },
   {"max-delete",       0,  POPT_ARG_INT,    &max_delete, 0, 0, 0 },
+  {"max-size",         0,  POPT_ARG_STRING, &max_size_arg,  OPT_MAX_SIZE, 0, 0 },
   {"timeout",          0,  POPT_ARG_INT,    &io_timeout, OPT_TIMEOUT, 0, 0 },
   {"temp-dir",        'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
   {"compare-dest",     0,  POPT_ARG_STRING, &compare_dest, 0, 0, 0 },
@@ -580,6 +583,32 @@ int parse_arguments(int *argc, const cha
 			checksum_seed = FIXED_CHECKSUM_SEED;
 			break;
 
+		case OPT_MAX_SIZE:
+			for (arg = max_size_arg; isdigit(*arg); arg++) {}
+			if (*arg == '.')
+				for (arg++; isdigit(*arg); arg++) {}
+			if (arg == max_size_arg)
+				arg = "?";
+			switch (*arg) {
+			case 'k': case 'K':
+				max_size = atof(max_size_arg) * 1024;
+				break;
+			case 'm': case 'M':
+				max_size = atof(max_size_arg) * 1024*1024;
+				break;
+			case 'g': case 'G':
+				max_size = atof(max_size_arg) * 1024*1024*1024;
+				break;
+			case '\0':
+				break;
+			default:
+				rprintf(FERROR,
+					"--max-size value is invalid.\n");
+				exit_cleanup(RERR_SYNTAX);
+				break;
+			}
+			break;
+
 		case OPT_TIMEOUT:
 			if (io_timeout && io_timeout < select_timeout)
 				select_timeout = io_timeout;
@@ -884,6 +913,11 @@ void server_options(char **args,int *arg
 		args[ac++] = arg;
 	}
 
+	if (max_size && am_sender) {
+		args[ac++] = "--max-size";
+		args[ac++] = max_size_arg;
+	}
+
 	if (batch_prefix) {
 		char *r_or_w = write_batch ? "write" : "read";
 		if (asprintf(&arg, "--%s-batch=%s", r_or_w, batch_prefix) < 0)
