From f71c7a145a4c840baff1d34e9d2c3d9e2f26d74e Mon Sep 17 00:00:00 2001 From: Ryo Nakamura Date: Fri, 16 Feb 2024 14:54:24 +0900 Subject: add checkpoint.c and .h --- include/config.h.in | 7 ------- include/mscp.h | 30 ++++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/config.h.in b/include/config.h.in index 86c6a24..972723a 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -15,11 +15,4 @@ /* Define to 1 if you have the ntohll function. */ #cmakedefine HAVE_NTOHLL 1 -/* Define to 1 if you have the bswap_64 function. */ -#cmakedefine HAVE_BSWAP_64 1 - -/* Define to 1 if you have the bswap64 function. */ -#cmakedefine HAVE_BSWAP64 1 - - #endif /* _CONFIG_H_ */ diff --git a/include/mscp.h b/include/mscp.h index 8f69c1e..c6af3f8 100644 --- a/include/mscp.h +++ b/include/mscp.h @@ -45,7 +45,8 @@ struct mscp_opts { int max_startups; /** sshd MaxStartups concurrent connections */ int interval; /** interval between SSH connection attempts */ bool preserve_ts; /** preserve file timestamps */ - + char *checkpoint; /** path to checkpoint */ + int resume; /** resume from checkpoint if > 0 */ int severity; /** messaging severity. set MSCP_SERVERITY_* */ }; @@ -162,15 +163,36 @@ int mscp_set_dst_path(struct mscp *m, const char *dst_path); int mscp_scan(struct mscp *m); /** - * @brief Join scna thread invoked by mscp_scan(). mscp_join() - * involves this, so that mscp_scan_join() should be called when - * mscp_scan() is called by mscp_start() is not. + * @brief Join scan thread invoked by mscp_scan() if it + * runs. mscp_join() involves mscp_can_join(). Thus, there is no need + * to call this function alone. * * @param m mscp instance. * @return 0 on success, < 0 if an error occured. */ int mscp_scan_join(struct mscp *m); +/** + * @brief resume transfer from a checkpoint. mscp_load_checkpoint() + * loads files and associated chunks from a checkpoint file pointed by + * pathname. If you call mscp_load_checkpoint, do not call + * mscp_scan(). + * + * @param m mscp instance. + * @param pathname path to a checkpoint file. + * @return 0 on success, < 0 if an error occured. + */ +int mscp_load_checkpoint(struct mscp *m, const char *pathname); + +/** + * @brief save untransferred files and chunks to a checkpoint file. + * + * @param m mscp instance. + * @param pathname path to a checkpoint file. + * @return 0 on success, < 0 if an error occured. + */ +int mscp_save_checkpoint(struct mscp *m, const char *pathname); + /** * @brief Start to copy files. mscp_start() returns immediately. You * can get statistics via mscp_get_stats() or messages via pipe set by -- cgit v1.2.3