add comments to mscp.h

This commit is contained in:
Ryo Nakamura
2023-02-26 23:56:57 +09:00
parent ca0ea3ee77
commit fc45fa2532
2 changed files with 24 additions and 1 deletions

View File

@@ -16,7 +16,7 @@
#include <mscp.h> #include <mscp.h>
struct mscp { struct mscp {
const char *remote; /* remote host (and uername) */ char *remote; /* remote host (and uername) */
struct mscp_opts *opts; struct mscp_opts *opts;
struct ssh_opts ssh_opts; struct ssh_opts ssh_opts;
@@ -597,6 +597,10 @@ void mscp_cleanup(struct mscp *m)
void mscp_free(struct mscp *m) void mscp_free(struct mscp *m)
{ {
mscp_cleanup(m); mscp_cleanup(m);
if (m->remote)
free(m->remote);
if (m->cores)
free(m->cores);
free(m); free(m);
} }

View File

@@ -2,6 +2,7 @@
#define _MSCP_H_ #define _MSCP_H_
#include <stdbool.h> #include <stdbool.h>
#include <limits.h>
#define MSCP_DIRECTION_L2R 1 #define MSCP_DIRECTION_L2R 1
#define MSCP_DIRECTION_R2L 2 #define MSCP_DIRECTION_R2L 2
@@ -42,13 +43,31 @@ struct mscp_opts {
struct mscp; struct mscp;
/* initialize and return a mscp instance with option validation */
struct mscp *mscp_init(const char *remote_host, struct mscp_opts *opts); struct mscp *mscp_init(const char *remote_host, struct mscp_opts *opts);
/* establish the first SFTP session. mscp_prepare() and mscp_start()
* requires mscp_connect() beforehand */
int mscp_connect(struct mscp *m); int mscp_connect(struct mscp *m);
/* add a source file path to be copied */
int mscp_add_src_path(struct mscp *m, const char *src_path); int mscp_add_src_path(struct mscp *m, const char *src_path);
/* set the destination file path */
int mscp_set_dst_path(struct mscp *m, const char *dst_path); int mscp_set_dst_path(struct mscp *m, const char *dst_path);
/* check source files, resolve destination file paths for all source
* files, and prepare chunks for all files. */
int mscp_prepare(struct mscp *m); int mscp_prepare(struct mscp *m);
/* start to copy files */
int mscp_start(struct mscp *m); int mscp_start(struct mscp *m);
/* cleanup mscp instance. after mscp_cleanup(), process can restart
* from mscp_connect() with the same setting. */
void mscp_cleanup(struct mscp *m); void mscp_cleanup(struct mscp *m);
/* free mscp instance */
void mscp_free(struct mscp *m); void mscp_free(struct mscp *m);
#endif /* _MSCP_H_ */ #endif /* _MSCP_H_ */