summaryrefslogtreecommitdiff
path: root/src/core/core.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-07-15 00:39:48 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-07-15 00:39:48 +0000
commit79d1d7089a699cf8a09bd5227f9033282001b0b3 (patch)
tree11a2e10bce84587e2b5a13029c43354a185e846c /src/core/core.c
parentbcbb55dd1e0ecf828942dcc91d5661e9a44ab841 (diff)
downloadirssi-79d1d7089a699cf8a09bd5227f9033282001b0b3.zip
Added --home and --config command line parameters to irssi to specify
locations for ~/.irssi and ~/.irssi/config git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1626 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/core.c')
-rw-r--r--src/core/core.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/core/core.c b/src/core/core.c
index f023552d..87816316 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -21,6 +21,7 @@
#include "module.h"
#include <signal.h>
+#include "args.h"
#include "pidwait.h"
#include "misc.h"
@@ -49,8 +50,20 @@ void chat_commands_deinit(void);
int irssi_gui;
+static char *irssi_dir, *irssi_config_file;
static GSList *dialog_type_queue, *dialog_text_queue;
+const char *get_irssi_dir(void)
+{
+ return irssi_dir;
+}
+
+/* return full path for ~/.irssi/config */
+const char *get_irssi_config(void)
+{
+ return irssi_config_file;
+}
+
static void read_signals(void)
{
#ifndef WIN32
@@ -106,7 +119,40 @@ static void sig_init_finished(void)
g_slist_free(dialog_text_queue);
}
-void core_init(void)
+void core_init_paths(int argc, char *argv[])
+{
+ static struct poptOption options[] = {
+ { "config", 0, POPT_ARG_STRING, NULL, 0, "Configuration file location (~/.irssi/config)", "PATH" },
+ { "home", 0, POPT_ARG_STRING, NULL, 0, "Irssi home dir location (~/.irssi)", "PATH" },
+ { NULL, '\0', 0, NULL }
+ };
+ int n, len;
+
+ for (n = 1; n < argc; n++) {
+ if (strncmp(argv[n], "--home=", 7) == 0) {
+ g_free_not_null(irssi_dir);
+ irssi_dir = convert_home(argv[n]+7);
+ len = strlen(irssi_dir);
+ if (irssi_dir[len-1] == G_DIR_SEPARATOR)
+ irssi_dir[len-1] = '\0';
+ break;
+ }
+ if (strncmp(argv[n], "--config=", 9) == 0) {
+ g_free_not_null(irssi_config_file);
+ irssi_config_file = convert_home(argv[n]+9);
+ break;
+ }
+ }
+
+ args_register(options);
+
+ if (irssi_dir == NULL)
+ irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, g_get_home_dir());
+ if (irssi_config_file == NULL)
+ irssi_config_file = g_strdup_printf("%s/config", irssi_dir);
+}
+
+void core_init(int argc, char *argv[])
{
dialog_type_queue = NULL;
dialog_text_queue = NULL;
@@ -179,4 +225,7 @@ void core_deinit(void)
pidwait_deinit();
#endif
modules_deinit();
+
+ g_free(irssi_dir);
+ g_free(irssi_config_file);
}