#include #define V1(p) ((long) *(buf+p)) #define V2(p) (256L * (long) *(buf+p) + (long) *(buf+p+1)) #define V4(p) (256L * (256L * (256L * (long) *(buf+p) + (long) *(buf+p+1)) + (long) *(buf+p+2)) + (long) *(buf+p+3)) main(argc,argv) int argc; char **argv; { FILE *inf, *fopen(); unsigned char buf[2000],check[8] = {0, 14, 1, 1, 'F','N','O','C'}; int satid,iyr,imon,iday,ihr,imin,nfile=0,nscan; int scid,rev,bjld,bhr,bmin,bsec,ejld,ehr,emin,esec; int ajld,ahr,amin,asec,lsat; if ((inf=fopen(argv[1],"r")) == NULL) { fprintf(stderr,"ERROR - Unable to open specified TDR file!\n"); exit(1); } fread(buf,1,28,inf); if (memcmp(buf, check, 8) == 0) { nfile = nfile + 1; satid = 10 * (V1(18) - '0') + V1(19) - '0'; iyr = V2(20); imon = V1(22); iday = V1(23); ihr = V1(24); imin = V1(25); fread(buf,1,32,inf); nscan=V2(14); fread(buf,1,190,inf); fread(buf,1,370,inf); fread(buf,1,1138,inf); fread(buf,1,370,inf); fread(buf,1,30,inf); scid = V4(4); rev = V4(8); bjld = V2(12); bhr = V1(14); bmin = V1(15); bsec = V1(16); ejld = V2(17); ehr = V1(19); emin = V1(20); esec = V1(21); ajld = V2(22); ahr = V1(24); amin = V1(25); asec = V1(26); lsat = V1(27); scid = scid - 6; iyr = iyr - 1900; printf("SSMI.TDR.S%1d.D%2d%3.3d.T%2.2d%2.2d.B%5.5d\n", scid,iyr,bjld,bhr,bmin,rev); } else { fprintf(stderr,"ERROR - Not a valid TDR file!\n"); exit(1); } }