Debian Codegraph @

src/base/0porting.c

raw
1 /*
2 * 0porting.c - checking sanity of typedefs
3 */
4
5 #include "../base/mdjvucfg.h"
6 #include <minidjvu/minidjvu.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 #ifdef HAVE_GETTEXT
11 #include <locale.h>
12 #endif
13
14 MDJVU_IMPLEMENT const char *mdjvu_check_sanity(void)
15 {
16 if (sizeof(int32) != 4)
17 return "mdjvu_check_sanity(): sizeof(int32) != 4";
18
19 if (sizeof(uint32) != 4)
20 return "mdjvu_check_sanity(): sizeof(uint32) != 4";
21
22 if (sizeof(int16) != 2)
23 return "mdjvu_check_sanity(): sizeof(int16) != 2";
24
25 if (sizeof(uint16) != 2)
26 return "mdjvu_check_sanity(): sizeof(uint16) != 2";
27
28 return NULL;
29 }
30
31
32 static int initialized = 0;
33
34 void mdjvu_init(void)
35 {
36 const char *sanity_error_message;
37
38 if (initialized)
39 return;
40
41 #ifdef HAVE_GETTEXT
42 bindtextdomain("minidjvu", LOCALEDIR);
43 #endif
44
45 /* check sizeof(int32) == 4 and such gibberish */
46 sanity_error_message = mdjvu_check_sanity();
47 if (sanity_error_message)
48 {
49 fprintf(stderr, "%s\n", sanity_error_message);
50 exit(1);
51 }
52
53 initialized = 1;
54 }