/* * YOU NEED TO DOCUMENT THIS INTERFACE FILE, INCLUDING THE CONSTANTS, * TYPES AND FUNCTION PROTOTYPES. FOR THE PROTOTYPES, YOU SHOULD * DOCUMENT HOW THEY SHOULD BE USED BY A MAIN PROGRAM. * * DON'T FORGET TO "WRAP" THIS HEADER FILE (SEE LAB 4). */ #define INVENT_NO_ROOM -1 #define INVENT_NO_SUCH_ITEM -2 #define INVENT_PRICE_MISMATCH -3 #define INVENT_NOT_ENOUGH -4 #define INVENT_FILE_ERROR -5 #define MAX_INVENTORY 200 #define NAME_MAX 20 typedef struct { char name[NAME_MAX+1]; /* One extra for the '\0' character. */ int count; /* Number of units in stock. */ int price; /* Cost of a single unit in cents. */ } itemT; typedef struct { itemT items[MAX_INVENTORY]; /* Stores all the items. */ int howmany; /* How many items currently in inventory. */ } inventoryT; /* * SOME FUNCTIONS BELOW MUST RECEIVE INVENTORY BY REFERENCE SINCE * THEY CHANGE INVENTORY. FOR CONSISTENCY, ALL FUNCTIONS TAKE * INVENTORY BY REFERENCE (WHETHER THEY CHANGE INVENTORY OR NOT)... * BESIDES, IT'S MORE EFFICIENT THAT WAY. */ /* * Function: InventoryInitialize * Usage: InventoryInitialize(&list); * -------------------------- * HERE WE DESCRIBE HOW TO USE THIS FUNCTION. ALSO, WE SHOULD * DESCRIBE WHAT IT DOES FROM A "HIGH LEVEL", I.E., DON'T DESCRIBE * THE INNER DETAILS OF WHAT IT DOES HERE, THOSE COMMENTS GO IN THE * IMPLEMENTATION FILE. * * This procedure initializes an inventory variable so that it * represents an empty inventory. */ void InventoryInitialize(inventoryT *listP); int InventoryAddItems(inventoryT *listP, itemT item); int InventoryRemoveItems(inventoryT *listP, itemT item); int InventoryGetPrice(inventoryT *listP, itemT item); int InventorySetPrice(inventoryT *listP, itemT item); int InventoryReadFromFile(inventoryT *listP, char filename[]);