int main(int argc,char *argv[]) { FILE *fp; int fd; int yr,mo,dy,hr,mt; double sc; fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } fd=fileno(fp); while(GridRead(fd,&grd) !=-1) { TimeEpochToYMDHMS(grd.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,grd.vcnum); GridWrite(fileno(stdout),&grd); } fclose(fp); return 0; }
int GridFread(FILE *fp,struct GridData *ptr) { return GridRead(fileno(fp),ptr); }
int main(int argc,char *argv[]) { FILE *fp; int fd; struct GridIndex *inx=NULL; int yr=2005,mo=3,dy=31,hr=10,mt=30; double sc=0,atme; int s; if (argc>2) { fp=fopen(argv[2],"r"); if (fp==NULL) { fprintf(stderr,"Index not found.\n"); exit(-1); } fd=fileno(fp); inx=GridIndexLoad(fd); fclose(fp); if (inx==NULL) { fprintf(stderr,"Error loading index.\n"); exit(-1); } } fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } fd=fileno(fp); s=GridSeek(fd,yr,mo,dy,hr,mt,(int) sc,&atme,inx); if (s==-1) { fprintf(stderr,"file does not contain that interval.\n"); exit(-1); } fprintf(stdout,"Requested:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); TimeEpochToYMDHMS(atme,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"Found:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); while(GridRead(fd,&grd) !=-1) { TimeEpochToYMDHMS(grd.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,grd.vcnum); } fclose(fp); return 0; }