Remove dynamic exceptions
[anna.git] / source / config / Release.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #include <stdio.h>
10 #include <sys/utsname.h>
11
12 #include <anna/config/Release.hpp>
13 #include <anna/config/defines.hpp>
14
15 using namespace std;
16 using namespace anna;
17
18 string config::Release::getVersion() {
19   static const int version = ANNA_VERSION;
20   string result;
21   int mainVersion = (version & 0xff0000) >> 16;
22   int year = (version & 0xff00) >> 8;
23   int month = (version & 0xff);
24   char aux [32];
25   sprintf(aux, "%d.%02d.%02d", mainVersion, year, month);
26   result = aux;
27   return result += getArchitecture();
28 }
29
30 // (1) It only will use the main OS version
31 string config::Release::getArchitecture() {
32   string result;
33 #ifdef _MT
34   result = "/MT";
35 #else
36   result = "/ST";
37 #endif
38 #ifdef _DEBUG
39   result += "/D";
40 #else
41   result += "/O";
42 #endif
43   struct utsname un;
44   uname(&un);
45   result += '/';
46   result += un.sysname;
47   result += ' ';
48   char* release = anna_strchr(un.release, '.');               // (1)
49
50   if(release != NULL)
51     if((release = anna_strchr(release + 1, '.')) != NULL)
52       * release = 0;
53
54   result += un.release;
55   result += " (";
56   result += un.machine;
57   result += ")";
58   return result;
59 }