|
Stock Control System
|
Stock Control System driver. More...
#include <errno.h>#include <limits.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "Pool.h"#include "Product.h"Go to the source code of this file.
Enumerations | |
| enum | MenuOption { MENU_INVALID , MENU_MANAGE_STOCK , MENU_GENERATE_REPORT , MENU_QUIT } |
| Represents all menu options on the interactive menu. More... | |
Functions | |
| static enum MenuOption | get_menu_selection () |
| Presents the user with a menu and interactively retrieves the selection. | |
| static size_t | get_input_line (char *const buffer, const size_t buffer_size, FILE *const stream) |
| Gets a single line of input from the given input and writes to the given buffer. | |
| static unsigned int | convert_to_uint (const char *const buffer, bool *error) |
| Converts the string in the given buffer to an unsigned integer. | |
| static int | convert_to_sint (const char *const buffer, bool *error) |
| Converts the string in the given buffer to a signed integer. | |
| static void | manage_stock (const struct Pool *const pool) |
| Interactively queries the user for a Product ID and an amount by which to modify the stock level. | |
| static void | generate_reports (const struct Pool *const pool) |
| Interactively query the user for an output file, and write a report to the chosen destination. | |
| static bool | load_inventory (FILE *const stock_file, struct Pool *const pool) |
| Parse the inventory from the given stock file into the given Pool. | |
| static FILE * | open_stock_file (const char *const filename) |
| Open the stock file with the given file name for reading, reporting errors as encountered. | |
| static void | save_inventory (FILE *const datafile, const struct Pool *const pool) |
| Save the inventory in the stock file format to the given file buffer. | |
| int | main (const int argc, const char **const argv) |
| The application entry point for interactive control of the Stock Control System. | |
Stock Control System driver.
Definition in file StockControlSystem.c.
| enum MenuOption |
Represents all menu options on the interactive menu.
| Enumerator | |
|---|---|
| MENU_INVALID | Placeholder invalid menu state. |
| MENU_MANAGE_STOCK | Manage Stock option. |
| MENU_GENERATE_REPORT | Generate Report option. |
| MENU_QUIT | Quit the Program option. |
Definition at line 29 of file StockControlSystem.c.
|
static |
Converts the string in the given buffer to a signed integer.
| buffer | The buffer containing the string representation of the signed integer. |
| error | Output error flag, indicating an error occurred during numerical parsing. |
Definition at line 138 of file StockControlSystem.c.
|
static |
Converts the string in the given buffer to an unsigned integer.
| buffer | The buffer containing the string representation of the unsigned integer. |
| error | Output error flag, indicating an error occurred during numerical parsing. |
Definition at line 117 of file StockControlSystem.c.
|
static |
Interactively query the user for an output file, and write a report to the chosen destination.
Definition at line 217 of file StockControlSystem.c.
|
static |
Gets a single line of input from the given input and writes to the given buffer.
| buffer | The destination buffer. |
| buffer_size | The maximum size in bytes of the destination buffer. |
| stream | The input stream. |
Definition at line 84 of file StockControlSystem.c.
|
static |
Presents the user with a menu and interactively retrieves the selection.
Definition at line 41 of file StockControlSystem.c.
|
static |
Parse the inventory from the given stock file into the given Pool.
| stock_file | The stock file containing name-quantity pair Product records, delimited with newline characters. |
| pool | The Pool into which the Product entries should be emplaced. |
Definition at line 241 of file StockControlSystem.c.
| int main | ( | const int | argc, |
| const char **const | argv | ||
| ) |
The application entry point for interactive control of the Stock Control System.
| argc | The number of command-line arguments provided by the shell. |
| argv | The command-line arguments provided by the shell. |
Definition at line 322 of file StockControlSystem.c.
|
static |
Interactively queries the user for a Product ID and an amount by which to modify the stock level.
Definition at line 157 of file StockControlSystem.c.
|
static |
Open the stock file with the given file name for reading, reporting errors as encountered.
| filename | The path on the filesystem, relative to the current working directory, of the stock file to open. |
Definition at line 282 of file StockControlSystem.c.
|
static |
Save the inventory in the stock file format to the given file buffer.
| datafile | The destination file for the inventory. |
| pool | The Pool containing the Product inventory items to be saved. |
Definition at line 310 of file StockControlSystem.c.