<commit_before>/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2014 <NAME>. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#include "xenia/base/main.h"

#include <fcntl.h>
#include <gflags/gflags.h>
#include <io.h>

#include <cstdlib>

// Autogenerated by `xb premake`.
#include "build/version.h"

#include "xenia/base/logging.h"
#include "xenia/base/platform_win.h"
#include "xenia/base/string.h"

#include <bcrypt.h>

DEFINE_bool(win32_high_freq, true,
            "Requests high performance from the NT kernel");

namespace xe {

bool has_console_attached_ = true;

bool has_console_attached() { return has_console_attached_; }

void AttachConsole() {
  bool has_console = ::AttachConsole(ATTACH_PARENT_PROCESS) == TRUE;
  if (!has_console) {
    // We weren't launched from a console, so just return.
    // We could alloc our own console, but meh:
    // has_console = AllocConsole() == TRUE;
    has_console_attached_ = false;
    return;
  }
  has_console_attached_ = true;

  FILE* dummy;
  freopen_s(&dummy, "CONIN$", "rb", stdin);
  freopen_s(&dummy, "CONOUT$", "wb", stdout);
  freopen_s(&dummy, "CONOUT$", "wb", stderr);

  setvbuf(stdout, nullptr, _IONBF, 0);<commit_msg>[Base] Undo last commit because it breaks file redirection.<commit_after>/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2014 <NAME>. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#include "xenia/base/main.h"

#include <fcntl.h>
#include <gflags/gflags.h>
#include <io.h>

#include <cstdlib>

// Autogenerated by `xb premake`.
#include "build/version.h"

#include "xenia/base/logging.h"
#include "xenia/base/platform_win.h"
#include "xenia/base/string.h"

#include <bcrypt.h>

DEFINE_bool(win32_high_freq, true,
            "Requests high performance from the NT kernel");

namespace xe {

bool has_console_attached_ = true;

bool has_console_attached() { return has_console_attached_; }

void AttachConsole() {
  bool has_console = ::AttachConsole(ATTACH_PARENT_PROCESS) == TRUE;
  if (!has_console) {
    // We weren't launched from a console, so just return.
    // We could alloc our own console, but meh:
    // has_console = AllocConsole() == TRUE;
    has_console_attached_ = false;
    return;
  }
  has_console_attached_ = true;

  auto std_handle = (intptr_t)GetStdHandle(STD_OUTPUT_HANDLE);
  auto con_handle = _open_osfhandle(std_handle, _O_TEXT);
  auto fp = _fdopen(con_handle, "w");
  *stdout = *fp;
  setvbuf(stdout, nullptr, _IONBF, 0);

  std_handle = (intptr_t)GetStdHandle(STD_ERROR_HANDLE);
  con_handle = _open_osfhandle(std_handle, _O_TEXT);
  fp = _fdopen(con_handle, "w");
  *stderr = *fp;
{'fraction_non_alphanumeric': 0.24470938897168407, 'fraction_numerical': 0.005961251862891207, 'mean_word_length': 4.092564491654021, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2198319', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1000, 'n_words': 254}