[Pkg-privacy-commits] [irssi-plugin-otr] 166/267: Create module directory on load

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.

commit cc5b86188198c4f41cecfc1f637ebdfe1d32fc45
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Sat Dec 1 21:33:05 2012 -0500

    Create module directory on load
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/module.c | 31 +++++++++++++++++++++++++++++++
 src/otr.h    |  7 ++++---
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/module.c b/src/module.c
index 52510e0..9c2d099 100644
--- a/src/module.c
+++ b/src/module.c
@@ -249,6 +249,30 @@ static void read_settings(void)
 	return;
 }
 
+static int create_module_dir(void)
+{
+	int ret;
+	char *dir_path = NULL;
+
+	/* Create ~/.irssi/otr directory. */
+	ret = asprintf(&dir_path, "%s%s", get_client_config_dir(), OTR_DIR);
+	if (ret < 0) {
+		IRSSI_MSG("Unable to allocate home dir path.");
+		goto error_alloc;
+	}
+
+	ret = mkdir(dir_path, S_IRWXU);
+	if (ret < 0) {
+		IRSSI_MSG("Unable to create %s directory.", dir_path);
+		goto error;
+	}
+
+error:
+	free(dir_path);
+error_alloc:
+	return ret;
+}
+
 void irssi_send_message(SERVER_REC *irssi, const char *recipient,
 		const char *msg)
 {
@@ -264,10 +288,17 @@ void irssi_send_message(SERVER_REC *irssi, const char *recipient,
  */
 void otr_init(void)
 {
+	int ret;
+
 	module_register(MODULE_NAME, "core");
 
 	theme_register(otr_formats);
 
+	ret = create_module_dir();
+	if (ret < 0) {
+		return;
+	}
+
 	otr_lib_init();
 
 	/*
diff --git a/src/otr.h b/src/otr.h
index a0634ef..e205ba2 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -40,9 +40,10 @@
 /* OTR protocol id */
 #define OTR_PROTOCOL_ID               "IRC"
 
-#define OTR_KEYFILE                   "/otr/otr.key"
-#define OTR_FINGERPRINTS_FILE         "/otr/otr.fp"
-#define OTR_INSTAG_FILE               "/otr/otr.instag"
+#define OTR_DIR                       "/otr"
+#define OTR_KEYFILE                   OTR_DIR "/otr.key"
+#define OTR_FINGERPRINTS_FILE         OTR_DIR "/otr.fp"
+#define OTR_INSTAG_FILE               OTR_DIR "/otr.instag"
 
 /*
  * Memory allocation zeroed. Really useful!

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git



More information about the Pkg-privacy-commits mailing list