/* @(#)add_pc_cp_entries.c 2.1 93/05/18 */ /******************************************************************************/ /* function : add_pc_cp_entries.c */ /* */ /* subsystem : chgen */ /* */ /* input : parent (fkey to), child (pkey), is_key (string from schema) */ /* */ /* output : (adds nodes to pc_table and cp_table) */ /* */ /* returns : void */ /* */ /* author : Steve Smith / Craig Smith */ /* */ /* created : July, 1991 */ /* */ /* revisions : */ /* */ /* description : This routine will add nodes to both the pc_table and cp_table*/ /* with information indicating a relationship between two */ /* tables. If the parent value (which is actually a foriegn */ /* key) has a digit in it, then the child value (which ident- */ /* ifies the parent table) will have the same digit appended */ /* to it. This logic is used to handle the case when the */ /* same table can be a parent of a table multiple times. */ /* For example, given parent = AAid1, child = BBid, */ /* the node added is firstid= AAid1, secondid = BBid1 */ /* The new "derived" field name is used to generate child ptrs */ /* in the parent table. */ /* */ /******************************************************************************/ #include #include #include "chgen_define.h" #include "chgen_externs.h" #include "prototypes.h" void add_pc_cp_entries (char parent[], char child[], char is_key[]) { static char rcsid[] = "$Id: add_pc_cp_entries.c,v 1.3.4.1 1999/05/04 16:58:40 jkarner Exp $"; struct rr_type *obj_ptr1, *obj_ptr2 ; unsigned int foundnum, i ; char temp_parent[NAMELENGTH], temp_child[NAMELENGTH]; strcpy(temp_parent,parent); strcpy(temp_child,child); foundnum = 0; i = 0 ; while ( (!foundnum) && (i < strlen(temp_parent))) if (isdigit(temp_parent[i]) != 0) foundnum = 1 ; else i++ ; if (foundnum) sprintf(temp_child,"%s%c",temp_child,temp_parent[i]); obj_ptr1 = (struct rr_type* ) malloc(sizeof(struct rr_type)); obj_ptr1->next_ptr = NULL ; strcpy (obj_ptr1->firstid,temp_parent); strcpy (obj_ptr1->secondid,temp_child); obj_ptr1->HasBp = (is_key[0] == '1') || (is_key[0] == 's'); obj_ptr1->Singleton = (is_key[0] == 's'); pc_table = (struct rr_type *) rr_insert(obj_ptr1,pc_table); obj_ptr2 = (struct rr_type* ) malloc(sizeof(struct rr_type)); obj_ptr2->next_ptr = NULL ; strcpy (obj_ptr2->firstid,temp_child); strcpy (obj_ptr2->secondid,temp_parent); obj_ptr2->HasBp = (is_key[0] == '1') || (is_key[0] == 's'); obj_ptr2->Singleton = (is_key[0] == 's'); cp_table = (struct rr_type *) rr_insert(obj_ptr2,cp_table); return; }