updated changelog
[platform/upstream/evolution-data-server.git] / camel / camel-win32.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-win32.c : Win32-specific bits */
3
4 /*
5  * Authors: Tor Lillqvist <tml@novell.com>
6  *
7  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
8  *
9  * This library is free software you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16  *for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #include <errno.h>
23 #include <io.h>
24 #include <stdlib.h>
25 #include <sys/stat.h>
26
27 #include <windows.h>
28
29 #include <glib/gstdio.h>
30
31 #include "camel.h"
32
33 G_LOCK_DEFINE_STATIC (mutex);
34
35 /* localedir uses system codepage as it is passed to the non-UTF8ified
36  * gettext library
37  */
38 static const gchar *localedir = NULL;
39
40 /* The others are in UTF-8 */
41 static const gchar *libexecdir;
42 static const gchar *providerdir;
43
44 /* XXX Where do these get defined?  e-data-server-util.h just has
45  * declarations for e_util_get_prefix() and e_util_get_cp_prefix(). */
46 static const gchar *    get_prefix              (void) G_GNUC_CONST;
47 static const gchar *    get_cp_prefix           (void) G_GNUC_CONST;
48
49 static gchar *
50 replace_prefix (const gchar *configure_time_prefix,
51                 const gchar *runtime_prefix,
52                 const gchar *configure_time_path)
53 {
54         gchar *c_t_prefix_slash;
55         gchar *retval;
56
57         c_t_prefix_slash = g_strconcat (configure_time_prefix, "/", NULL);
58
59         if (runtime_prefix != NULL &&
60             g_str_has_prefix (configure_time_path, c_t_prefix_slash)) {
61                 retval = g_strconcat (
62                         runtime_prefix,
63                         configure_time_path + strlen (configure_time_prefix),
64                         NULL);
65         } else
66                 retval = g_strdup (configure_time_path);
67
68         g_free (c_t_prefix_slash);
69
70         return retval;
71 }
72
73 static void
74 setup (void)
75 {
76         G_LOCK (mutex);
77
78         if (localedir != NULL) {
79                 G_UNLOCK (mutex);
80                 return;
81         }
82
83         localedir = replace_prefix (
84                 E_DATA_SERVER_PREFIX, get_cp_prefix (), LOCALEDIR);
85         libexecdir = replace_prefix (
86                 E_DATA_SERVER_PREFIX, get_prefix (), CAMEL_LIBEXECDIR);
87         providerdir = replace_prefix (
88                 E_DATA_SERVER_PREFIX, get_prefix (), CAMEL_PROVIDERDIR);
89
90         G_UNLOCK (mutex);
91 }
92
93 #include "camel-win32.h"        /* For prototypes */
94
95 #define GETTER(varbl)                           \
96 const gchar *                                   \
97 _camel_get_##varbl (void)                       \
98 {                                               \
99         setup ();                               \
100         return varbl;                           \
101 }
102
103 GETTER(localedir)
104 GETTER(libexecdir)
105 GETTER(providerdir)