~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/sanity.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <glib.h>
22
22
#include <fontconfig/fontconfig.h>
 
23
#include <pango/pango.h>
23
24
#include <pango/pangoft2.h>
 
25
#include <gegl.h>
24
26
 
25
27
#include "libgimpbase/gimpbase.h"
26
28
 
31
33
 
32
34
static gchar * sanity_check_gimp              (void);
33
35
static gchar * sanity_check_glib              (void);
 
36
static gchar * sanity_check_pango             (void);
34
37
static gchar * sanity_check_fontconfig        (void);
35
38
static gchar * sanity_check_freetype          (void);
 
39
static gchar * sanity_check_babl              (void);
 
40
static gchar * sanity_check_gegl              (void);
36
41
static gchar * sanity_check_filename_encoding (void);
37
42
 
38
43
 
47
52
    abort_message = sanity_check_glib ();
48
53
 
49
54
  if (! abort_message)
 
55
    abort_message = sanity_check_pango ();
 
56
 
 
57
  if (! abort_message)
50
58
    abort_message = sanity_check_fontconfig ();
51
59
 
52
60
  if (! abort_message)
53
61
    abort_message = sanity_check_freetype ();
54
62
 
55
63
  if (! abort_message)
 
64
    abort_message = sanity_check_babl ();
 
65
 
 
66
  if (! abort_message)
 
67
    abort_message = sanity_check_gegl ();
 
68
 
 
69
  if (! abort_message)
56
70
    abort_message = sanity_check_filename_encoding ();
57
71
 
58
72
  return abort_message;
84
98
static gchar *
85
99
sanity_check_glib (void)
86
100
{
87
 
  const gchar *mismatch;
88
 
 
89
101
#define GLIB_REQUIRED_MAJOR 2
90
 
#define GLIB_REQUIRED_MINOR 12
91
 
#define GLIB_REQUIRED_MICRO 3
 
102
#define GLIB_REQUIRED_MINOR 16
 
103
#define GLIB_REQUIRED_MICRO 1
92
104
 
93
 
  mismatch = glib_check_version (GLIB_REQUIRED_MAJOR,
94
 
                                 GLIB_REQUIRED_MINOR,
95
 
                                 GLIB_REQUIRED_MICRO);
 
105
  const gchar *mismatch = glib_check_version (GLIB_REQUIRED_MAJOR,
 
106
                                              GLIB_REQUIRED_MINOR,
 
107
                                              GLIB_REQUIRED_MICRO);
96
108
 
97
109
  if (mismatch)
98
110
    {
117
129
}
118
130
 
119
131
static gchar *
 
132
sanity_check_pango (void)
 
133
{
 
134
#define PANGO_REQUIRED_MAJOR 1
 
135
#define PANGO_REQUIRED_MINOR 18
 
136
#define PANGO_REQUIRED_MICRO 0
 
137
 
 
138
  const gchar *mismatch = pango_version_check (PANGO_REQUIRED_MAJOR,
 
139
                                               PANGO_REQUIRED_MINOR,
 
140
                                               PANGO_REQUIRED_MICRO);
 
141
 
 
142
  if (mismatch)
 
143
    {
 
144
      const gint pango_major_version = pango_version () / 100 / 100;
 
145
      const gint pango_minor_version = pango_version () / 100 % 100;
 
146
      const gint pango_micro_version = pango_version () % 100;
 
147
 
 
148
      return g_strdup_printf
 
149
        ("%s\n\n"
 
150
         "GIMP requires Pango version %d.%d.%d or later.\n"
 
151
         "Installed Pango version is %d.%d.%d.\n\n"
 
152
         "Somehow you or your software packager managed\n"
 
153
         "to install GIMP with an older Pango version.\n\n"
 
154
         "Please upgrade to Pango version %d.%d.%d or later.",
 
155
         mismatch,
 
156
         PANGO_REQUIRED_MAJOR, PANGO_REQUIRED_MINOR, PANGO_REQUIRED_MICRO,
 
157
         pango_major_version, pango_minor_version, pango_micro_version,
 
158
         PANGO_REQUIRED_MAJOR, PANGO_REQUIRED_MINOR, PANGO_REQUIRED_MICRO);
 
159
    }
 
160
 
 
161
#undef PANGO_REQUIRED_MAJOR
 
162
#undef PANGO_REQUIRED_MINOR
 
163
#undef PANGO_REQUIRED_MICRO
 
164
 
 
165
  return NULL;
 
166
}
 
167
 
 
168
static gchar *
120
169
sanity_check_fontconfig (void)
121
170
{
122
 
  gint   fc_version       = FcGetVersion ();
123
 
  gint   fc_major_version = fc_version / 100 / 100;
124
 
  gint   fc_minor_version = fc_version / 100 % 100;
125
 
  gint   fc_micro_version = fc_version % 100;
 
171
  const gint fc_version = FcGetVersion ();
126
172
 
127
173
#define FC_REQUIRED_MAJOR 2
128
174
#define FC_REQUIRED_MINOR 2
132
178
                    (FC_REQUIRED_MINOR *   100) +
133
179
                    (FC_REQUIRED_MICRO *     1)))
