bf15a5ac12
GitOrigin-RevId: 632e05de183a55b045f74e09ca8d41060f55ad41
48 lines
964 B
C++
48 lines
964 B
C++
//
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
#include "td/utils/port/StdStreams.h"
|
|
|
|
namespace td {
|
|
|
|
namespace {
|
|
template <class T>
|
|
FileFd create(T handle) {
|
|
return FileFd::from_native_fd(NativeFd(handle, true)).move_as_ok();
|
|
}
|
|
} // namespace
|
|
FileFd &Stdin() {
|
|
static FileFd res = create(
|
|
#if TD_PORT_POSIX
|
|
0
|
|
#elif TD_PORT_WINDOWS
|
|
GetStdHandle(STD_INPUT_HANDLE)
|
|
#endif
|
|
);
|
|
return res;
|
|
}
|
|
FileFd &Stdout() {
|
|
static FileFd res = create(
|
|
#if TD_PORT_POSIX
|
|
1
|
|
#elif TD_PORT_WINDOWS
|
|
GetStdHandle(STD_OUTPUT_HANDLE)
|
|
#endif
|
|
);
|
|
return res;
|
|
}
|
|
FileFd &Stderr() {
|
|
static FileFd res = create(
|
|
#if TD_PORT_POSIX
|
|
2
|
|
#elif TD_PORT_WINDOWS
|
|
GetStdHandle(STD_ERROR_HANDLE)
|
|
#endif
|
|
);
|
|
return res;
|
|
}
|
|
} // namespace td
|