<commit_before>/*
Fiche - Command line pastebin for sharing terminal output.

-------------------------------------------------------------------------------

License: MIT (http://www.opensource.org/licenses/mit-license.php)
Repository: https://github.com/solusipse/fiche/
Live example: http://code.solusipse.net/

-------------------------------------------------------------------------------

usage: fiche [-bdpqs].
             [-d host_domain.com] [-p port] [-s slug_size]
             [-o output_directory] [-b buffer_size] [-q queue_size]

Compile with Makefile or manually with -O2 and -pthread flags.
To install use `make install` command.

Use netcat to push text - example:

$ cat fiche.c | nc localhost 9999

-------------------------------------------------------------------------------
*/

#include "fiche.h"

int main(int argc, char **argv)
{
    time_seed = time(0);

    set_basedir();
    parse_parameters(argc, argv);
    startup_message();

    int listen_socket, address_lenght, optval = 1;
    struct sockaddr_in server_address;

    listen_socket = create_socket();
    setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval , sizeof(int));

    server_address = set_address(server_address);
    bind_to_port(listen_socket, server_address);

    while (1) perform_connection(listen_socket);
}

void *thread_connection(void *args)
{
    char buffer[BUFSIZE];
    int n, client = *(int *)args;
    bzero(buffer, BUFSIZE);

    int status = recv(client, buffer, BUFSIZE, 0);

    if (status != -1)<commit_msg>changed order of setting BASEDIR variable<commit_after>/*
Fiche - Command line pastebin for sharing terminal output.

-------------------------------------------------------------------------------

License: MIT (http://www.opensource.org/licenses/mit-license.php)
Repository: https://github.com/solusipse/fiche/
Live example: http://code.solusipse.net/

-------------------------------------------------------------------------------

usage: fiche [-bdpqs].
             [-d host_domain.com] [-p port] [-s slug_size]
             [-o output_directory] [-b buffer_size] [-q queue_size]

Compile with Makefile or manually with -O2 and -pthread flags.
To install use `make install` command.

Use netcat to push text - example:

$ cat fiche.c | nc localhost 9999

-------------------------------------------------------------------------------
*/

#include "fiche.h"

int main(int argc, char **argv)
{
    time_seed = time(0);

    parse_parameters(argc, argv);
    if (BASEDIR == NULL)
        set_basedir();
    
    startup_message();

    int listen_socket, address_lenght, optval = 1;
    struct sockaddr_in server_address;

    listen_socket = create_socket();
    setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval , sizeof(int));

    server_address = set_address(server_address);
    bind_to_port(listen_socket, server_address);

    while (1) perform_connection(listen_socket);
}

void *thread_connection(void *args)
{
    char buffer[BUFSIZE];
    int n, client = *(int *)args;
    bzero(buffer, BUFSIZE);

    int status = recv(client, buffer, BUFSIZE, 0);

    if (status != -1)
{'fraction_non_alphanumeric': 0.2537974683544304, 'fraction_numerical': 0.006329113924050633, 'mean_word_length': 1.9736594543744121, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4246913', 'n_tokens_mistral': 927, 'n_tokens_neox': 900, 'n_words': 241}