<commit_before>#include <iostream>
#include <string>

#include "help.h"

#include <libproc.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>

#define KwmDaemonPort 3020

int KwmcSockFD;

void Fatal(const std::string &err)
{
    std::cout << err << std::endl;
    exit(1);
}

std::string ReadFromSocket(int SockFD)
{
    std::string Message;
    char Cur;

    while(recv(SockFD, &Cur, 1, 0))
        Message += Cur;

    return Message;
}

void WriteToSocket(std::string Msg)
{
    send(KwmcSockFD, Msg.c_str(), Msg.size(), 0);

    std::string Response = ReadFromSocket(KwmcSockFD);
    if(!Response.empty())
        std::cout << Response << std::endl;

    shutdown(KwmcSockFD);
    close(KwmcSockFD);
}

void KwmcForwardMessageThroughSocket(int argc, char **argv)
{
    std::string Msg;
    for(int i = 1; i < argc; ++i)
    {
        Msg += argv[i];

        if(i < argc - 1)
            Msg += " ";
    }<commit_msg>kwmc interpreter mode for remote control through ssh<commit_after>#include <iostream>
#include <string>

#include "help.h"

#include <libproc.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>

#define KwmDaemonPort 3020

int KwmcSockFD;

void Fatal(const std::string &err)
{
    std::cout << err << std::endl;
    exit(1);
}

std::string ReadFromSocket(int SockFD)
{
    std::string Message;
    char Cur;

    while(recv(SockFD, &Cur, 1, 0))
        Message += Cur;

    return Message;
}

void WriteToSocket(std::string Msg)
{
    send(KwmcSockFD, Msg.c_str(), Msg.size(), 0);

    std::string Response = ReadFromSocket(KwmcSockFD);
    if(!Response.empty())
        std::cout << Response << std::endl;

    shutdown(KwmcSockFD, SHUT_RDWR);
    close(KwmcSockFD);
}

void KwmcForwardMessageThroughSocket(int argc, char **argv)
{
    std::string Msg;
    for(int i = 1; i < argc; ++i)
    {
        Msg += argv[i];

        if(i < argc - 1)
            Msg += " ";
    }
{'fraction_non_alphanumeric': 0.16005946481665015, 'fraction_numerical': 0.009910802775024777, 'mean_word_length': 3.2327044025157234, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 19, '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': '1144745', 'n_tokens_mistral': 811, 'n_tokens_neox': 759, 'n_words': 170}