/************************* 
 * Owen Sullivan
 * CPSC 2310-002
 * opsulli@clemson.edu
*************************/

#ifndef ENCODEDECODE_
#define ENCODEDECODE_

#include "ppm.h"

/* Parameters: number - integer that the number of digits will be counted for
 * Return:     numDigits - integer representing the number of digits in the 
                           input number
 * This function counts the number of digits in an integer.
*/
int numDigits(int number);

/* Parameters: inFile - FILE pointer representing an input file
               outFile - FILE pointer representing an output file
 * Return:     N/A - function is of type void
 * This function presents the user with a menu allowing them to encode either 
 * a pre-selected message or their own custom message.
*/
void promptMenu(FILE *inFile, FILE *outFile);

/* Parameters: inFile - FILE pointer that points to all of the image data
                        in the input PPM file
               message - char array containing message to be encoded
               size - int representing the size of the message array
               outFile - FILE pointer representing an output file
 * Return:     N/A - function is of type void
 * This function reads in an input image, encodes a message in the pixel data, 
 * then creates a new output image with the encoded message.
*/
void encodeImage(FILE *inFile, char message[], int size, FILE *outFile);

/* Parameters: decimal - unsigned int that represents the decimal of a 9-bit 
                         binary sequence
 * Return:     binary - unsigned int pointer that holds a 9-bit
                        binary sequence
 * This function converts a decimal to a 9-bit binary representation in the 
 * form of a pointer acting as an array.
*/
unsigned int *decimalToBinary(unsigned int decimal);

/* Parameters: binary - unsigned int array that presumably holds a 9-bit
                        binary sequence
 * Return:     N/A - function is of type void
 * This function sets the values of a 9-bit binary sequence to all zeros so 
 * that the same array can be used multiple times when looping.
*/
void clearBinaryArray(unsigned int binary[]);

/* Parameters: binary - unsigned int array that presumably holds a 9-bit
                        binary sequence
 * Return:     decimal - unsigned int that represents the decimal of a 9-bit 
                         binary sequence
 * This function converts the contents of an array with a 9-bit binary 
 * sequence to decimal representation.
*/
unsigned int binaryToDecimal(unsigned int binary[]);

/* Parameters: header - header_t object containing header data
               image - pixel_t double pointer representing a PPM image pixel
                       array
               binary - unsigned int array that presumably holds a 9-bit
                        binary sequence
 * Return:     N/A - function is of type void
 * This function decodes the hidden message in blocks of 3 pixels and prints 
 * the decoded characters to stdout.
*/
void decodePixels(header_t header, pixel_t **image, unsigned int binary[]);

/* Parameters: inFile - FILE pointer representing an input file
 * Return:     N/A - function is of type void
 * This function reads in an input image and decodes the image's hidden
 * message.
*/
void decodeImage(FILE *inFile);

#endif