/* @(#)gen_pr_add.c 95/05/11 */ /******************************************************************************/ /* function : gen_pr_add.c */ /* */ /* subsystem : chgen */ /* */ /* input : */ /* */ /* output : (writes to pr_load.c output file) */ /* */ /* returns : void */ /* */ /* author : Steve Smith / Craig Smith */ /* */ /* created : July, 1991 */ /* */ /* revisions : added comment at line 194 - RJL 91/1/16 */ /* : inserted NEWVERSION flag for 0 version problem -CEM 19/11/92*/ /* : added code at line 50 - 92s523GEN - 4/24/92 */ /* : included #include and added assert macro */ /* : to link_child_1 macro -RJL 94/12/6 */ /* : inserted logging code throughout - GENLOG 96s523 -DN */ /* : NT port: included prototypes.h - kmiu 00/11/30 */ /* : Removed unreferenced variables - kmiu 00/11/30 */ /* : Added return type to gen_pr_create() to match its prototype */ /* -kmiu 00/11/30 */ /* : STL modifications: ifdef'd out pr_link - kmiu & mottesen */ /* 2kf522 */ /* */ /* description : This routine writes out the code for the pr_add routine */ /* to the pr_load.c output file. For a description of output */ /* code, see the output comments below. */ /* */ /******************************************************************************/ /******************************************************************************/ /* 95s523 (V10), chwang modifies the file to generate the btree_initialized() */ /* routine and modify pr_link() routine. 5,11,95 */ /******************************************************************************/ #include #include #include "chgen_define.h" #include "chgen_externs.h" #include "prototypes.h" #include /* 93su523 PGEN merge (BEGIN) */ /* // GENMERGE: structure definition of rr_data moved tp chgen_externs.h by GENLOG */ void gen_pr_link(); /* 93su523 PGEN merge (END) */ void gen_pr_add() /* generating function pr_add() */ { static char rcsid[] = "$Id: gen_pr_add.c,v 1.4.4.2 1999/05/07 01:25:08 jkarner Exp $"; /* gen_pr_link_macros(); ntansala 2k0430 */ gen_pr_link(); /* gen_pr_create(); */ /* gen_pr_add_macros(); ntansala 2k0430 */ /* if (cli_log == 1) gen_pr_add_log(); ntansala */ } void gen_pr_link() /* generating function pr_link() */ { fprintf(prload_fp, "\ /******************************************************************************/\n\ /* This routine is used to link a single row to a virtual database table. */\n\ /******************************************************************************/\n\ \n\ #ifndef USE_STL\n\ void pr_link (int tbl_encoding)\n\ {\n\ \n\ switch( tbl_encoding )\n\ {\n\ "); /* * generating cases' branches */ tt_curr = tt; while ( tt_curr != NULL) { fprintf(prload_fp,"\t\tcase %d :\t/* encoding of %s */\n", encoding(tt_curr->TTabbr), tt_curr->TTabbr); fprintf(prload_fp,"\t\t\t%selt->link_row() ;\n", tt_curr->TTabbr ); fprintf(prload_fp,"\t\t\tbreak;\n\n" ); tt_curr = tt_curr->next_ptr; } /* while tt */ fprintf(prload_fp,"\t}\n\n}\n"); fprintf(prload_fp,"#endif /* USE_STL */\n"); } int pr_get_pc_entry( tmp, TTabbr, pc_entry) register struct rr_type *tmp; char *TTabbr; struct rr_data *pc_entry; { int foundnum, i; if (strncmp(tmp->firstid, TTabbr, hcg_abbr_size) != 0) { return 0; } /* getting table type and abbreviates for parent and child */ strncpy_null( pc_entry->prnt_abbrev, tmp->firstid, hcg_abbr_size); strcpy( pc_entry->parent, tmp->firstid); strncpy_null( pc_entry->child_abbrev, tmp->secondid, hcg_abbr_size); strcpy( pc_entry->child, tmp->secondid); strcpy( pc_entry->parent_pkey, pc_entry->parent); foundnum = 0; i = 0 ; while ( (!foundnum) && (i < strlen(pc_entry->parent) )) if (isdigit( pc_entry->parent[i]) != 0) foundnum = 1; else i++ ; if (foundnum) pc_entry->parent_pkey[i] = '\0'; return 1; } int pr_get_cp_entry( tmp, TTabbr, cp_entry ) register struct rr_type *tmp; char *TTabbr; struct rr_data *cp_entry; { int foundnum, i; if (strncmp(tmp->firstid, TTabbr, hcg_abbr_size) != 0 ) { return 0; } /* getting table type and abbreviates for parent and child */ strncpy_null( cp_entry->child_abbrev, tmp->firstid, hcg_abbr_size); strcpy( cp_entry->child, tmp->firstid); strncpy_null( cp_entry->prnt_abbrev, tmp->secondid, hcg_abbr_size); strcpy( cp_entry->parent, tmp->secondid); strcpy( cp_entry->parent_pkey, cp_entry->parent); foundnum = 0; i = 0 ; while ( (!foundnum) && (i < strlen(cp_entry->parent))) if (isdigit(cp_entry->parent[i]) != 0) foundnum = 1; else i++ ; if (foundnum) cp_entry->parent_pkey[i] = '\0'; return 1; } void gen_pr_create(void) { fprintf(prload_fp, "\n\ /******************************************************************************/\n\ /* This routine is used to create a table element and initialize it. */\n\ /******************************************************************************/\n\ \n\ hcg_ptr pr_gen_create ( int size ) \n\ { \n\ hcg_ptr ptr = (hcg_ptr) malloc(size); \n\ bzero(ptr, size); /* or memset(ptr, 0, size); */\n\ /* This should also set all the keys to null_key() but doesn't right now -- MM */\n\ return ptr; \n\ } \n\ "); }