/**************************
 * Owen Sullivan
 * CPSC 2310 Fall 22
 * UserName: opsulli
 * Instructor:  Dr. Yvon Feaster
*************************/

#ifndef FUNCTIONS_H
#define FUNCTIONS_H

#include <stdio.h> // for fprintf and file I/O
#include <assert.h>
#include <stdlib.h>
#include <string.h> // for strcpy

// BDay struct with day, month, and year
struct BDay {

    int day;
    int month;
    int year;

};

// Node struct with firstName, lastName, favoriteSong, favoritePastime,
// whyCS, an instance of BDay, and a self-referencing pointer
typedef struct Node {

    char firstName[20];
    char lastName[20];
    char favoriteSong[100];
    char favoritePastime[100];
    char whyCS[500];
    struct BDay birthday;
    struct Node *next;

} node_t;

/* Parameters: **node - node pointer, passed from createList as the node to
                        be added to the existing linked list, parametized
                        as double pointer to allow passing by pointer
               **head - node pointer, passed from createList as the beginning
                        of the linked list, paramaterized as double pointer
                        to allow passing by pointer
 * Returns:    N/A - function is of type void
 * This function adds the specified node to the existing linked list. If the
   linked list is empty, it simply replaces the head node with the specified
   node.
 */
void add(node_t **node, node_t **head);

/* Parameters: *inFile - FILE pointer pointing to the memory address of the open
                         input file, supplied at runtime as a
                         command-line argument
 * Returns:    node - linked list node created by this function, populated with
                      data scanned from input file
 * This function reads data from the input file using scansets to separate data
   by commas and new lines (at the end). The data is scanned into member
   variables for a newly created node.
 */
node_t* readNodeInfo(FILE *input);

/* Parameters: *inFile - FILE pointer pointing to the memory address of the open
                         input file, supplied at runtime as a
                         command-line argument
               **head - node pointer, passed from main as the beginning
                        of the linked list, paramaterized as double pointer
                        to allow passing by pointer
 * Returns:    *head - node pointer that points to the start of the linked list
                       that this function creates
 * This function creates a linked list by calling readNodeInfo and adding the
   returned pointer to the list.
 */
node_t* createList(FILE*, node_t**);

/* Parameters: *outFile - FILE pointer pointing to the memory address of the open
                          output file, supplied at runtime as a
                          command-line argument
               *head - node pointer, passed from main as the beginning
                       of the linked list
 * Returns:    N/A - function is of type void
 * This function prints the data from each node in the linked list, after
   printing borders by calling printBorder.
 */
void printList(FILE*, node_t*);

/* Parameters: *outFile - FILE pointer pointing to the memory address of the
                          open output file, supplied at runtime as a
                          command-line argument
 * Returns:    N/A - function is of type void
 * This function prints the asterisk character 80 times on a single line
   to the specified file.
 */
void printBorder(FILE*);

/* Parameters: **head - node pointer, passed from main as the beginning
                        of the linked list, paramaterized as double pointer
                        to allow passing by pointer
 * Returns:    N/A - function is of type void
 * This function frees the memory for each node in the linked list.
 */
void deleteList(node_t**);

#endif