summaryrefslogtreecommitdiff
path: root/src/mscp.h
diff options
context:
space:
mode:
authorRyo Nakamura <upa@haeena.net>2023-03-03 22:14:54 +0900
committerRyo Nakamura <upa@haeena.net>2023-03-03 22:14:54 +0900
commit1e57e8fb2fcbf64ad518a5f6aa763725cbb43244 (patch)
treeb3924a58a4e01c8435759a221d61f463ea069020 /src/mscp.h
parent1b9ae5197463eed7d7015e6749bec1372844baea (diff)
implementing messaging.
ToDo: remove pprint. mscp should use mpr_* functions, and main.c should use just fprintf(stdout, "\r\033[K" fmt, ...) for printing progress bar.
Diffstat (limited to 'src/mscp.h')
-rw-r--r--src/mscp.h42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/mscp.h b/src/mscp.h
index ab195bf..d182ea9 100644
--- a/src/mscp.h
+++ b/src/mscp.h
@@ -20,10 +20,12 @@ struct mscp_opts {
size_t buf_sz;
char coremask[MSCP_MAX_COREMASK_STR];
- int verbose_level;
- bool quiet;
- bool dryrun;
+ /* messaging */
+ int severity; /* messaging severity. set MSCP_SERVERITY_* */
+ int msg_fd; /* fd to output message. default STDOUT,
+ * and -1 disables output */
+ bool dryrun;
};
#define MSCP_SSH_MAX_LOGIN_NAME 64
@@ -63,12 +65,6 @@ struct mscp;
struct mscp *mscp_init(const char *remote_host,
struct mscp_opts *o, struct mscp_ssh_opts *s);
-/* return a fd for read message from mscp */
-int mscp_msg_fd(struct mscp *m);
-
-/* get message for the most recent error (not thread safe) */
-const char *mscp_get_error();
-
/* establish the first SFTP session. mscp_prepare() and mscp_start()
* requires mscp_connect() beforehand */
int mscp_connect(struct mscp *m);
@@ -99,4 +95,32 @@ void mscp_cleanup(struct mscp *m);
/* free mscp instance */
void mscp_free(struct mscp *m);
+
+/* messaging with mscp */
+
+/* severity filter for messages. specifiy it with mscp_opts->serverity.
+ */
+enum {
+ MSCP_SEVERITY_NONE = -1,
+ MSCP_SEVERITY_ERR = 0,
+ MSCP_SEVERITY_WARN = 1,
+ MSCP_SEVERITY_NOTICE = 2,
+ MSCP_SEVERITY_INFO = 3,
+ MSCP_SEVERITY_DEBUG = 4,
+};
+
+/* set fd to which mscp writes messages. default is STDOUT.
+ * supposed fd is pipe write fd.
+ */
+void mscp_set_msg_fd(struct mscp *m, int fd);
+
+/* retrieve the fd for read message from mscp */
+int mscp_get_msg_fd(struct mscp *m);
+
+/* get message for the most recent error (not thread safe) */
+const char *mscp_get_error();
+
+
+
+
#endif /* _MSCP_H_ */