Added rmanager "date" command to show current date / time.
git-svn-id: http://yate.null.ro/svn/yate/trunk@6465 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
a017421895
commit
6097706c14
|
@ -26,6 +26,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
@ -48,6 +49,18 @@ namespace { // anonymous
|
||||||
#define DEF_HISTORY 10
|
#define DEF_HISTORY 10
|
||||||
#define MAX_HISTORY 50
|
#define MAX_HISTORY 50
|
||||||
|
|
||||||
|
static const TokenDict s_timeFmts[] =
|
||||||
|
{
|
||||||
|
{ "date and time not logged", Debugger::None },
|
||||||
|
{ "seconds from program start", Debugger::Relative },
|
||||||
|
{ "seconds from UNIX EPOCH", Debugger::Absolute },
|
||||||
|
{ "UTC without separators", Debugger::Textual },
|
||||||
|
{ "local time without separators", Debugger::TextLocal },
|
||||||
|
{ "UTC with separators", Debugger::TextSep },
|
||||||
|
{ "local time with separators", Debugger::TextLSep },
|
||||||
|
{ 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
enum Level {
|
enum Level {
|
||||||
None = 0,
|
None = 0,
|
||||||
User,
|
User,
|
||||||
|
@ -121,6 +134,7 @@ static const CommandInfo s_cmdInfo[] =
|
||||||
// User commands
|
// User commands
|
||||||
{ User, "status", "[overview] [modulename]", s_oview, "Shows status of all or selected modules or channels" },
|
{ User, "status", "[overview] [modulename]", s_oview, "Shows status of all or selected modules or channels" },
|
||||||
{ User, "uptime", 0, 0, "Show information on how long Yate has run" },
|
{ User, "uptime", 0, 0, "Show information on how long Yate has run" },
|
||||||
|
{ User, "date", 0, 0, "Show current logging date, time and format" },
|
||||||
{ User, "machine", "[on|off]", s_bools, "Show or turn machine output mode on or off" },
|
{ User, "machine", "[on|off]", s_bools, "Show or turn machine output mode on or off" },
|
||||||
{ User, "output", "[on|off]", s_bools, "Show or turn local output on or off" },
|
{ User, "output", "[on|off]", s_bools, "Show or turn local output on or off" },
|
||||||
{ User, "color", "[on|off]", s_bools, "Show status or turn local colorization on or off" },
|
{ User, "color", "[on|off]", s_bools, "Show status or turn local colorization on or off" },
|
||||||
|
@ -1464,6 +1478,28 @@ bool Connection::processCommand(const char *line, bool saveLine)
|
||||||
writeStr(str);
|
writeStr(str);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (str.startSkip("date"))
|
||||||
|
{
|
||||||
|
Debugger::Formatting fmt = Debugger::getFormatting();
|
||||||
|
char buf[32];
|
||||||
|
Debugger::formatTime(buf,fmt);
|
||||||
|
str = buf;
|
||||||
|
switch (fmt) {
|
||||||
|
case Debugger::TextLocal:
|
||||||
|
case Debugger::TextLSep:
|
||||||
|
{
|
||||||
|
int tz = Time::timeZone() / 60;
|
||||||
|
::sprintf(buf,"%+03d:%02d ",tz / 60, ::abs(tz) % 60);
|
||||||
|
str << buf;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
str << "(" << lookup(fmt,s_timeFmts,"unknown format") << ")\r\n";
|
||||||
|
writeStr(str);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else if (str.startSkip("machine"))
|
else if (str.startSkip("machine"))
|
||||||
{
|
{
|
||||||
str >> m_machine;
|
str >> m_machine;
|
||||||
|
|
Loading…
Reference in New Issue