lc4-disassembler / lc4_loader.h
lc4_loader.h
Raw
#include "lc4_memory.h"

#include <stdio.h>

/* declarations of functions that must defined in lc4_loader.c */

/**
 * opens up name of the file passed in, returns a pointer
 * to the open file
 *
 * returns the FILE pointer upon success, else NULL.
 */
FILE *open_file(char *file_name);

/**
 * parses the given input file into an ordered (by memory address)
 * linked list with the passed in row_of_memory as the head.
 *
 * returns 0 upon successs, non-zero if an error occurs.
 */
int parse_file(FILE *my_obj_file, row_of_memory **memory);

/**
 * writes the contents of the linked list to the given file
 * in the correct format.
 *
 * returns 0 upon success, non-zero if an error occurs.
 */
int output_file(char *file_name, row_of_memory *memory);

/**
 * replaces the file extension of the given file name
 * with the given extension, if the current extension matches
 * the current extension.
 *
 * returns 0 upon success, non-zero if an error occurs.
 */
void replace_file_ext(char *file_name, char *curr_ext, char *new_ext);

/**
 * converts the given value to the given endian format and masks it
 *
 */
void convert_endian(unsigned short int *value, const short int endian);

/**
 * close input file, if fails, release LL memory and prints an error message
 *
 */
int close_file(FILE *file, row_of_memory **memory);