#include "type_hyd.h" #include "varext.h" extern int dcmp; extern list_m_h *lmh_start; void Get_Fmt(void) { fpos_t CurrPos; short int min,len,year,hd_size; main_head_o old_h; main_head_3 mh3; struct tm *tm3; if ( (headfil=fopen(head_fil,"rb"))==NULL ){ printf("could not open %s \n",head_fil); perror(""); exit(0); } CurrPos=4L; fsetpos(headfil,&CurrPos); for (min=1;min<1442;min++){ if(fread(&CurrPos,4,1,headfil)!=1){ if (feof) { printf("min=%d EOF .... ",min); exit(0); } printf("min=%d\n",min); printf("Could not read position from headfil !!!\n"); perror(""); exit(0); } } if(fread(&oldlen,2,1,headfil)!=1){ printf("timlist: Could not read oldlen from headfil !!!\n"); perror(""); exit(0); } CurrPos=0L; fsetpos(headfil,&CurrPos); CurrPos=5770L; fsetpos(headfil,&CurrPos); while(1){ if (fread(&len,2,1,headfil)!=1){ if (feof) break; else perror ("gethyd02:"); } if (len==(-1*SIZE_MAINH_O)){ old_h.indic=len; if (fread(&old_h.len_prev,SIZE_MAINH_O-2,1,headfil)!=1){ fprintf(stderr," could not read main header ! \n"); perror("gethyd03:"); exit(0); } memcpy(&main_h.indic,&old_h.indic,30); main_h.HBL=old_h.DELTA_H; main_h.HBR=old_h.DELTA_H; main_h.HFR=old_h.DELTA_H; memcpy(&main_h.gate1,&old_h.gate1,30); base_frequ=main_h.line_frequ; tm3=gmtime(&main_h.main_time); } else if (len==(-1*SIZE_MAINH_3)){ main_h.indic=len; if (fread(&mh3.len_prev,SIZE_MAINH_3-2,1,headfil)!=1){ fprintf(stderr," could not read main header ! \n"); perror("gethyd03:"); exit(0); } base_frequ=mh3.line_frequ; if ((base_frequ>34089)&&(base_frequ<34091)){ base_frequ= (1193180./35.); } tm3=gmtime(&mh3.main_time); memcpy(&main_h.indic,&mh3.indic,42); main_h.mid_pix=256; memcpy(&main_h.gate1,&old_h.gate1,30); } else if (len==(-1*SIZE_MAINH_4)){ main_h.indic=len; if (fread(&main_h.len_prev,SIZE_MAINH_4-2,1,headfil)!=1){ fprintf(stderr," could not read main header ! \n"); perror("gethyd03:"); exit(0); } base_frequ=main_h.line_frequ; tm3=gmtime(&main_h.main_time); } year=1900+tm3->tm_year; hd_size=-1*len; /* printf("file = %s \n",argv[1]); printf("year = %d \n",year); printf("SIZE_MAINH = %d \n",hd_size); printf("base_frequ = %lf \n",base_frequ); printf("oeu_nr = %d \n",main_h.oeu_nr); printf("format = %d \n",main_h.format); printf("dat_gen = %d \n",main_h.dat_gen); printf("dat_rev = %d \n",main_h.dat_rev); */ fomt=0; if (year<=1995){ size_mainh=SIZE_MAINH_O; size_pixh=SIZE_PIXH_O; fomt=1; } else{ if (hd_size==64){ fomt=2; size_mainh=hd_size; size_pixh=SIZE_PIXH_3; } if (hd_size==72){ fomt=3; size_mainh=hd_size; size_pixh=SIZE_PIXH_3; } if (hd_size==74){ fomt=4; size_mainh=hd_size; size_pixh=SIZE_PIXH_4; } } if (!fomt){ printf("could not determine data format \n"); exit(0); } } rewind(headfil); }