#include #include #include #include #include #include struct upc_type { char upc[30]; char name[80]; int quantity; int type; // 1:consumable 2:appliance float cost; int total_consumed; //how many of these have we discarded. struct //for adjustable rate products { int static_pos; int price_start; int price_end; }specials; int unit; // size of product. char unit_type[15]; // unit measurement (oz,cans, etc) int parent; // parent product (or -1 if none) struct // children products { int number; int quantity; }children[10]; int parent_type; }; struct upc_key_element { char upc[30]; int number; }; main() { int x,y,z; int handle; int size; struct upc_type upcdata; handle = open("/home/pjm/barcode.dat",O_RDONLY | O_CREAT); size = lseek(handle,0,2) / sizeof upcdata; close(handle); printf("Content-type: text/html\n"); printf("\n"); printf("\n"); printf("Generated Inventory Listing\n"); printf("\n"); printf("
\n"); printf("\n"); printf(" \n"); for(z=0;z"); load_upc(&upcdata,z); printf("",z); printf("",z); printf("",upcdata.name,upcdata.upc,upcdata.quantity); printf("\n"); } printf("
TrackNumberNameUPC CodeQuantity
%d%s%s%d
\n"); printf("\n"); } int load_upc(struct upc_type *upc, int number) { int x,y,z; int handle; handle = open("/home/pjm/barcode.dat",O_RDONLY | O_CREAT); z = lseek(handle,0,2) / sizeof *upc; if(number >= z) { printf("This number is too large.\n"); return(-1); } lseek(handle,number*sizeof *upc,0); read(handle,upc,sizeof *upc); close(handle); } int save_upc(struct upc_type *upc, int number,int mode) { int x,y,z; int handle; handle = open("/home/pjm/barcode.dat",O_WRONLY | O_CREAT); z = lseek(handle,0,2) / sizeof *upc; if(mode) // new { lseek(handle,0,2); number=z; } else { if(number >= z) { printf("This number is too large.\n"); return(-1); } lseek(handle,number*sizeof *upc,0); } write(handle,upc,sizeof *upc); close(handle); return(number); } load_keys(struct upc_key_element *keys) { } int find_upc(char upc[30]) { int x,y,z; int handle; struct upc_type upcdata; handle = open("/home/pjm/barcode.dat",O_RDONLY | O_CREAT); z = lseek(handle,0,2) / sizeof upcdata; close(handle); for(x=0;x