Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

gettingstarted_common.h

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2004-2005
00005  *      Sleepycat Software.  All rights reserved.
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; /* Database containing inventory information */
00035     DB *vendor_dbp;    /* Database containing vendor information */
00036     DB *itemname_sdbp; /* Index based on the item name index */
00037 
00038     char *db_home_dir;             /* Directory containing the database files */
00039     char *itemname_db_name;  /* Itemname secondary database */
00040     char *inventory_db_name; /* Name of the inventory database */
00041     char *vendor_db_name;    /* Name of the vendor database */
00042 } STOCK_DBS;
00043 
00044 typedef struct vendor {
00045     char name[MAXFIELD];             /* Vendor name */
00046     char street[MAXFIELD];           /* Street name and number */
00047     char city[MAXFIELD];             /* City */
00048     char state[3];                   /* Two-digit US state code */
00049     char zipcode[6];                 /* US zipcode */
00050     char phone_number[13];           /* Vendor phone number */
00051     char sales_rep[MAXFIELD];        /* Name of sales representative */
00052     char sales_rep_phone[MAXFIELD];  /* Sales rep's phone number */
00053 } VENDOR;
00054 
00055 /* Function prototypes */
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);

Generated on Sun Dec 25 12:14:25 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2