Extending test-client-custom-summary to try e_book_client_get_contacts_uids()
[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 program is free software; you can redistribute it and/or
10  * modify it under the terms of version 2 of the GNU Lesser General Public
11  * License as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License 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, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21  * USA
22  */
23
24 #include <errno.h>
25 #include <io.h>
26 #include <stdlib.h>
27 #include <sys/stat.h>
28
29 #include <windows.h>
30
31 #include <glib/gstdio.h>
32
33 #include "camel.h"
34
35 G_LOCK_DEFINE_STATIC (mutex);
36
37 /* localedir uses system codepage as it is passed to the non-UTF8ified
38  * gettext library
39  */
40 static const gchar *localedir = NULL;
41
42 /* The others are in UTF-8 */
43 static const gchar *libexecdir;
44 static const gchar *providerdir;
45
46 /* XXX Where do these get defined?  e-data-server-util.h just has
47  * declarations for e_util_get_prefix() and e_util_get_cp_prefix(). */
48 static const gchar *    get_prefix              (void) G_GNUC_CONST;
49 static const gchar *    get_cp_prefix           (void) G_GNUC_CONST;
50
51 static gchar *
52 replace_prefix (const gchar *configure_time_prefix,
53                 const gchar *runtime_prefix,
54                 const gchar *configure_time_path)
55 {
56         gchar *c_t_prefix_slash;
57         gchar *retval;
58
59         c_t_prefix_slash = g_strconcat (configure_time_prefix, "/", NULL);
60
61         if (runtime_prefix != NULL &&
62             g_str_has_prefix (configure_time_path, c_t_prefix_slash)) {
63                 retval = g_strconcat (
64                         runtime_prefix,
65                         configure_time_path + strlen (configure_time_prefix),
66                         NULL);
67         } else
68                 retval = g_strdup (configure_time_path);
69
70         g_free (c_t_prefix_slash);
71
72         return retval;
73 }
74
75 static void
76 setup (void)
77 {
78         G_LOCK (mutex);
79
80         if (localedir != NULL) {
81                 G_UNLOCK (mutex);
82                 return;
83         }
84
85         localedir = replace_prefix (
86                 E_DATA_SERVER_PREFIX, get_cp_prefix (), LOCALEDIR);
87         libexecdir = replace_prefix (
88                 E_DATA_SERVER_PREFIX, get_prefix (), CAMEL_LIBEXECDIR);
89         providerdir = replace_prefix (
90                 E_DATA_SERVER_PREFIX, get_prefix (), CAMEL_PROVIDERDIR);
91
92         G_UNLOCK (mutex);
93 }
94
95 #include "camel-win32.h"        /* For prototypes */
96
97 #define GETTER(varbl)                           \
98 const gchar *                                   \
99 _camel_get_##varbl (void)                       \
100 {                                               \
101         setup ();                               \
102         return varbl;                           \
103 }
104
105 GETTER(localedir)
106 GETTER(libexecdir)
107 GETTER(providerdir)