/* @(#)gen_structures.c 2.1 95/05/11 */ /******************************************************************************/ /* function : gen_structures.c */ /* */ /* subsystem : chgen */ /* */ /* input : */ /* */ /* output : (writes to output schema .h file) */ /* */ /* returns : void */ /* */ /* author : Steve Smith / Craig Smith */ /* */ /* created : July, 1991 */ /* */ /* revisions : 93s523: change output method for key fields, output table */ /* index global hcg_tbl_abbr. */ /* 99s523: added rcsId lines, merged in 97 wang updates. JK-KS */ /* */ /* description : This routine will write the actual structure definitions for */ /* each table in the schema to the schema output .h file. */ /* This is ddone by traversing the tt and ta tables. Other */ /* routines are called to generate the parent/child pointers */ /* as needed. This module also marks the end of the output .h */ /* file. */ /* */ /******************************************************************************/ /******************************************************************************/ /* 95s523 (V10), chwang modifies the file to generate the btree structure for */ /* pr_find macro. The btrees is built for binary tree search by pkey. 5,11,95 */ /******************************************************************************/ #include #include #include "chgen_define.h" #include "chgen_externs.h" #include "prototypes.h" void gen_structures() { static char rcsid[] = ""; int dimension, index ; fprintf(schh_fp,"/******************************************************************************/\n"); fprintf(schh_fp,"/* The remainder of this file holds the 'C' structure definitions for each */\n"); fprintf(schh_fp,"/* table in the schema. */\n"); fprintf(schh_fp,"/******************************************************************************/\n\n"); tt_curr = tt; while (tt_curr != NULL) { fprintf(schh_fp,"/******************************************************************************/\n"); fprintf(schh_fp,"/* Table: %s */\n",tt_curr->TTabbr); fprintf(schh_fp,"/******************************************************************************/\n"); fprintf(schh_fp, "hcg_extern\n") ; fprintf(schh_fp, "struct %s", tt_curr->TTabbr); if (tt_curr->comment[0] == '\0') fprintf(schh_fp, "\n"); else fprintf(schh_fp, "\t\t\t%s\n", tt_curr->comment); fprintf(schh_fp, "{\n"); ta_curr = tt_curr->ta_ptr; while (ta_curr != NULL) { if(ta_curr->IsKey) fprintf(schh_fp, "hcg_key %s;", ta_curr->FieldName); else switch(ta_curr->FieldType[0]) { case 'i' : fprintf(schh_fp,"int %s;",ta_curr->FieldName); break; case 'f' : fprintf(schh_fp,"float %s;",ta_curr->FieldName); break; case 'c' : case 't' : dimension = atoi(&(ta_curr->FieldType[1])) +1; fprintf(schh_fp,"char %s[%d];",ta_curr->FieldName,dimension); break; case 'd' : fprintf(schh_fp,"char %s[26];",ta_curr->FieldName); break; } /* switch */ if (ta_curr->comment[0] == '\0') fprintf(schh_fp, "\n"); else fprintf(schh_fp, "\t%s\n", ta_curr->comment); ta_curr = ta_curr->next_ptr; } /* end while ta_curr */ make_pptr(tt_curr->ta_ptr->FieldName,cp_table); make_cptr(tt_curr->ta_ptr->FieldName,pc_table); fprintf(schh_fp,"struct %s *prev_ptr;\n" ,tt_curr->TTabbr); fprintf(schh_fp,"struct %s *next_ptr;\n" ,tt_curr->TTabbr); fprintf(schh_fp,"int RFLAG; /* for pr_utility macro log */\n"); /* From ctwang log changes */ fprintf(schh_fp,"} hcg_declare(%s);\n",tt_curr->TTabbr); fprintf(schh_fp,"\n\n"); tt_curr = tt_curr->next_ptr; } /* end while tt_cur */ { int i; fprintf(schh_fp, "\nstatic char *hcg_tbl_abbr[] = {\n"); for(i=0; i < num_tables - 1; i++) fprintf(schh_fp, "\t\t\t\t\t\t\"%s\",\n", lut_get_name(&hcg_table_abbrev_lut, i)); fprintf(schh_fp, "\t\t\t\t\t\t\"%s\" };\n\n", lut_get_name(&hcg_table_abbrev_lut, i)); } fprintf(schh_fp, "#endif\n") ; /*** 95s523,chwang,5,11,95. Add btree structures and other relative btree arguments. ***/ /*** ---lines begin--- ***/ /************ Sathya Chgen V 12 Modification --- Code removed from .h file Portion of unused code removed Chgen V12 Changes Sathya ***********************/ /*** ---lines end--- ***/ return; }