<commit_before>
#include <assert.h>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include "event_queue.hpp"
#include "worker_pool.hpp"
#include "fsm.hpp"

// Process commands received from the user
void process_command(char *buf, size_t size, event_queue_t *event_queue, event_t *event) {
    int res;
    
    if(size >= 4 && strncmp(buf, "quit", 4) == 0) {
        // Quit the server
        printf("Quitting server...\n");
        res = pthread_kill(event_queue->parent_pool->main_thread, SIGINT);
        check("Could not send kill signal to main thread", res != 0);
    }
    else {
        // TODO: do the whole read from file/send business
        printf("Gotta do smtg here...\n");
    }
}

// This state represents a connected socket with no outstanding
// operations. Incoming events should be user commands received by the
// socket.
void fsm_socket_connected(event_queue_t *event_queue, event_t *event) {
    size_t sz;
    char buf[256];

    // TODO: Are we checking for reading here? What about when socket<commit_msg>Send some dummy message to client for now<commit_after>
#include <assert.h>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include "event_queue.hpp"
#include "worker_pool.hpp"
#include "fsm.hpp"

// Process commands received from the user
void process_command(char *buf, size_t size, event_queue_t *event_queue, event_t *event) {
    int res;
    
    if(size >= 4 && strncmp(buf, "quit", 4) == 0) {
        // Quit the server
        printf("Quitting server...\n");
        res = pthread_kill(event_queue->parent_pool->main_thread, SIGINT);
        check("Could not send kill signal to main thread", res != 0);
    }
    else {
        // TODO: do the whole read from file/send business
        int sz = write(event->state->source, "Gotta do smtg here...", 21);
        check("Couldn't send message to client", sz != 21);
    }
}

// This state represents a connected socket with no outstanding
// operations. Incoming events should be user commands received by the
// socket.
void fsm_socket_connected(event_queue_t *event_queue, event_t *event) {
    size_t sz;
    char buf[256];

    // TODO: Are we checking for reading here? What about when socket
{'fraction_non_alphanumeric': 0.11947700631199279, 'fraction_numerical': 0.008115419296663661, 'mean_word_length': 3.202651515151515, 'pattern_counts': {'":': 0, '<': 11, '<?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': '851997', 'n_tokens_mistral': 711, 'n_tokens_neox': 686, 'n_words': 236}