134
180
    {
 
181
      const gint fc_major_version = fc_version / 100 / 100;
 
182
      const gint fc_minor_version = fc_version / 100 % 100;
 
183
      const gint fc_micro_version = fc_version % 100;
 
184
 
135
185
      return g_strdup_printf
136
186
        ("The Fontconfig version being used is too old!\n\n"
137
187
         "GIMP requires Fontconfig version %d.%d.%d or later.\n"
202
252
}
203
253
 
204
254
static gchar *
 
255
sanity_check_babl (void)
 
256
{
 
257
  gint babl_major_version;
 
258
  gint babl_minor_version;
 
259
  gint babl_micro_version;
 
260
 
 
261
#define BABL_REQUIRED_MAJOR 0
 
262
#define BABL_REQUIRED_MINOR 0
 
263
#define BABL_REQUIRED_MICRO 22
 
264
 
 
265
  babl_get_version (&babl_major_version,
 
266
                    &babl_minor_version,
 
267
                    &babl_micro_version);
 
268
 
 
269
  if (babl_major_version < BABL_REQUIRED_MAJOR ||
 
270
      babl_minor_version < BABL_REQUIRED_MINOR ||
 
271
      babl_micro_version < BABL_REQUIRED_MICRO)
 
272
    {
 
273
      return g_strdup_printf
 
274
        ("BABL version too old!\n\n"
 
275
         "GIMP requires BABL version %d.%d.%d or later.\n"
 
276
         "Installed BABL version is %d.%d.%d.\n\n"
 
277
         "Somehow you or your software packager managed\n"
 
278
         "to install GIMP with an older BABL version.\n\n"
 
279
         "Please upgrade to BABL version %d.%d.%d or later.",
 
280
         BABL_REQUIRED_MAJOR, BABL_REQUIRED_MINOR, BABL_REQUIRED_MICRO,
 
281
         babl_major_version, babl_minor_version, babl_micro_version,
 
282
         BABL_REQUIRED_MAJOR, BABL_REQUIRED_MINOR, BABL_REQUIRED_MICRO);
 
283
    }
 
284
 
 
285
#undef BABL_REQUIRED_MAJOR
 
286
#undef BABL_REQUIRED_MINOR
 
287
#undef BABL_REQUIRED_MICRO
 
288
 
 
289
  return NULL;
 
290
}
 
291
 
 
292
static gchar *
 
293
sanity_check_gegl (void)
 
294
{
 
295
  gint gegl_major_version;
 
296
  gint gegl_minor_version;
 
297
  gint gegl_micro_version;
 
298
 
 
299
#define GEGL_REQUIRED_MAJOR 0
 
300
#define GEGL_REQUIRED_MINOR 0
 
301
#define GEGL_REQUIRED_MICRO 18
 
302
 
 
303
  gegl_get_version (&gegl_major_version,
 
304
                    &gegl_minor_version,
 
305
                    &gegl_micro_version);
 
306
 
 
307
  if (gegl_major_version < GEGL_REQUIRED_MAJOR ||
 
308
      gegl_minor_version < GEGL_REQUIRED_MINOR ||
 
309
      gegl_micro_version < GEGL_REQUIRED_MICRO)
 
310
    {
 
311
      return g_strdup_printf
 
312
        ("GEGL version too old!\n\n"
 
313
         "GIMP requires GEGL version %d.%d.%d or later.\n"
 
314
         "Installed GEGL version is %d.%d.%d.\n\n"
 
315
         "Somehow you or your software packager managed\n"
 
316
         "to install GIMP with an older GEGL version.\n\n"
 
317
         "Please upgrade to GEGL version %d.%d.%d or later.",
 
318
         GEGL_REQUIRED_MAJOR, GEGL_REQUIRED_MINOR, GEGL_REQUIRED_MICRO,
 
319
         gegl_major_version, gegl_minor_version, gegl_micro_version,
 
320
         GEGL_REQUIRED_MAJOR, GEGL_REQUIRED_MINOR, GEGL_REQUIRED_MICRO);
 
321
    }
 
322
 
 
323
#undef GEGL_REQUIRED_MAJOR
 
324
#undef GEGL_REQUIRED_MINOR
 
325
#undef GEGL_REQUIRED_MICRO
 
326
 
 
327
  return NULL;
 
328
}
 
329
 
 
330
static gchar *
205
331
sanity_check_filename_encoding (void)
206
332
{
207
333
  gchar  *result;