#pragma once
+#include <string>
+#include "Common/Time.hxx"
+
namespace DefMain
{
- static const char *const Name = "TinNS";
- static const char *const Version = "0.3 C++11 development";
+ static const std::string Name = "TinNS";
+ static const std::string Version = "0.3 C++11 development";
+ static const std::string Revision = Time::toDateString(Time::now()).c_str();
}
+#include <iomanip>
+#include <sstream>
#include "Common/Time.hxx"
namespace Time
{
return Clock::from_time_t(timet);
}
+
+ std::string toDateString(const time_t timet, const std::string &format)
+ {
+ const struct std::tm temp = *std::localtime(&timet);
+ std::stringstream result;
+
+ result << std::put_time(&temp, format.c_str());
+
+ return result.str();
+ }
+
+ std::string toDateString(const Timepoint &timepoint, const std::string &format)
+ {
+ return toDateString(toTimeT(timepoint), format);
+ }
}
#pragma once
#include <chrono>
+#include <string>
namespace Time
{
- //--- types ---
+ //--- types and constants ---
using Clock = std::chrono::system_clock;
using Rep = Clock::rep;
using Period = Clock::period;
using Duration = Clock::duration;
using Timepoint = Clock::time_point;
+ // fromat: YYYYMMDD.hhmmss - 24h
+ static const std::string DefCompactDateTime = "%Y%m%j.%H%M%S";
+ static const std::string DefDateTime = "%Y/%m/%j %H:%M:%S";
+
//--- functions ---
Timepoint now();
+
time_t toTimeT(const Timepoint &timepoint);
Timepoint toTimepoint(const time_t timet);
+
+ std::string toDateString(const time_t timet, const std::string &format = DefCompactDateTime);
+ std::string toDateString(const Timepoint &timepoint, const std::string &format = DefCompactDateTime);
}
-ADD_EXECUTABLE (getsvnrev getsvnrev.cxx)
ADD_EXECUTABLE (cleandepfile cleandepfile.c)
+++ /dev/null
-/*
- TinNS (TinNS is not a Neocron Server)
- Copyright (C) 2005 Linux Addicted Community
- maintainer Akiko <akiko@gmx.org>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-*/
-
-
-
-/*
- getsvnrev - a simple tool to read out actual SVN revision-number
-
- Why?
- Well for example my server doesnt have any SVN libs installed. Therefore,
- the getsvnrev script fails. I need this little tool, and maybe someone else too ^^
-
- Usage:
- call getsvnrev either without parameters or with the directory you
- want to know the SVN revision.
-
- Console output:
- If no .svn directory is found, the tool returns 0.
- Otherwise it will return the SVN revision of the target dir
-
- MODIFIED: 22 Dec 2006 Namikon
- REASON: - started this tool
- MODIFIED: 09 Jun 2009 Akiko
- REASON: - more C++ stylish
- - missing libs (cstring, cstdlib)
-
- TODO:
- - Better way to get SVN rev than this (2nd number in file)
-*/
-
-
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-#include <iostream>
-
-int main(int argc, char **argv)
-{
- std::string targetdir;
- FILE *f;
-
- if(argc == 2)
- {
- int i = 0;
- while(argv[1][i] != '\0') { i++; };
- if(argv[1][i-1] == '/')
- {
- targetdir = strcat(argv[1], ".svn/entries");
- }
- else
- {
- targetdir = strcat(argv[1], "/.svn/entries");
- }
- }
- else
- {
- targetdir = ".svn/entries";
- }
-
-
- if ((f = fopen(targetdir.c_str(), "r")) != NULL) {
- char line[255];
- int rev;
- bool firstnrfound = false;
-
- do
- {
- fgets (line, 255, f);
- rev = atoi(line);
- if(rev > 0 && firstnrfound == false)
- {
- firstnrfound = true;
- rev = 0;
- }
- } while (rev == 0);
-
- fclose(f);
-
- std::cout << rev << std::endl;
- }
- else
- {
- std::cout << "0" << std::endl;
- }
- return(0);
-}
{
char tmpChatMsg[300];
snprintf(tmpChatMsg, 299, "You are on TinNS server %s runnig version %s - SVN Rev. %s",
- Config->GetOption("server_name").c_str(), DefMain::Version, DefMain::Version);
+ Config->GetOption("server_name").c_str(), DefMain::Version.c_str(), DefMain::Version.c_str());
tmpChatMsg[299] = '\0';
Chat->send(source, CHAT_DIRECT, "System", tmpChatMsg);
Console->Print(WHITE, BLUE, "/-------------------------------------------------------------------\\");
Console->Print(WHITE, BLUE, "| TinNS (TinNS is not a Neocron Server) |");
Console->Print(WHITE, BLUE, "| Copyright (C) 2005 Linux Addicted Community |");
- Console->Print(WHITE, BLUE, "| maintainer Akiko <akiko@linux-addicte.net> |");
+ Console->Print(WHITE, BLUE, "| maintainer Akiko <akiko@linux-addicted.net> |");
Console->Print(WHITE, BLUE, "| ========================================== |");
Console->Print(WHITE, BLUE, "| Head coders: The packet analyzing team: |");
Console->Print(WHITE, BLUE, "| - Akiko - MaxxJag |");
//GetSVNRev(svnrev);
Console->LPrint("You are running TinNS Gameserver version");
Console->LPrint(GREEN, BLACK, " %s", DefMain::Version);
- Console->LPrint(WHITE, BLACK, " - SVN Rev");
- Console->LPrint(GREEN, BLACK, " %s", DefMain::Version);
+ Console->LPrint(WHITE, BLACK, " - Revision");
+ Console->LPrint(GREEN, BLACK, " %s", DefMain::Revision);
Console->LClose();
Config = new PConfig();
//GetSVNRev(svnrev);
Console->LPrint("You are running TinNS Infoserver version");
Console->LPrint(GREEN, BLACK, " %s", DefMain::Version);
- Console->LPrint(WHITE, BLACK, " - SVN Rev");
- Console->LPrint(GREEN, BLACK, " %s", DefMain::Version);
+ Console->LPrint(WHITE, BLACK, " - Revision");
+ Console->LPrint(GREEN, BLACK, " %s", DefMain::Revision);
Console->LClose();
Config = new PConfig();
//GetSVNRev(svnrev);
Console->LPrint("You are running TinNS Patchserver version");
Console->LPrint(GREEN, BLACK, " %s", DefMain::Version);
- Console->LPrint(WHITE, BLACK, " - SVN Rev");
- Console->LPrint(GREEN, BLACK, " %s", DefMain::Version);
+ Console->LPrint(WHITE, BLACK, " - Revision");
+ Console->LPrint(GREEN, BLACK, " %s", DefMain::Revision);
Console->LClose();
Config = new PConfig();