/* * db.h - Parts database * * Copyright 2012 by Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #ifndef DB_H #define DB_H struct exchange { const struct currency *dst; double factor; struct exchange *next; }; struct currency { const char *name; struct exchange *exchange; struct currency *next; }; struct price { int qty; /* order quantity */ double value; /* per quantity cost */ const struct currency *curr; int fract; /* 0 if > qty at same price; 1 if multiples of qty */ struct price *next; /* next lower qty */ }; struct provider { const char *name; double shipping; /* S&H cost */ double minimum; /* minimum order */ const struct currency *curr; struct provider *next; }; struct stock { int avail; /* items in stock */ int package; /* "natural" quantity (reel, tray, bag, etc.) */ struct price *manual; /* single parts, for manual assembly only */ double reeling; /* cost of converting "manual" to "fab"; <0 if n/a */ struct price *fab; /* for automated assembly */ } stock; struct part { const char *domain; const char *name; struct param *param; /* NULL if @@@ */ struct stock *stock; /* NULL if vendor part */ struct part *next; /* alias loop (cyclic) */ struct part *prev; }; struct part *part_lookup(const char *domain, const char *name); struct part *part_add(const char *domain, const char *name); void part_alias(struct part *a, struct part *b); #endif /* !DB_H */