00001
00002
00003
00004
00005
00006
00007
00008 #include <db.h>
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 #include <string.h>
00012
00013 #ifdef _WIN32
00014 extern int getopt(int, char * const *, const char *);
00015 extern char *optarg;
00016 #define snprintf _snprintf
00017 #else
00018 #include <unistd.h>
00019 #endif
00020
00021 #define DEFAULT_HOMEDIR "./"
00022 #define INVENTORY_FILE "inventory.txt"
00023 #define VENDORS_FILE "vendors.txt"
00024 #define INVENTORYDB "inventoryDB.db"
00025 #define ITEMNAMEDB "itemnameDB.db"
00026 #define MAXDATABUF 1024
00027 #define MAXFIELD 20
00028 #define MAXLINE 150
00029 #define PRIMARY_DB 0
00030 #define SECONDARY_DB 1
00031 #define VENDORDB "vendorDB.db"
00032
00033 typedef struct stock_dbs {
00034 DB *inventory_dbp;
00035 DB *vendor_dbp;
00036 DB *itemname_sdbp;
00037
00038 char *db_home_dir;
00039 char *itemname_db_name;
00040 char *inventory_db_name;
00041 char *vendor_db_name;
00042 } STOCK_DBS;
00043
00044 typedef struct vendor {
00045 char name[MAXFIELD];
00046 char street[MAXFIELD];
00047 char city[MAXFIELD];
00048 char state[3];
00049 char zipcode[6];
00050 char phone_number[13];
00051 char sales_rep[MAXFIELD];
00052 char sales_rep_phone[MAXFIELD];
00053 } VENDOR;
00054
00055
00056 int databases_close(STOCK_DBS *);
00057 int databases_setup(STOCK_DBS *, const char *, FILE *);
00058 void initialize_stockdbs(STOCK_DBS *);
00059 int open_database(DB **, const char *, const char *, FILE *, int);
00060 void set_db_filenames(STOCK_DBS *my_stock);