rnd-20140225-2-src
[rocksndiamonds.git] / src / config.c
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * config.c                                                 *
12 ***********************************************************/
13
14 #include "libgame/libgame.h"
15
16 #include "config.h"
17 #include "conftime.h"
18
19
20 #define USE_EXTENDED_VERSION    1
21
22
23 char *getCompileDateString()
24 {
25   return COMPILE_DATE_STRING;
26 }
27
28 char *getProgramReleaseVersionString()
29 {
30   static char program_version_string[32];
31
32 #if USE_EXTENDED_VERSION
33   sprintf(program_version_string, "%d.%d.%d.%d",
34           PROGRAM_VERSION_MAJOR, PROGRAM_VERSION_MINOR, PROGRAM_VERSION_PATCH,
35           PROGRAM_VERSION_BUILD);
36 #else
37   sprintf(program_version_string, "%d.%d.%d",
38           PROGRAM_VERSION_MAJOR, PROGRAM_VERSION_MINOR, PROGRAM_VERSION_PATCH);
39 #endif
40
41   return program_version_string;
42 }
43
44 char *getProgramFullVersionString()
45 {
46   static char program_version_string[32];
47
48 #if USE_EXTENDED_VERSION
49   sprintf(program_version_string, "%d.%d.%d.%d",
50           PROGRAM_VERSION_MAJOR, PROGRAM_VERSION_MINOR, PROGRAM_VERSION_PATCH,
51           PROGRAM_VERSION_BUILD);
52 #else
53   sprintf(program_version_string, "%d.%d.%d-%d",
54           PROGRAM_VERSION_MAJOR, PROGRAM_VERSION_MINOR, PROGRAM_VERSION_PATCH,
55           PROGRAM_VERSION_BUILD);
56 #endif
57
58   return program_version_string;
59 }
60
61 char *getProgramVersionString()
62 {
63 #ifdef DEBUG
64   return getProgramFullVersionString();
65 #else
66   return getProgramReleaseVersionString();
67 #endif
68 }
69
70 char *getProgramInitString()
71 {
72   static char *program_init_string = NULL;
73
74 #if 1
75   // do not display compile target anymore, as it is almost always "SDL" now
76   if (program_init_string == NULL)
77   {
78     program_init_string = checked_malloc(strlen(PROGRAM_TITLE_STRING) + 1 +
79                                          strlen(getProgramVersionString()) + 1);
80
81     sprintf(program_init_string, "%s %s",
82             PROGRAM_TITLE_STRING, getProgramVersionString());
83   }
84 #else
85   if (program_init_string == NULL)
86   {
87     program_init_string = checked_malloc(strlen(PROGRAM_TITLE_STRING) + 1 +
88                                          strlen(getProgramVersionString()) + 1 +
89                                          strlen(TARGET_STRING) + 1);
90
91     sprintf(program_init_string, "%s %s %s",
92             PROGRAM_TITLE_STRING, getProgramVersionString(), TARGET_STRING);
93   }
94 #endif
95
96   return program_init_string;
97 }
98
99 char *getWindowTitleString()
100 {
101 #ifdef DEBUG
102   static char *window_title_string = NULL;
103
104   if (window_title_string == NULL)
105   {
106     window_title_string = checked_malloc(strlen(getProgramInitString()) + 1 +
107                                          strlen(getCompileDateString()) + 2 +1);
108
109     sprintf(window_title_string, "%s [%s]",
110             getProgramInitString(), getCompileDateString());
111   }
112
113   return window_title_string;
114 #else
115   return getProgramInitString();
116 #endif
117 }