/* supps.c */ #include #include #include "types.h" #include "supps.h" Snodeptr salloc(void) { return (Snodeptr) malloc(sizeof(struct snode)); } int hash(struct supp_element_type x) { int i, sum; sum = 0; for (i = 0; x.sno[i] != '\0'; i++) sum = sum + x.sno[i]; return (sum%MAXSIZE); } void makenull_supp(Snodeptr suppliers[]) { } int member_supp(struct supp_element_type x, Snodeptr suppliers[], Snodeptr *s) { } int insert_supp(struct supp_element_type x, Snodeptr suppliers[]) { } int delete_supp(struct supp_element_type x, Snodeptr suppliers[], Pnodeptr parts) { Snodeptr p,q; int b; int found; b = hash(x); if (suppliers[b] != NULL) { if (strcmp(suppliers[b]->supplier.sno,x.sno) == 0) { q = suppliers[b]; delete_all_supply_for_supplier(q,suppliers,parts); suppliers[b] = suppliers[b]->next; free(q); return TRUE; } else { p = suppliers[b]; found = FALSE; while ((p->next != NULL) && !found) if (strcmp(p->next->supplier.sno,x.sno) == 0) found = TRUE; else p = p->next; if (found) { q = p->next; delete_all_supply_for_supplier(q,suppliers,parts); p->next = p->next->next; free(q); return TRUE; } else return FALSE; } } else return FALSE; } void print_suppliers(Snodeptr suppliers[]) { } void delete_all_supply_for_supplier(Snodeptr q, Snodeptr suppliers[], Pnodeptr parts) { SPnodeptr r1,r2; r1 = q->first_sp; while (r1 != NULL) { r2 = r1->snext; delete_supply(q->supplier,r1->p_owner->part,suppliers,parts); r1 = r2; } }