2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
29 #include <glib/gi18n.h>
44 static gboolean claws_initialized = FALSE;
45 static gchar *startup_dir;
46 static void (*claws_idle_function)(void) = NULL;
49 * Parse program parameters and remove all parameters
50 * that have been processed. Arguments are pointers to
51 * original passed programm arguments and these will
52 * be modified leaving only unknown parameters for
55 * \param argc pointer to number of parameters
56 * \param argv pointer to array of parameter strings
58 static void parse_parameter(int *argc, char ***argv)
62 cm_return_if_fail(argc != NULL);
63 cm_return_if_fail(argv != NULL);
65 for (i = 1; i < *argc;) {
66 if (strcmp("--debug", (*argv)[i]) == 0) {
75 /* Remove NULL args from argv[] for further processing */
76 for (i = 1; i < *argc; i++) {
77 for (k = i; k < *argc; k++)
78 if ((*argv)[k] != NULL)
83 for (j = i + k; j < *argc; j++)
84 (*argv)[j - k] = (*argv)[j];
90 gboolean claws_init(int *argc, char ***argv)
92 if (claws_initialized)
98 startup_dir = g_get_current_dir();
100 parse_parameter(argc, argv);
102 debug_print("Starting Claws Mail version %s\n", PROG_VERSION);
104 setlocale(LC_ALL, "");
106 bindtextdomain(PACKAGE, get_locale_dir () );
107 bind_textdomain_codeset (PACKAGE, "UTF-8");
109 #endif /*ENABLE_NLS*/
110 putenv("G_BROKEN_FILENAMES=1");
112 /* backup if old rc file exists */
113 if (is_file_exist(RC_DIR)) {
114 if (g_rename(RC_DIR, RC_DIR ".bak") < 0) {
115 FILE_OP_ERROR(RC_DIR, "rename");
120 srand((gint) time(NULL));
122 claws_initialized = TRUE;
127 void claws_done(void)
135 const gchar *claws_get_startup_dir(void)
140 guint claws_get_version(void)
142 return VERSION_NUMERIC;
145 void claws_register_idle_function (void (*idle_func)(void))
147 claws_idle_function = idle_func;
150 void claws_do_idle(void)
152 if (claws_idle_function != NULL)
153 claws_idle_function();