summaryrefslogtreecommitdiff
path: root/src/greeting.cc
blob: bd7ad51dd85c66dfcff7c6cb7deb5afb8b676a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
 *  @file greeting.cc
 *  @brief Implementation of the inital greeting.
 *  @author Andreas Aardal Hanssen
 *  @date 2002-2005
 */

#include "globals.h"
#include "iodevice.h"
#include "iofactory.h"
#include "session.h"

#include <time.h>

using namespace Binc;

static const unsigned int ISO8601SIZE = 32;

namespace Binc {
  void showGreeting();
};

void Binc::showGreeting()
{
  Session &session = Session::getInstance();
  time_t t = time(nullptr);
  struct tm *mytm = localtime(&t);

  char mytime[ISO8601SIZE];
  unsigned int size = strftime(mytime, sizeof(mytime), "%Y-%m-%d %H:%M:%S %z", mytm);
  if (size >= sizeof(mytime) || size == 0) mytime[0] = 0;

  if (session.hasEnv("VERBOSE_GREETING")) {
    bincClient << "* OK Welcome to Binc IMAP " << BINC_VERSION << " " << IMAP_VERSION
               << " by Andreas Aardal Hanssen & Erwin Hoffmann at " << mytime << std::endl;
  } else {
    bincClient << "* OK Welcome to Binc IMAP at " << mytime << std::endl;
  }
}