GLYLIB
0.3.0b
|
00001 /************************** init_struct() ******************************/ 00002 /* This is load_pdb's main initialization function. It assigns default rule 00003 * values to some data structures and calls other functions to assign 00004 * values to other functions. 00005 * Author: Lachele Foley 00006 * Modified for use in library by: Michael Tessier 00007 */ 00008 #include <load_pdb.h> 00009 //#include "../inc/load_pdb.h" 00010 extern int DEBUG,INWC; 00011 void init_struct(){ 00012 int isa=0, isb=0,isc=0, iswc=0; 00013 char istst='\0'; 00014 if(DEBUG>=0){printf("init_struct at 1 \n");} 00015 // Get number of lines in input file 00016 rewind(IN); 00017 while(istst!=EOF){ 00018 istst=fgetc(IN); 00019 if(istst=='\n') iswc++; 00020 } 00021 INWC=iswc; 00022 00023 /* Allocate array for line info */ 00024 ln=(linedef*)calloc(iswc,sizeof(linedef)); 00025 for(isa=0;isa<iswc;isa++){ 00026 ln[isa].m='\0'; 00027 ln[isa].n=isa+1; 00028 ln[isa].ignore=1; 00029 for(isb=0;isb<25;isb++){ 00030 for(isc=0;isc<81;isc++){ 00031 ln[isa].f[isb].c[isc]='\0'; 00032 } 00033 } 00034 } 00035 if(DEBUG>=0){printf("init_struct at 9\n");} 00036 /* Read in values defining line and field types */ 00037 pdb_def(); 00038 00039 if(DEBUG>=0){printf("init_struct at 12 \n");} 00040 return; 00041 } 00042 00043 /*This function created by Michael Tessier 20080828*/ 00044 void init_struct_slurp(fileslurp S){ 00045 int i,j,k; 00046 INWC=S.n; //Set the number of lines 00047 ln=(linedef*)calloc(S.n,sizeof(linedef)); 00048 for(i=0;i<S.n;i++){ 00049 ln[i].m='\0'; 00050 ln[i].n=i+1; 00051 ln[i].ignore=1; 00052 for(j=0;j<25;j++){ 00053 for(k=0;k<81;k++){ 00054 ln[i].f[j].c[k]='\0'; 00055 } 00056 } 00057 } 00058 pdb_def(); 00059 }