2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999,2000 Hiroyuki Yamamoto and 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/>.
28 #include <glib/gi18n.h>
43 static gboolean claws_initialized = FALSE;
44 static gchar *startup_dir;
45 static void (*claws_idle_function)(void) = NULL;
48 * Parse program parameters and remove all parameters
49 * that have been processed. Arguments are pointers to
50 * original passed programm arguments and these will
51 * be modified leaving only unknown parameters for
54 * \param argc pointer to number of parameters
55 * \param argv pointer to array of parameter strings
57 static void parse_parameter(int *argc, char ***argv)
61 g_return_if_fail(argc != NULL);
62 g_return_if_fail(argv != NULL);
64 for (i = 1; i < *argc;) {
65 if (strcmp("--debug", (*argv)[i]) == 0) {
74 /* Remove NULL args from argv[] for further processing */
75 for (i = 1; i < *argc; i++) {
76 for (k = i; k < *argc; k++)
77 if ((*argv)[k] != NULL)
82 for (j = i + k; j < *argc; j++)
83 (*argv)[j - k] = (*argv)[j];
89 gboolean claws_init(int *argc, char ***argv)
91 if (claws_initialized)
94 startup_dir = g_get_current_dir();
96 parse_parameter(argc, argv);
98 debug_print("Starting Claws Mail version %s\n", PROG_VERSION);
100 setlocale(LC_ALL, "");
102 bindtextdomain(PACKAGE, get_locale_dir () );
103 bind_textdomain_codeset (PACKAGE, "UTF-8");
105 #endif /*ENABLE_NLS*/
106 putenv("G_BROKEN_FILENAMES=1");
108 /* backup if old rc file exists */
109 if (is_file_exist(RC_DIR)) {
110 if (rename(RC_DIR, RC_DIR ".bak") < 0) {
111 FILE_OP_ERROR(RC_DIR, "rename");
116 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();