2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999,2000 Hiroyuki Yamamoto
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 static gboolean sylpheed_initialized = FALSE;
40 static gchar *startup_dir;
41 static void (*sylpheed_idle_function)(void) = NULL;
44 * Parse program parameters and remove all parameters
45 * that have been processed. Arguments are pointers to
46 * original passed programm arguments and these will
47 * be modified leaving only unknown parameters for
50 * \param argc pointer to number of parameters
51 * \param argv pointer to array of parameter strings
53 static void parse_parameter(int *argc, char ***argv)
57 g_return_if_fail(argc != NULL);
58 g_return_if_fail(argv != NULL);
60 for (i = 1; i < *argc;) {
61 if (strcmp("--debug", (*argv)[i]) == 0) {
70 /* Remove NULL args from argv[] for further processing */
71 for (i = 1; i < *argc; i++) {
72 for (k = i; k < *argc; k++)
73 if ((*argv)[k] != NULL)
78 for (j = i + k; j < *argc; j++)
79 (*argv)[j - k] = (*argv)[j];
85 gboolean sylpheed_init(int *argc, char ***argv)
87 if (sylpheed_initialized)
90 startup_dir = g_get_current_dir();
92 parse_parameter(argc, argv);
94 debug_print("Starting sylpheed version %08x\n", VERSION_NUMERIC);
96 setlocale(LC_ALL, "");
97 bindtextdomain(PACKAGE, LOCALEDIR);
98 bind_textdomain_codeset (PACKAGE, "UTF-8");
100 putenv("G_BROKEN_FILENAMES=1");
102 /* backup if old rc file exists */
103 if (is_file_exist(RC_DIR)) {
104 if (rename(RC_DIR, RC_DIR ".bak") < 0) {
105 FILE_OP_ERROR(RC_DIR, "rename");
110 srand((gint) time(NULL));
116 plugin_load_all("Common");
118 sylpheed_initialized = TRUE;
123 void sylpheed_done(void)
125 plugin_unload_all("Common");
132 const gchar *sylpheed_get_startup_dir(void)
137 guint sylpheed_get_version(void)
139 return VERSION_NUMERIC;
142 void sylpheed_register_idle_function (void (*idle_func)(void))
144 sylpheed_idle_function = idle_func;
147 void sylpheed_do_idle(void)
149 if (sylpheed_idle_function != NULL)
150 sylpheed_idle_function();