static char rcsid[]="$Id: testohf.c,v 1.0 1992/07/28 23:07:53 maurer $"; /*********************************************************************** testohf.c Function: program illustrates how to read OHF orbit header file This file is part of the STARLab Magellan Altimeter Data Processing Software. Joe Twicken, June 1992. ***********************************************************************/ /* $Log: testohf.c,v $ * Revision 1.0 1992/07/28 23:07:53 maurer * Initial revision * */ #include #include "scvdr.h" #include "scvparse.h" #include "scvparse.i" #include "scv_rdr.i" int main(argc,argv) int argc; /* Number of program arguments */ char *argv[]; /* Argument strings */ { sfdu sf1; /* CCSDS header SFDU label */ sfdu sf2; /* Keyword/value SFDU label */ sfdu sf3; /* Orbit header record SFDU label */ sfdu sf4; /* Aggr start marker SFDU label */ keyval_t *kv2; /* Catalog keyword/value list */ keyval_t *kv4; /* Aggr smarker keyword/value list */ hr_rec hr; /* Orbit header record */ int orb; /* Orbit */ char avg_sclk[15]; /* Average orbit periapsis time */ char product_file_name[80];/* Product file name */ FILE *f_ohf; /* OHF file pointer */ /* Check usage */ if (argc != 2) { fprintf(stderr,"usage: testohf ohf_file\n"); exit(1); } /* Open the OHF file for reading */ if ((f_ohf = fopen(argv[1],"r")) == NULL) { fprintf(stderr, "testohf: [main] can't open %s\n",argv[1]); exit(2); } /* Although the OHF file does not include an aggregation start marker, the addresses of sf4 and kv4 should be passed to hdr_read() anyway. On return from hdr_read(), sf4 will simply contain a null sfdu and *kv4 will be null as well. Remember to free the keyword/value list pointers with free_catalog() when they are no longer needed */ if (hdr_read(f_ohf,&sf1,&sf2,&kv2,&sf3,&hr,&sf4,&kv4)) { fprintf(stderr, "testohf: [main] can't read ohf header\n"); exit(3); } /* Do something with the header record values. The example here shows how to get the orbit, periapsis time and product file name */ orb = hr.hr_orb; strncpy(avg_sclk,hr.hr_avg_sclk,sizeof(avg_sclk)); strncpy(product_file_name,kv2[0].val,sizeof(product_file_name)); /* Free the keyword/value lists */ free_catalog(kv2); free_catalog(kv4); /* Close the OHF file */ fclose(f_ohf); return(0); }