<commit_before>#include <dirent.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "fileio.h"
#include "hash.h"
#include "requests.h"


int socketlisten(int port) {
    int sockfd;
    struct sockaddr_in serv_addr;

    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd == -1) {
        return -1;
    }
    int yes = 1;
    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
    memset(&serv_addr, 0,sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(port);
    if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) == -1) {
        return -1;
    }
    if (listen(sockfd, 5) < 0) {
        return -1;
    }
    return sockfd;
}

int main(void) {
    int sockfd, conn;
    socklen_t len;
    struct sockaddr_in6 claddr;
    struct HashMap *h;
    char buffer[1024];

    /* Bind to our HTTP socket */
    if ((sockfd = socketlisten( /* config */ 80)) == -1) {
        perror("Couldn't connect to socket");
        exit(1);
    }

    len = sizeof(struct sockaddr_in6);
    /* Server loop */
    while (1) {
        /* clear the buffer between requests */
        memset(&buffer, 0, 1024);
        if ((conn = accept(sockfd, (struct sockaddr*) &claddr, &len)) < 0) {
            perror("Error receiving on socket");
            break;
        }
        if (recv(conn, buffer, 1024, 0) < 0) {
            perror("Error receiving on socket");
            break;
        }
        h = parse_header(buffer);
        hash_insert(h, "wut", "woah");
        char *hashval;
        if ((hashval = hash_get(h, "wut")) == NULL) {
            printf("ERROR\n");
        } else {
            printf("%s\n", hashval);
        }
        if (respond_with_file(conn, "server.c") < 0) {
            perror("Error sending on socket");
            break;
        }
    }

    if (close(sockfd) != 0) {
        perror("Error closing file");
    }
    return 0;
}<commit_msg>Removed unused hashmap.<commit_after>#include <dirent.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "fileio.h"
#include "hash.h"
#include "requests.h"


int socketlisten(int port) {
    int sockfd;
    struct sockaddr_in serv_addr;

    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd == -1) {
        return -1;
    }
    int yes = 1;
    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
    memset(&serv_addr, 0,sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(port);
    if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) == -1) {
        return -1;
    }
    if (listen(sockfd, 5) < 0) {
        return -1;
    }
    return sockfd;
}

int main(void) {
    int sockfd, conn;
    socklen_t len;
    struct sockaddr_in6 claddr;
    char buffer[1024];

    /* Bind to our HTTP socket */
    if ((sockfd = socketlisten( /* config */ 80)) == -1) {
        perror("Couldn't connect to socket");
        exit(1);
    }

    len = sizeof(struct sockaddr_in6);
    /* Server loop */
    while (1) {
        /* clear the buffer between requests */
        memset(&buffer, 0, 1024);
        if ((conn = accept(sockfd, (struct sockaddr*) &claddr, &len)) < 0) {
            perror("Error receiving on socket");
            break;
        }
        if (recv(conn, buffer, 1024, 0) < 0) {
            perror("Error receiving on socket");
            break;
        }
        if (respond_with_file(conn, "server.c") < 0) {
            perror("Error sending on socket");
            break;
        }
    }

    if (close(sockfd) != 0) {
        perror("Error closing file");
    }
    return 0;
}
{'fraction_non_alphanumeric': 0.14893617021276595, 'fraction_numerical': 0.0182370820668693, 'mean_word_length': 2.2636363636363637, 'pattern_counts': {'":': 0, '<': 29, '<?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': '3556566', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1385, 'n_words': 337}