// // omi.h // // Oliver Fromme // @(#)$Id: omi.h,v 1.36 1998/12/04 09:04:47 olli Exp $ // #ifndef HAVE_OMI_H #define HAVE_OMI_H static const char cvsid_omi_h[] = "@(#)$Id: omi.h,v 1.36 1998/12/04 09:04:47 olli Exp $"; #include #include #include "utils.h" #include "bas.h" #include "lst.h" #include "dir.h" #include "stt.h" #define OMI_VERSION "20030719" // // Debug flags. // // This is a large bunch of flags, so it is possible to // select the kind (and amount) of debug autput very exactly. // However, these are the most useful ones: // // REPORT Report only on changes to the local mirror, // and why they have changed. This will not // produce any output at all if no updates have // to be done. // // PROGRESS Display progress for long data transfers. // // VERBOSE Verbosely report mirroring activity and FTP // server input/output per file. // // STATS Print final summary statistics if mirroring // activity took place. This will not produce // any output at all if no updates had to be // done. // // STATISTICS Print statistics for every remote / local // directory tree pair, as well as final summary // statistics. // // ALL Report on everything. Warning: this can // generate several megabytes of debug output! // // NONE Report on nothing, be quiet while mirroring. // // The default is REPORT + STATS. Note that error messages // will _always_ be printed, no matter what debug flags are // used. // #define DEBUG_ALL 0xfffffff // everything #define DEBUG_NONE 0x0000000 // nothing #define DEBUG_OUTPUT 0x0000001 // output to the FTP server #define DEBUG_INPUT 0x0000002 // input from the FTP server #define DEBUG_CREATE_DIRS 0x0000004 // creation of local directories #define DEBUG_CREATE_FILES 0x0000008 // creation of local plain files #define DEBUG_CREATE_LINKS 0x0000010 // creation of local symlinks #define DEBUG_REMOVE_DIRS 0x0000020 // removal of local directories #define DEBUG_REMOVE_FILES 0x0000040 // removal of local plain files #define DEBUG_REMOVE_LINKS 0x0000080 // removal of local symlinks #define DEBUG_REASONING 0x0000100 // reasons for file transfers #define DEBUG_RETRY 0x0000200 // FTP reconnects/retries #define DEBUG_REPORT 0x0000400 // report on mirroring #define DEBUG_STATS 0x0000800 // summary statistics (if activity) #define DEBUG_STATISTICS 0x0001000 // per-pair statistics (always) #define DEBUG_DNS 0x0002000 // DNS look-ups #define DEBUG_CONNECT 0x0004000 // network connections #define DEBUG_XFERRATE 0x0008000 // transfer rates per file #define DEBUG_MULTI 0x0010000 // multi-line server replies & ls -lR #define DEBUG_PARSE 0x0020000 // parse-tree of the remote ls -lR #define DEBUG_CHX 0x0040000 // chmod(), chgrp(), rename() #define DEBUG_REMOTE_REGEX 0x0080000 // remote regular expression matches #define DEBUG_LOCAL_REGEX 0x0100000 // local regular expression matches #define DEBUG_PROGRESS 0x0200000 // progress display #define DEBUG_DIRS (DEBUG_CREATE_DIRS | DEBUG_REMOVE_DIRS) #define DEBUG_FILES (DEBUG_CREATE_FILES | DEBUG_REMOVE_FILES) #define DEBUG_LINKS (DEBUG_CREATE_LINKS | DEBUG_REMOVE_LINKS) #define DEBUG_CREATE (DEBUG_CREATE_DIRS | DEBUG_CREATE_FILES \ | DEBUG_CREATE_LINKS) #define DEBUG_REMOVE (DEBUG_REMOVE_DIRS | DEBUG_REMOVE_FILES \ | DEBUG_REMOVE_LINKS) #define DEBUG_SERVER (DEBUG_OUTPUT | DEBUG_INPUT | DEBUG_XFERRATE \ | DEBUG_DNS | DEBUG_CONNECT | DEBUG_RETRY \ | DEBUG_PROGRESS) #define DEBUG_MIRROR (DEBUG_CREATE | DEBUG_REMOVE | DEBUG_REASONING) #define DEBUG_VERBOSE (DEBUG_SERVER | DEBUG_MIRROR) #define DEBUG_REGEX (DEBUG_REMOTE_REGEX | DEBUG_LOCAL_REGEX) // // Mirror flags. The default is 0 (i.e. no flags at all). // // GETOLDERFILES Normally, if a file on the local host has // a newer datestamp than the remote file, it // not be retrieved. If you set this flag, // it will be retrieved if the timestamp is // different (no matter whether it's older or // newer). // // PRESERVEDIRS Normally, if a local directory does not // exist anymore on the remote server, it is // removed locally (including all files and // subdirectories in it). If you set this // flag, it will be preserved, and a warning // will be printed (unless you have set the // debug flags to DEBUG_NONE). You will then // have to remove that directory manually, or // (if you want to keep it) add it to the // local exclude list. This is useful if the // remote server is unreliable (i.e. if parts // of it disappear sometimes and then are // back the next day). // // IGNORETIME Ignore the timestamps of remote and local // files when mirroring. I.e. only retrieve // a remote file if it doesn't already exist // locally, or if the file sizes mismatch. // Useful if some stupid cronjob touches all // files on the remote site, even though // their contents don't change. // // DONTTOUCH Do not update the time stamps of local files // to be the same as those of the remote files. // This only makes sense if you also use the // "IgnoreTime" option flag, or the "deviation" // config entry (-t option). // // LOCALTIME Assume that the time stamps of the remote // server are local time. The default (if // this flag is not set) is to use GMT. Most // UNIX-based FTP servers seem to use GMT, so // this flag should not be used normally. // (Note that RFC 959 does not specify the // time zone.) // // EXCLUDEALL Exclude all files by default. In this // case you have to use "Include" (or the -y // command line option) to include files for // mirroring. // // TEST This is for testing / debugging purposes. // If this flag is set, no modifications are // performed (no retrieval or deletion of // files). Useful to test exclusion patterns // etc. without the risk to kill any files if // something doesn't work as expected. // // ACTIVE Use "active" FTP transfers (the default is // to use "passive" FTP transfers). This can // be useful if the FTP server is behind a // firewall, of if the passive mode support // of the server is broken. // // NOSTAT Do not use the "STAT" command to retrieve // a directory listing (use "LIST" instead). // "STAT" (the default) is more efficient, // but some FTP servers don't implement it // correctly. Note that omi automatically // falls back to "LIST", but sometimes it // requires a rather long timeout, so better // use this flag if needed. // // PERMISSIONS Normally, new files and directories will // get permissions according to the umask of // the omi process, or use the mode specified // by the user (-m option). But when this // flag is set, omi tries to parse and copy // the permission modes from the FTP server. // #define MIRROR_NONE 0x00000 // nothing #define MIRROR_GETOLDERFILES 0x00001 // update old files from remote site #define MIRROR_PRESERVEDIRS 0x00002 // don't kill local directories #define MIRROR_IGNORETIME 0x00004 // ignore time when mirroring #define MIRROR_DONTTOUCH 0x00008 // Don't set local mtimes #define MIRROR_LOCALTIME 0x00010 // handle remote time as non-GMT #define MIRROR_EXCLUDEALL 0x00020 // exclude everything by default #define MIRROR_TEST 0x00040 // test only (don't mirror) #define MIRROR_ACTIVE 0x00080 // use active transfer mode #define MIRROR_NOSTAT 0x00100 // avoid "stat" command #define MIRROR_PERMISSIONS 0x00200 // copy permissions from server // // Struct for configuration information. // Timeouts are in seconds, 0 means no timeout. // Deviation: If a file has an mtime difference within this // deviation, it will not be mirrored. // typedef struct { char *pidfilemask; // PID filename (with % macros) char *pidfilename; // PID filename (expanded) int pidfiledesc; // PID file FD char *login, *email; // FTP login and email (password) char *account; // FTP account information char *local_addr; // local address to bind to (or NULL) unsigned long debug; // debug flags, see above unsigned long flags; // mirror flags, see above unsigned int timeout_dns; // timeout for DNS look-ups unsigned int timeout_connect; // timeout for server connect unsigned int timeout_command; // timeout for server commands unsigned int timeout_read; // timeout for reading from server unsigned int maxsretry; // max. number of soft retries unsigned int maxhretry; // max. number of hard retries unsigned int maxremfail; // max. number of remote failures unsigned int maxlocfail; // max. number of local failures unsigned int reopendelay; // delay before re-open: start value unsigned int reopeninc; // delay before re-open: increment unsigned int reopenmax; // delay before re-open: maximum unsigned long deviation; // maximum mtime deviation int removelimit; // local remove limit (percent) int newest; // mirror newest n files (if n > 0) mode_t perms_dir; // permission modes for files mode_t perms_file; // permission modes for directories gid_t newgroup; // new group ownership bool changegroup; // TRUE == change the group bool havereporthead; // TRUE == printed report header simple_list *exclude; // list of remote (mirror) exclude REs simple_list *locexclude; // list of local (delete) exclude REs } omiconf; // // Global configuration, and pointer to the current configuration. // extern omiconf globalconfig; extern omiconf *cc; // // The time when the mirror started. // extern time_t now; extern struct tm start; // // Struct for storing directory pair (remote/local) information. // typedef struct { char *localdir; // local directory name char *remotedir; // remote directory name omifile *omidir; // remote dir struct omiconf *conf; // configuration info for this pair omistats *stats; // statistics info for this pair } omipair; // // Current directory pair. // extern omipair *cp; // // Struct for storing remote site information. // typedef struct { char *name; // name of the site unsigned int port; // port number (control connection) omiconf *conf; // configuration info for this site omistats *stats; // statistics info for this site int num; // number of directory pairs omipair *pair; // list of directory pairs } omisite; // // Current site. // extern omisite *ct; #endif // HAVE_OMI_H //--