<commit_before>#ifndef __PHONE_HOME_H__
#define __PHONE_HOME_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include <jansson.h>
#include <time.h>

typedef struct _release Release;

struct _release {
    char *name;
    char *build_date;
    char *commit;
    char *url;
    void (*dispose)(Release *_this);
};

typedef struct _sized_buffer {
    char *buffer;
    size_t size;
} SizedBuffer;

void release_dispose(Release *_this)
{
    if (_this->name)
        free(_this->name);
    if (_this->build_date)
        free(_this->build_date);
    if (_this->commit)
        free(_this->commit);
    if (_this->url)
        free(_this->url);
}

static size_t git_data_write_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
{
    SizedBuffer *sbuf = (SizedBuffer *)userdata;
    size_t old_size, new_buf_size = size * nmemb;
    char *r_buf;

    if (ptr) {
        old_size = sbuf->size;
        r_buf = (char *)realloc(sbuf->buffer, old_size + new_buf_size);
        if (r_buf) {
            memcpy(r_buf + old_size, ptr, new_buf_size);
            sbuf->buffer = r_buf;
            sbuf->size += new_buf_size;
        } else {
            printf("buffer realloc failed\n");
        }
    }

    return new_buf_size;
}

static CURLcode git_request(const char *url, char **out_data)
{
    CURL *c_handle;
    CURLcode c_ret = CURLE_OK;
    SizedBuffer sized_buffer = { NULL, 0 };
    long resp_code;

    c_handle = curl_easy_init();
    if (!c_handle) {
        printf("curl_easy_init() failed: %s\n",
            curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_URL, url);
    if (c_ret != CURLE_OK) {
        printf("curl_easy_setop(with CURLOPT_URL) failed: %s\n",
               curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_SSL_VERIFYPEER, FALSE);
    if (c_ret != CURLE_OK) {
        printf("curl_easy_setop(with CURLOPT_SSL_VERIFYPEER) failed: %s\n",
               curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_USERAGENT, "pixelpulse2");
    if (c_ret != CURLE_OK) {
        printf("curl_easy_setop(with CURLOPT_USERAGENT) failed: %s\n",
               curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_WRITEFUNCTION, git_data_write_cb);
    if (c_ret != CURLE_OK) {<commit_msg>Fix: Use "false" boolean literal instead of "FALSE" otherwise this will break the linux build process<commit_after>#ifndef __PHONE_HOME_H__
#define __PHONE_HOME_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include <jansson.h>
#include <time.h>

typedef struct _release Release;

struct _release {
    char *name;
    char *build_date;
    char *commit;
    char *url;
    void (*dispose)(Release *_this);
};

typedef struct _sized_buffer {
    char *buffer;
    size_t size;
} SizedBuffer;

void release_dispose(Release *_this)
{
    if (_this->name)
        free(_this->name);
    if (_this->build_date)
        free(_this->build_date);
    if (_this->commit)
        free(_this->commit);
    if (_this->url)
        free(_this->url);
}

static size_t git_data_write_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
{
    SizedBuffer *sbuf = (SizedBuffer *)userdata;
    size_t old_size, new_buf_size = size * nmemb;
    char *r_buf;

    if (ptr) {
        old_size = sbuf->size;
        r_buf = (char *)realloc(sbuf->buffer, old_size + new_buf_size);
        if (r_buf) {
            memcpy(r_buf + old_size, ptr, new_buf_size);
            sbuf->buffer = r_buf;
            sbuf->size += new_buf_size;
        } else {
            printf("buffer realloc failed\n");
        }
    }

    return new_buf_size;
}

static CURLcode git_request(const char *url, char **out_data)
{
    CURL *c_handle;
    CURLcode c_ret = CURLE_OK;
    SizedBuffer sized_buffer = { NULL, 0 };
    long resp_code;

    c_handle = curl_easy_init();
    if (!c_handle) {
        printf("curl_easy_init() failed: %s\n",
            curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_URL, url);
    if (c_ret != CURLE_OK) {
        printf("curl_easy_setop(with CURLOPT_URL) failed: %s\n",
               curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_SSL_VERIFYPEER, false);
    if (c_ret != CURLE_OK) {
        printf("curl_easy_setop(with CURLOPT_SSL_VERIFYPEER) failed: %s\n",
               curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_USERAGENT, "pixelpulse2");
    if (c_ret != CURLE_OK) {
        printf("curl_easy_setop(with CURLOPT_USERAGENT) failed: %s\n",
               curl_easy_strerror(c_ret));
        goto cleanup;
    }

    c_ret = curl_easy_setopt(c_handle, CURLOPT_WRITEFUNCTION, git_data_write_cb);
    if (c_ret != CURLE_OK) {
{'fraction_non_alphanumeric': 0.11895241903238704, 'fraction_numerical': 0.0007996801279488205, 'mean_word_length': 2.8425499231950844, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 39, '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': '2180590', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1814, 'n_words': 373}