<commit_before>#include "stdafx.h"
#include "Wind_API.h"

#include "util.h"

#include "kdb+.util/util.h"
#include "kdb+.util/multilang.h"
#include "kdb+.util/type_convert.h"
#include <iostream>


WIND_API K K_DECL Wind_login(K username, K password) {
	std::wstring uid, pwd;
	try {
		uid = q::q2WString(username);
		pwd = q::q2WString(password);
	}
	catch (std::string const& error) {
		return q::error2q(error);
	}

	::WQAUTH_INFO login = { true };
	std::wmemset(login.strUserName, L'\0', _countof(login.strUserName));
	std::wmemset(login.strPassword, L'\0', _countof(login.strPassword));

	static_assert(std::is_same<std::wstring::value_type, TCHAR>::value, "UNICODE/_UNICODE not defined");
	if (uid.size() >= _countof(login.strUserName)) return q::error2q("username too long");
	if (pwd.size() >= _countof(login.strPassword)) return q::error2q("password too long");
#	ifdef _MSC_VER
	::wcsncpy_s(login.strUserName, uid.c_str(), uid.size());
	::wcsncpy_s(login.strPassword, pwd.c_str(), pwd.size());
#	else
	std::wcsncpy(login.strUserName, uid.c_str(), uid.size());
	std::wcsncpy(login.strPassword, pwd.c_str(), pwd.size());
#	endif

#	ifndef NDEBUG
	std::cerr << ">>> WDataAuthorize({\""
		<< login.strUserName << "\", \"" << login.strPassword
		<< "\"})" << std::endl;
#	endif
	::WQErr const error = ::WDataAuthorize(&login);
#	ifndef NDEBUG
	std::cerr << "<<< WDataAuthorize = " << error << std::endl;
#	endif
	if (error == WQERR_OK) {
		std::string const u = ml::convert(q::DEFAULT_CP, uid.c_str());
		std::cerr << "<Wind> logged in as " << u << std::endl;
		return ks(const_cast<S>(u.c_str()));
	}
	else {
		return q::error2q(Wind::util::error2Text(error));
	}
}

WIND_API K K_DECL Wind_logout(K _) {
	::WQErr const error = ::WDataAuthQuit();
	return (error == WQERR_OK) ? K_NIL : q::error2q(Wind::util::error2Text(error));
}<commit_msg>In debug mode, show actual WDataAuthorize params.<commit_after>#include "stdafx.h"
#include "Wind_API.h"

#include "util.h"

#include "kdb+.util/util.h"
#include "kdb+.util/multilang.h"
#include "kdb+.util/type_convert.h"
#include <iostream>


WIND_API K K_DECL Wind_login(K username, K password) {
	std::wstring uid, pwd;
	try {
		uid = q::q2WString(username);
		pwd = q::q2WString(password);
	}
	catch (std::string const& error) {
		return q::error2q(error);
	}

	::WQAUTH_INFO login = { true };
	std::wmemset(login.strUserName, L'\0', _countof(login.strUserName));
	std::wmemset(login.strPassword, L'\0', _countof(login.strPassword));

	static_assert(std::is_same<std::wstring::value_type, TCHAR>::value, "UNICODE/_UNICODE not defined");
	if (uid.size() >= _countof(login.strUserName)) return q::error2q("username too long");
	if (pwd.size() >= _countof(login.strPassword)) return q::error2q("password too long");
#	ifdef _MSC_VER
	::wcsncpy_s(login.strUserName, uid.c_str(), uid.size());
	::wcsncpy_s(login.strPassword, pwd.c_str(), pwd.size());
#	else
	std::wcsncpy(login.strUserName, uid.c_str(), uid.size());
	std::wcsncpy(login.strPassword, pwd.c_str(), pwd.size());
#	endif

#	ifndef NDEBUG
	std::wcerr << L">>> WDataAuthorize({\""
		<< login.strUserName << L"\", \"" << login.strPassword
		<< L"\"})" << std::endl;
#	endif
	::WQErr const error = ::WDataAuthorize(&login);
#	ifndef NDEBUG
	std::wcerr << L"<<< WDataAuthorize = " << error << std::endl;
#	endif
	if (error == WQERR_OK) {
		std::string const u = ml::convert(q::DEFAULT_CP, uid.c_str());
		std::cerr << "<Wind> logged in as " << u << std::endl;
		return ks(const_cast<S>(u.c_str()));
	}
	else {
		return q::error2q(Wind::util::error2Text(error));
	}
}

WIND_API K K_DECL Wind_logout(K _) {
	::WQErr const error = ::WDataAuthQuit();
	return (error == WQERR_OK) ? K_NIL : q::error2q(Wind::util::error2Text(error));
}
{'fraction_non_alphanumeric': 0.2026809651474531, 'fraction_numerical': 0.005898123324396783, 'mean_word_length': 5.6387900355871885, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 21, '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': '3672489', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1501, 'n_words': 272}