compat.c

説明を見る。
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 int remote_protocol = 0;
00029 
00030 extern int verbose;
00031 extern int am_server;
00032 extern int inplace;
00033 extern int fuzzy_basis;
00034 extern int read_batch;
00035 extern int checksum_seed;
00036 extern int basis_dir_cnt;
00037 extern int prune_empty_dirs;
00038 extern int protocol_version;
00039 extern char *dest_option;
00040 
00041 void setup_protocol(int f_out,int f_in)
00042 {
00043         if (remote_protocol == 0) {
00044                 if (!read_batch)
00045                         write_int(f_out, protocol_version);
00046                 remote_protocol = read_int(f_in);
00047                 if (protocol_version > remote_protocol)
00048                         protocol_version = remote_protocol;
00049         }
00050         if (read_batch && remote_protocol > protocol_version) {
00051                 rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n",
00052                         remote_protocol, protocol_version);
00053                 exit_cleanup(RERR_PROTOCOL);
00054         }
00055 
00056         if (verbose > 3) {
00057                 rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n",
00058                         am_server? "Server" : "Client", remote_protocol, protocol_version);
00059         }
00060         if (remote_protocol < MIN_PROTOCOL_VERSION
00061          || remote_protocol > MAX_PROTOCOL_VERSION) {
00062                 rprintf(FERROR,"protocol version mismatch -- is your shell clean?\n");
00063                 rprintf(FERROR,"(see the rsync man page for an explanation)\n");
00064                 exit_cleanup(RERR_PROTOCOL);
00065         }
00066         if (remote_protocol < OLD_PROTOCOL_VERSION) {
00067                 rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n",
00068                         am_server? "Client" : "Server");
00069         }
00070         if (protocol_version < MIN_PROTOCOL_VERSION) {
00071                 rprintf(FERROR, "--protocol must be at least %d on the %s.\n",
00072                         MIN_PROTOCOL_VERSION, am_server? "Server" : "Client");
00073                 exit_cleanup(RERR_PROTOCOL);
00074         }
00075         if (protocol_version > PROTOCOL_VERSION) {
00076                 rprintf(FERROR, "--protocol must be no more than %d on the %s.\n",
00077                         PROTOCOL_VERSION, am_server? "Server" : "Client");
00078                 exit_cleanup(RERR_PROTOCOL);
00079         }
00080 
00081         if (protocol_version < 29) {
00082                 if (fuzzy_basis) {
00083                         rprintf(FERROR,
00084                             "--fuzzy requires protocol 29 or higher"
00085                             " (negotiated %d).\n",
00086                             protocol_version);
00087                         exit_cleanup(RERR_PROTOCOL);
00088                 }
00089 
00090                 if (basis_dir_cnt && inplace) {
00091                         rprintf(FERROR,
00092                             "%s with --inplace requires protocol 29 or higher"
00093                             " (negotiated %d).\n",
00094                             dest_option, protocol_version);
00095                         exit_cleanup(RERR_PROTOCOL);
00096                 }
00097 
00098                 if (basis_dir_cnt > 1) {
00099                         rprintf(FERROR,
00100                             "Using more than one %s option requires protocol"
00101                             " 29 or higher (negotiated %d).\n",
00102                             dest_option, protocol_version);
00103                         exit_cleanup(RERR_PROTOCOL);
00104                 }
00105 
00106                 if (prune_empty_dirs) {
00107                         rprintf(FERROR,
00108                             "--prune-empty-dirs requires protocol 29 or higher"
00109                             " (negotiated %d).\n",
00110                             protocol_version);
00111                         exit_cleanup(RERR_PROTOCOL);
00112                 }
00113         }
00114 
00115         if (am_server) {
00116                 if (!checksum_seed)
00117                         checksum_seed = time(NULL);
00118                 write_int(f_out, checksum_seed);
00119         } else {
00120                 checksum_seed = read_int(f_in);
00121         }
00122 }

rsyncに対してSat Dec 5 19:45:40 2009に生成されました。  doxygen 1.4.7