/* sp.c */ #include #include #include "types.h" #include "supps.h" #include "parts.h" #include "sp.h" SPnodeptr spalloc(void) { return (SPnodeptr) malloc(sizeof(struct spnode)); } int member_supply(struct supp_element_type x, struct part_element_type y, Snodeptr suppliers[], Pnodeptr parts) { Pnodeptr p; Snodeptr s; SPnodeptr sp; int found; if (member_supp(x,suppliers,&s) == TRUE) { if (member_part(y,parts,&p) == TRUE) { sp = s->first_sp; found = FALSE; while ((sp != NULL) && !found) if (strcmp(sp->p_owner->part.pno,y.pno) == 0) found = TRUE; else sp = sp->snext; return found; } else return FALSE; } else return FALSE; } int insert_supply(struct supp_element_type x, struct part_element_type y, Snodeptr suppliers[], Pnodeptr parts) { Pnodeptr p; Snodeptr s; SPnodeptr r; if (member_supp(x,suppliers,&s) == TRUE) { if (member_part(y,parts,&p) == TRUE) { if (member_supply(x,y,suppliers,parts) == FALSE) { r = spalloc(); r->snext = s->first_sp; r->pnext = p->first_sp; r->s_owner = s; r->p_owner = p; s->first_sp = r; p->first_sp = r; return TRUE; } else return FALSE; } else return FALSE; } else return FALSE; } int delete_supply(struct supp_element_type x, struct part_element_type y, Snodeptr suppliers[], Pnodeptr parts) { } int print_suppliers_given_part(struct part_element_type x, Pnodeptr parts) { } int print_parts_given_supplier(struct supp_element_type x, Snodeptr suppliers[]) { } void print_supply(Snodeptr suppliers[], Pnodeptr parts) { }