00001 /* 00002 Copyright (C) Andrew Tridgell 1996 00003 Copyright (C) Paul Mackerras 1996 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 /** 00021 * @file compat.c 00022 * 00023 * Compatibility routines for older rsync protocol versions. 00024 **/ 00025 00026 #include "rsync.h" 00027 00028 extern int am_server; 00029 00030 extern int preserve_links; 00031 extern int preserve_perms; 00032 extern int preserve_devices; 00033 extern int preserve_uid; 00034 extern int preserve_gid; 00035 extern int preserve_times; 00036 extern int always_checksum; 00037 extern int checksum_seed; 00038 00039 00040 extern int remote_version; 00041 extern int verbose; 00042 00043 extern int read_batch; /* dw */ 00044 extern int write_batch; /* dw */ 00045 00046 void setup_protocol(int f_out,int f_in) 00047 { 00048 if (remote_version == 0) { 00049 if (am_server) { 00050 remote_version = read_int(f_in); 00051 write_int(f_out,PROTOCOL_VERSION); 00052 } else { 00053 write_int(f_out,PROTOCOL_VERSION); 00054 remote_version = read_int(f_in); 00055 } 00056 } 00057 00058 if (remote_version < MIN_PROTOCOL_VERSION || 00059 remote_version > MAX_PROTOCOL_VERSION) { 00060 rprintf(FERROR,"protocol version mismatch - is your shell clean?\n"); 00061 rprintf(FERROR,"(see the rsync man page for an explanation)\n"); 00062 exit_cleanup(RERR_PROTOCOL); 00063 } 00064 00065 if (remote_version >= 12) { 00066 if (am_server) { 00067 if (read_batch || write_batch) /* dw */ 00068 checksum_seed = 32761; 00069 else 00070 checksum_seed = time(NULL); 00071 write_int(f_out,checksum_seed); 00072 } else { 00073 checksum_seed = read_int(f_in); 00074 } 00075 } 00076 00077 checksum_init(); 00078 } 00079