📄 console_fe.c
字号:
} else { printf( _("] failed:\n%s\n"), error ); } }}void fe_synching( const struct site_file_t *file ) { if( quiet ) { printf( "%s\n", file->rel_local ); } else { if( file->dir ) { if( file->diff != file_new ) { printf( _("Creating %s/: "), file->rel_local+1 ); } else { printf( _("Deleting %s/: "), file->rel_local+1 ); } } else { switch( file->diff ) { case file_changed: case file_deleted: printf( _("Downloading %s: ["), file->rel_local+1 ); break; case file_new: printf( _("Deleting %s: "), file->rel_local+1 ); break; case file_moved: printf( _("Moving %s->%s: "), file->rel_local+1, file->old->directory ); break; default: break; } } fflush( stdout ); }}void fe_synched( const struct site_file_t *file, const bool success, const char *error ) { if( quiet ) return; if( file->dir || (file->diff!=file_changed && file->diff!=file_deleted) ) { if( success ) { printf( _("done.\n") ); } else { printf( _("failed:\n%s\n"), error ); } } else { if( success ) { printf( _("] done.\n") ); } else { printf( _("] failed:\n%s\n"), error ); } }}void fe_transfer_progress( size_t num, size_t total ) { if( quiet > 0 ) return; putchar( '.' ); fflush( stdout );}void fe_connection( fe_conn_status status ) {}void fe_fetch_found( const struct site_file_t *file ) { if( file->dir ) { printf( _("Directory: %s/\n"), file->rel_local+1 ); } else { printf( _("File: %s - modified %s"), file->rel_local+1, ctime(&file->remotetime) ); }}void init_sites( void ) { int ret; /* Read the rcfile */ ret = rcfile_read( &all_sites ); if( ret == RC_OPENFILE ) { printf( _("%s: Error: Could not open rcfile: %s.\n"), progname, rcfile ); exit( -1 ); } else if( ret == RC_CORRUPT ) { printf( _("%s: rcfile corrupt at line %d:\n%s"), progname, rcfile_linenum, rcfile_err ); exit( -1 ); }}int main( int argc, char *argv[] ) { int ret, num, numgoodsites; struct site_t *current; /* Initialize up */ ret = 0;#ifdef HAVE_SETLOCALE setlocale( LC_MESSAGES, "" );#endif /* HAVE_SETLOCALE */#ifdef ENABLE_NLS bindtextdomain( PACKAGE, LOCALEDIR ); textdomain( PACKAGE );#endif /* ENABLE_NLS */ init( argc, argv ); if( init_env( ) == 1 ) { printf( _("%s: Error: Environment variable HOME not set.\n"), progname ); exit( -1 ); } ret = init_paths( ); if( ret != 0 ) { switch( ret ) { case RC_OPENFILE: printf( _("%s: Error: Could not open rcfile: %s\n"), progname, rcfile ); break; case RC_PERMS: printf( _("%s: Error: rcfile permissions allow other users to read your rcfile.\n"), progname ); printf( _("%s: Set the permissions to 0600.\n"), progname ); break; case RC_DIROPEN: printf( _("%s: Error: Could not open storage directory: %s\n"), progname, copypath ); printf( _("%s: You need to create this directory and set the permissions to 0700.\n"), progname ); break; case RC_DIRPERMS: printf( _("%s: Error: storage directory permissions incorrect.\n"), progname ); printf( _("%s: Set the permissions to 0700.\n"), progname ); break; case RC_NETRCPERMS: printf( _("%s: Error: ~/.netrc permissions incorrect.\n"), progname ); printf( _("%s: Set the permissions to 0600.\n"), progname ); break; default: printf( _("%s: Argh, unhandled error.\n"), progname ); break; } exit(-1); } if( init_netrc( ) == 1 ) { printf( _("%s: Error: Could not parse ~/.netrc.\n"), progname ); exit( -1 ); } ret = 0; init_sites( ); /* Handle signals, so if we get killed in the middle of a * site update, the state gets saved properly. */ signal( SIGTERM, abort_handler ); signal( SIGQUIT, abort_handler ); signal( SIGINT, abort_handler ); signal( SIGABRT, abort_handler ); /* And ignore SIGPIPE */ signal( SIGPIPE, SIG_IGN ); if( needsite && !allsites ) { /* Mark all the sites we are interested in */ for( num=0; num < numsites; num++ ) { current = site_find( sitenames[num] ); if( current == NULL ) { printf( _("%s: Error: No site called `%s' found - skipping.\n"), progname, sitenames[num] ); } else { current->use_this = true; } } } /* Count the number of sites that are okay */ numgoodsites = 0; for( current = all_sites; current!=NULL; current=current->next ) { if( !current->use_this && !allsites ) continue; /* Check the site rcfile entry is okay */ ret = rc_verifysite( current ); switch( ret ) { case SITE_ACCESSLOCALDIR: printf( _("%s: Could not read directory for `%s':\n\t%s\n"), progname, current->name, current->local_root ); break; case SITE_NOSERVER: printf( _("%s: Server not specified in site `%s'.\n"), progname, current->name ); break; case SITE_NOUSERNAME: printf( _("%s: Username not specified in site `%s'.\n"), progname, current->name ); break; case SITE_NOPASSWORD: printf( _("%s: Password not specified in site `%s'.\n"), progname, current->name ); break; case SITE_NOREMOTEDIR: printf( _("%s: Remote directory not specified in site `%s'.\n"), progname, current->name ); break; case SITE_NOLOCALDIR: printf( _("%s: Local directory not specified in site `%s'.\n"), progname, current->name ); break; case SITE_INVALIDPORT: printf( _("%s: Invalid port used in site `%s'.\n"), progname, current->name ); break; case SITE_NOMAINTAIN: printf( _("%s: %s cannot maintain symbolic links (site `%s').\n"), progname, current->driver->protocol_name, current->name ); break; case SITE_NOREMOTEREL: printf( _("%s: Cannot use a relative remote directory in %s (site `%s').\n"), progname, current->driver->protocol_name, current->name ); break; case SITE_NOPERMS: printf( _("%s: File permissions are not supported in %s (site `%s').\n"), progname, current->driver->protocol_name, current->name ); break; case 0: /* Success */ break; default: printf( _("%s: Unhandled error %d in site `%s' - please contact the maintainer.\n"), progname, ret, current->name ); break; } if( ret != 0 ) continue; if( site_readfiles( current ) ) { printf( _("%s: Error: Could not read site info file for `%s'.\n"), progname, current->name ); } else { numgoodsites++; } } /* Handle the dump sites request */ if( ! needsite ) { switch( action ) { case action_view: site_dumpsites( ); ret = 0; break; default: printf( _("Unimplemented.\n") ); ret = -1; } return ret; } if( numgoodsites==0 ) { printf( _("%s: No sites specified.\n"), progname ); printf( _("Try `%s --help' for more information.\n"), progname ); exit(-1); } for( current=all_sites; current!=NULL; current=current->next ) { if( !current->use_this && !allsites ) continue; if( !listflat ) { printf( _("%s: %s site `%s' (on %s)\n"), progname, action_names[action], current->name, current->server ); } switch( action ) { case action_update: if( current->is_different ) { current_site = current; ret = site_update( current, false ); switch( ret ) { case SITE_OK: printf( _("%s: Remote site updated successfully.\n"), progname ); ret = 0; break; case SITE_ERRORS: printf( _("%s: Errors occurred while updating remote site.\n"), progname ); ret = 1; break; case SITE_LOOKUP: printf( _("%s: Error: Could not resolve remote hostname.\n"), progname ); ret = 2; break; case SITE_CONNECT: printf( _("%s: Error: Could not connect to remote host.\n"), progname ); ret = 2; break; case SITE_AUTH: printf( _("%s: Error: Could not authorise user on server.\n"), progname ); ret = 2; break; } /* hope we don't get signalled here */ current_site = NULL; site_writefiles( current ); } else { printf( _("%s: Nothing to do - no changes found.\n"), progname ); ret = 0; } break; case action_list: if( listflat ) { site_flatlist( stdout, current ); } else { site_normlist( current ); } ret = (current->is_different)?1:0; if( current->is_different ) { if( !listflat ) { printf( _("%s: The remote site needs updating.\n"), progname); } ret = 1; } else { if( !listflat ) { printf( _("%s: The remote site does not need updating.\n"), progname ); } ret = 0; } break; case action_init: site_initialize( current ); site_writefiles( current ); printf( _("%s: All the files and directories are marked as NOT updated remotely.\n"), progname ); break; case action_catchup: site_catchup( current ); site_writefiles( current ); printf( _("%s: All the files and and directories are marked as updated remotely.\n"), progname ); break; case action_fetch: ret = site_fetch( current ); switch( ret ) { case SITE_UNIMPL: printf( _("%s: Fetch mode unsupported for %s.\n"), progname, current->driver->protocol_name ); ret = -1; break; case SITE_LOOKUP: printf( _("%s: Error: Could not resolve remote hostname.\n"), progname ); ret = 2; break; case SITE_CONNECT: printf( _("%s: Error: Could not connect to remote host.\n"), progname ); ret = 2; break; case SITE_AUTH: printf( _("%s: Error: Could not authorise user on server.\n"), progname ); ret = 2; break; case SITE_FAILED: printf( _("%s: Failed to fetch file listing.\n"), progname ); ret = -1; break; case SITE_OK: printf( _("%s: Fetch completed successfully.\n"), progname ); site_writefiles( current ); ret = 0; break; } break; case action_synch: if( current->is_different ) { ret = site_synch( current ); switch( ret ) { case SITE_OK: printf( _("%s: Synchronize completed successfully\n"), progname ); ret = 0; break; case SITE_ERRORS: printf( _("%s: Errors occurred while synchronizing the local site.\n"), progname ); ret = 1; break; } } else { printf( _("%s: Nothing to do - no changes found.\n"), progname ); ret = 0; } break; default: printf( _("Unimplemented.\n") ); ret = -1; break; } } return ret;}void usage( ) { version(); printf( _("Usage: %s [OPTIONS] [MODE] [sitename]...\n"), progname ); printf( _("Options: \n") );#ifdef DEBUGGING printf( _(" -d, --debug=LEVEL Set debugging level\n"" (LEVEL=sum of: 1=socket, 2=files, 4=rcfile, 8=WebDAV, 16=FTP, 32=XML )\n") );#endif printf( _(" -r, --rcfile=FILE Use alternate run control file\n"" -p, --storepath=PATH Use alternate site storage directory\n"" -y, --prompting Request confirmation before making each update\n"" -a, --allsites Perform the operation on ALL defined sites\n"" -k, --keep-going Carry on an update regardless of errors\n"" -q, --quiet Be quiet while performing the operation\n"" -qq, --silent Be silent while perforing the operation\n""Operation modes:\n"" -l, --list List changes between remote and local sites (default)\n"" -ll, --flatlist Flat list of changes between remote and local sites\n"" -v, --view Display a list of the site definitions\n"" -i, --initialize Mark all files and directories as not updated\n"" -f, --fetch Find out what files are on the remote site\n"" -c, --catchup Mark all files and directories as updated\n"" -s, --synchronize Update the local site from the remote site\n"" -u, --update Update the remote site\n"" -h, --help Display this help message\n"" -V, --version Display version information\n""Please report bugs to sitecopy@lyra.org\n") );}/* "Warning: directory search depth exceeded. Increase MAXDIRS in sites.c.\n\ Directory %s is being skipped.\n" *//* One-liner version information. */void version( void ) { printf( PACKAGE " " VERSION ": FTP"#ifdef USE_DAV ", WebDAV"#ifdef HAVE_LIBEXPAT "+fetch"#endif#endif#ifdef DEBUGGING ", debugging"#endif#ifdef __EMX__ ", EMX/RSX platform"#else#ifdef __CYGWIN__ ", cygwin platform"#else ", Unix platform"#endif /* __CYGWIN__ */#endif /* __EMX__ */#ifdef HAVE_LX22_SENDFILE ", sendfile()"#endif ".\n" );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -