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 2 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, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <glib/gi18n.h>
43 static gboolean sylpheed_initialized = FALSE;
44 static gchar *startup_dir;
45 static void (*sylpheed_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 sylpheed_init(int *argc, char ***argv)
91 if (sylpheed_initialized)
94 startup_dir = g_get_current_dir();
96 parse_parameter(argc, argv);
98 debug_print("Starting sylpheed version %08x\n", VERSION_NUMERIC);
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 sylpheed_initialized = TRUE;
127 void sylpheed_done(void)
135 const gchar *sylpheed_get_startup_dir(void)
140 guint sylpheed_get_version(void)
142 return VERSION_NUMERIC;
145 void sylpheed_register_idle_function (void (*idle_func)(void))
147 sylpheed_idle_function = idle_func;
150 void sylpheed_do_idle(void)
152 if (sylpheed_idle_function != NULL)
153 sylpheed_idle_function();