##include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "imageInput.h"

#define BUFFER_SIZE 100
#define FILE_HEADER_STRING "__info2_image_file_format__"


/*
 * Hilfsfunktionen 
 */


static FILE *openImageFile(const char *path) // Checks if the given filename pointer is valid (not NULL).
{  
if (path == NULL)
    {
        return NULL;
    }

    return fopen(path, "rb");  //opening document in binear 
}

static int readAndCheckHeader(FILE *file) // gets the length of the header text
{
    size_t headerLength = strlen(FILE_HEADER_STRING);
    char buffer[BUFFER_SIZE];

    if (headerLength + 1 > BUFFER_SIZE) //checks if buffer is big enough for header size
    {
        return 0;
    }

    if (fread(buffer, 1, headerLength, file) != headerLength) // Checks if reading the expected number of header bytes from the file succeeded

        return 0;
    

    buffer[headerLength] = '\0'; // add string terminator so the header becomes a valid C-string

    if (strcmp(buffer, FILE_HEADER_STRING) != 0) // checks if the expected header matches the header read from the file

    {
        return 0;
    }

    return 1; /* Header ok */
}




static int readImageMetaData(FILE *file, // reads the metadata (count, width, height) from the file and stores them in the provided pointers
                             unsigned short *count,
                             unsigned short *width,
                             unsigned short *height)
{






    /*
    Hauptfunktion
    */




    