<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include "header.h"

/**
 * Displays the usage information and returns an error exit code
 * @return exit code 1
 */
int displayUsage();

int main(int argc, char* argv[]) {

    int targetFormat;
    char* inputFilename;
    char* outputFilename;
    FILE *filePointer;
    PpmHeader inputHeaderInformation;

    // Validate argument count
    if (argc != 4)
        return displayUsage();

    // Validate target format parameter
    targetFormat = atoi(argv[1]);
    if (targetFormat != 3 && targetFormat != 6) {
        printf("Invalid parameter target_format = '%s', expected 3 or 6.\n", argv[1]);
        return displayUsage();
    }

    inputFilename = argv[2];
    outputFilename = argv[3];

    // Open input file
    printf("Processing input file.\n");
    filePointer = fopen(inputFilename, "r");
    if (filePointer == NULL) {
        printf("File '%s' does not exist or cannot be opened. Error number %d.\n", inputFilename, errno);
        return displayUsage();
    }

    // Read input image file's headers
    if (!header_read(filePointer, &inputHeaderInformation)) {
        printf("Unable to continue processing image file.\n");
        return displayUsage();
    }
    printf("Detected file with dimensions %u x %u of type P%d, maxval=%hu.\n",
           inputHeaderInformation.imageWidth,
           inputHeaderInformation.imageHeight,
           inputHeaderInformation.ppmType,
           inputHeaderInformation.maxVal);

    // Close input file
    fclose(filePointer);
    printf("Input file processed.\n");
<commit_msg>Create & allocate pixel grid from header information<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include "header.h"
#include "helpers.h"

/**
 * Displays the usage information and returns an error exit code
 * @return exit code 1
 */
int displayUsage();

int main(int argc, char* argv[]) {

    int targetFormat;
    char* inputFilename;
    char* outputFilename;
    FILE *filePointer;
    PpmHeader fileHeader;
    ColorRef pixelGrid;

    // Validate argument count
    if (argc != 4)
        return displayUsage();

    // Validate target format parameter
    targetFormat = atoi(argv[1]);
    if (targetFormat != 3 && targetFormat != 6) {
        printf("Invalid parameter target_format = '%s', expected 3 or 6.\n", argv[1]);
        return displayUsage();
    }

    inputFilename = argv[2];
    outputFilename = argv[3];

    // Open input file
    printf("Processing input file.\n");
    filePointer = fopen(inputFilename, "r");
    if (filePointer == NULL) {
        printf("File '%s' does not exist or cannot be opened. Error number %d.\n", inputFilename, errno);
        return displayUsage();
    }

    // Read input image file's headers
    if (!header_read(filePointer, &fileHeader)) {
        printf("Unable to continue processing image file.\n");
        return displayUsage();
    }
    printf("Detected file with dimensions %u x %u of type P%d, maxval=%hu.\n",
           fileHeader.imageWidth,
           fileHeader.imageHeight,
           fileHeader.ppmType,
           fileHeader.maxVal);

    // Create the pixel grid in memory
    pixelGrid = malloc(sizeof(Color) * fileHeader.imageWidth * fileHeader.imageHeight);

    // Close input file
    fclose(filePointer);
    printf("Input file processed.\n");

    // Deallocate the pixel grid
    free(pixelGrid);

{'fraction_non_alphanumeric': 0.11869349664625255, 'fraction_numerical': 0.0058326042578011085, 'mean_word_length': 2.884484711211778, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7667052', 'n_tokens_mistral': 983, 'n_tokens_neox': 945, 'n_words': 305}