File: init.cc

package info (click to toggle)
golang-github-google-certificate-transparency 0.0~git20160709.0.0f6e3d1~ds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 5,676 kB
  • sloc: cpp: 35,278; python: 11,838; java: 1,911; sh: 1,885; makefile: 950; xml: 520; ansic: 225
file content (80 lines) | stat: -rw-r--r-- 1,631 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "util/init.h"

#include <event2/thread.h>
#include <evhtp.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <unistd.h>
#include <string>

#include "config.h"
#include "log/ct_extensions.h"
#include "proto/cert_serializer.h"
#include "version.h"

using std::string;

namespace util {


namespace {


void LibEventLog(int severity, const char* msg) {
  const string msg_s(msg);
  switch (severity) {
    case EVENT_LOG_DEBUG:
      VLOG(1) << msg_s;
      break;
    case EVENT_LOG_MSG:
      LOG(INFO) << msg_s;
      break;
    case EVENT_LOG_WARN:
      LOG(WARNING) << msg_s;
      break;
    case EVENT_LOG_ERR:
      LOG(ERROR) << msg_s;
      break;
    default:
      LOG(ERROR) << "LibEvent(?): " << msg_s;
      break;
  }
}


}  // namespace


void InitCT(int* argc, char** argv[]) {
  google::SetVersionString(cert_trans::kBuildVersion);
  google::ParseCommandLineFlags(argc, argv, true);
  google::InitGoogleLogging(*argv[0]);
  google::InstallFailureSignalHandler();

  event_set_log_callback(&LibEventLog);

  evthread_use_pthreads();
  // Set-up OpenSSL for multithreaded use:
  evhtp_ssl_use_threads();

  OpenSSL_add_all_algorithms();
  ERR_load_BIO_strings();
  ERR_load_crypto_strings();
  SSL_load_error_strings();
  SSL_library_init();

  cert_trans::LoadCtExtensions();

  LOG(INFO) << "Build version: " << google::VersionString();
#ifdef ENABLE_HARDENING
  LOG(INFO) << "Binary built with hardening enabled.";
#else
  LOG(WARNING) << "Binary built with hardening DISABLED.";
#endif
}


}  // namespace util