<commit_before>//! @file getcomputername.cpp
//! @author <NAME> <<EMAIL>>
//! @brief Implements GetComputerName Win32 API

#include <errno.h>
#include <langinfo.h>
#include <locale.h>
#include <unistd.h>
#include <string>
#include <iostream>
#include "getcomputername.h"

//! @brief GetComputerName retrieves the name of the host associated with
//! the current thread.
//!
//! @exception errno Passes these errors via errno to GetLastError:
//! - ERROR_BAD_ENVIRONMENT: locale is not UTF-8
//! - ERROR_INVALID_FUNCTION: getlogin_r() returned an unrecognized error code
//! - ERROR_INVALID_ADDRESS:  buffer is an invalid address
//! - ERROR_GEN_FAILURE: buffer not large enough
//!
//! @retval username as UTF-8 string, or null if unsuccessful

char* GetComputerName()
{
    errno = 0;
    
    // Select locale from environment
    setlocale(LC_ALL, "");
    // Check that locale is UTF-8
    if (nl_langinfo(CODESET) != std::string("UTF-8"))
    {
        errno = ERROR_BAD_ENVIRONMENT;
        return FALSE;
    }
    
    // Get computername from system in a thread-safe manner
    std::string computername(HOST_NAME_MAX, 0);
    int err = gethostname(&computername[0], computername.length());
    // Map errno to Win32 Error Codes
    if (err != 0) 
    {
        switch (errno) 
        {
            case EFAULT:
                errno = ERROR_INVALID_ADDRESS;
                break;
            case ENAMETOOLONG:
                errno = ERROR_GEN_FAILURE;
                break; 
            default:
                errno = ERROR_INVALID_FUNCTION;
        }
        return FALSE;
    }
    
    return strdup(computername.c_str());
    
}

<commit_msg>Remove <iostream><commit_after>//! @file getcomputername.cpp
//! @author <NAME> <<EMAIL>>
//! @brief Implements GetComputerName Win32 API

#include <errno.h>
#include <langinfo.h>
#include <locale.h>
#include <unistd.h>
#include <string>
#include "getcomputername.h"

//! @brief GetComputerName retrieves the name of the host associated with
//! the current thread.
//!
//! @exception errno Passes these errors via errno to GetLastError:
//! - ERROR_BAD_ENVIRONMENT: locale is not UTF-8
//! - ERROR_INVALID_FUNCTION: getlogin_r() returned an unrecognized error code
//! - ERROR_INVALID_ADDRESS:  buffer is an invalid address
//! - ERROR_GEN_FAILURE: buffer not large enough
//!
//! @retval username as UTF-8 string, or null if unsuccessful

char* GetComputerName()
{
    errno = 0;
    
    // Select locale from environment
    setlocale(LC_ALL, "");
    // Check that locale is UTF-8
    if (nl_langinfo(CODESET) != std::string("UTF-8"))
    {
        errno = ERROR_BAD_ENVIRONMENT;
        return FALSE;
    }
    
    // Get computername from system in a thread-safe manner
    std::string computername(HOST_NAME_MAX, 0);
    int err = gethostname(&computername[0], computername.length());
    // Map errno to Win32 Error Codes
    if (err != 0) 
    {
        switch (errno) 
        {
            case EFAULT:
                errno = ERROR_INVALID_ADDRESS;
                break;
            case ENAMETOOLONG:
                errno = ERROR_GEN_FAILURE;
                break; 
            default:
                errno = ERROR_INVALID_FUNCTION;
        }
        return FALSE;
    }
    
    return strdup(computername.c_str());
    
}


{'fraction_non_alphanumeric': 0.10980036297640654, 'fraction_numerical': 0.007259528130671506, 'mean_word_length': 2.416322314049587, 'pattern_counts': {'":': 0, '<': 21, '<?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': '3365329', 'n_tokens_mistral': 1053, 'n_tokens_neox': 975, 'n_words': 285}