Move version identification into a common place.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 11 Apr 2013 19:08:14 +0000 (21:08 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 11 Apr 2013 19:08:14 +0000 (21:08 +0200)
httpinput.cpp
main.cpp
version.h [new file with mode: 0644]

index 1db4f91..012f5bc 100644 (file)
@@ -23,6 +23,7 @@
 #include "server.h"
 #include "serverpool.h"
 #include "parse.h"
+#include "version.h"
 #include "state.pb.h"
 
 using namespace std;
@@ -163,7 +164,7 @@ bool HTTPInput::parse_response(const std::string &request)
        // TODO: Make case-insensitive.
        // XXX: Use a Via: instead?
        if (parameters.count("Server") == 0) {
-               parameters.insert(make_pair("Server", "metacube/0.1"));
+               parameters.insert(make_pair("Server", SERVER_IDENTIFICATION));
        } else {
                for (multimap<string, string>::iterator it = parameters.begin();
                     it != parameters.end();
@@ -171,7 +172,7 @@ bool HTTPInput::parse_response(const std::string &request)
                        if (it->first != "Server") {
                                continue;
                        }
-                       it->second = "metacube/0.1 (reflecting: " + it->second + ")";
+                       it->second = SERVER_IDENTIFICATION " (reflecting: " + it->second + ")";
                }
        }
 
index 04d0d3d..e258c86 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -27,6 +27,7 @@
 #include "input.h"
 #include "httpinput.h"
 #include "stats.h"
+#include "version.h"
 #include "state.pb.h"
 
 using namespace std;
@@ -323,7 +324,7 @@ void create_streams(const vector<ConfigLine> &config,
 
 int main(int argc, char **argv)
 {
-       fprintf(stderr, "\nCubemap starting.\n");
+       fprintf(stderr, "\nCubemap " SERVER_VERSION " starting.\n");
 
        struct timeval serialize_start;
        bool is_reexec = false;
diff --git a/version.h b/version.h
new file mode 100644 (file)
index 0000000..5b5596a
--- /dev/null
+++ b/version.h
@@ -0,0 +1,9 @@
+#ifndef _VERSION_H
+#define _VERSION_H
+
+// Version number. Don't expect this to change all that often.
+
+#define SERVER_VERSION "0.1"
+#define SERVER_IDENTIFICATION "Cubemap/" SERVER_VERSION
+
+#endif  // !defined(_VERSION_H)