#endif
}
+static gchar *claws_rc_dir = NULL;
+static gboolean rc_dir_alt = FALSE;
const gchar *get_rc_dir(void)
{
- static gchar *rc_dir = NULL;
- if (!rc_dir)
- rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
+ if (!claws_rc_dir)
+ claws_rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
RC_DIR, NULL);
- return rc_dir;
+ return claws_rc_dir;
+}
+
+void set_rc_dir(const gchar *dir)
+{
+ if (claws_rc_dir != NULL) {
+ g_print("Error: rc_dir already set\n");
+ } else {
+ rc_dir_alt = TRUE;
+ if (g_path_is_absolute(dir))
+ claws_rc_dir = g_strdup(dir);
+ else {
+ claws_rc_dir = g_strconcat(g_get_current_dir(),
+ G_DIR_SEPARATOR_S, dir, NULL);
+ }
+ debug_print("set rc_dir to %s\n", claws_rc_dir);
+ if (!is_dir_exist(claws_rc_dir)) {
+ if (make_dir_hier(claws_rc_dir) != 0) {
+ g_print("Error: can't create %s\n",
+ claws_rc_dir);
+ }
+ }
+ }
+}
+
+gboolean rc_dir_is_alt(void) {
+ return rc_dir_alt;
}
const gchar *get_mail_base_dir(void)
return 0;
}
- prefs_prepare_cache();
prog_version = PROG_VERSION;
argv0 = g_strdup(argv[0]);
parse_cmd_opt(argc, argv);
+ prefs_prepare_cache();
+
#ifdef CRASH_DIALOG
if (cmd.crash) {
gtk_set_locale();
cmd.send = TRUE;
} else if (!strncmp(argv[i], "--version", 9) ||
!strncmp(argv[i], "-v", 2)) {
- g_print("Claws Mail version " VERSION);
+ g_print("Claws Mail version " VERSION "\n");
exit(0);
} else if (!strncmp(argv[i], "--status-full", 13)) {
const gchar *p = argv[i + 1];
g_print("%s\n", _(" --send send all queued messages"));
g_print("%s\n", _(" --status [folder]... show the total number of messages"));
g_print("%s\n", _(" --status-full [folder]...\n"
- " show the status of each folder"));
+ " show the status of each folder"));
g_print("%s\n", _(" --select folder[/msg] jumps to the specified folder/message\n"
" folder is a folder id like 'folder/sub_folder'"));
g_print("%s\n", _(" --online switch to online mode"));
g_print("%s\n", _(" --help -h display this help and exit"));
g_print("%s\n", _(" --version -v output version information and exit"));
g_print("%s\n", _(" --config-dir output configuration directory"));
+ g_print("%s\n", _(" --alternate-config-dir [dir]\n"
+ " use specified configuration directory"));
g_free(base);
exit(1);
cmd.crash_params = g_strdup(argv[i + 1]);
i++;
} else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
- g_print(RC_DIR);
+ g_print(RC_DIR "\n");
exit(0);
+ } else if (!strncmp(argv[i], "--alternate-config-dir", sizeof "--alternate-config-dir" - 1) && i+1 < argc) {
+ set_rc_dir(argv[i+1]);
} else if (!strncmp(argv[i], "--exit", 6) ||
!strncmp(argv[i], "--quit", 6) ||
!strncmp(argv[i], "-q", 2)) {
gchar *claws_get_socket_name(void)
{
static gchar *filename = NULL;
-
+ const gchar *socket_dir = NULL;
+
+ if (rc_dir_is_alt())
+ socket_dir = get_rc_dir();
+ else
+ socket_dir = g_get_tmp_dir();
if (filename == NULL) {
filename = g_strdup_printf("%s%cclaws-mail-%d",
- g_get_tmp_dir(), G_DIR_SEPARATOR,
+ socket_dir, G_DIR_SEPARATOR,
#if HAVE_GETUID
getuid());
#else