4 #define SIZEOFDIR (sizeof(struct DIRECTORY))
6 #define MAX_SCANS 16384
19 int bytesinindex, bytesused;
22 log_msg(
"directory sizes dont match");
26 bytesinindex = b->num_index_rec * b->bytperrec;
27 bytesused = b->num_entries_used * b->bytperent;
29 if( bytesinindex < bytesused +
SIZEOFDIR ) {
30 log_msg(
"Dir struct of %s, full.", fn );
36 if( b->typesdd || !b->version ) {
37 log_msg(
"SDD version or type of %s is invalid.", fn );
42 log_msg(
"File %s has faulty direcory size, can't verify", fn );
46 if( b->num_entries_used <= 0 ) {
59 if(head->refpt_vel == 0.0)
72 int fd, dirl, num,
max;
80 log_msg(
"READ_SCAN: Scan %.2f, in version %d Ignored", scan,
version);
90 if( (fd = pdopen(filename))<0)
93 if( read( fd, (
char *)&boot,
sizeof(
struct BOOTSTRAP))<0 ) {
106 lseek( fd, (off_t)dirl, SEEK_SET );
113 return((
int)dir.
scan);
121 lseek( fd, (off_t)dirl, SEEK_SET );
130 if( scan == dir.
scan )
147 lseek( fd, (off_t)max, SEEK_SET );
149 if(read(fd, (
char *)head,
sizeof(
struct HEADER) )<0)
151 perror(
"read header");
160 *data = (
float *)malloc( (
unsigned int)
datalen );
161 bzero((
char *)*data, datalen );
163 if( read( fd, (
char *)*data, datalen) <0 ) {
165 log_msg(
"Error reading scan %7.2f data", scan);
176 l = datalen /
sizeof(float);
180 if(isnan( (
double)(*data)[i]))
192 static int pdopen(name)
197 if( (fd = open(name, O_RDONLY, 0666 ))<0)
199 log_msg(
"Unable to open: %s", name );
215 strcpy(field,
modes[
id].field);
220 strcpy(field,
modes[0].field);
233 int fd, dirl, bytesinindex, bytesused, num,
max;
238 if( (fd = pdopen(filename))<0)
243 if( read( fd, (
char *)&boot,
sizeof(
struct BOOTSTRAP))<0 ) {
252 log_msg(
"directory sizes dont match");
260 if( bytesinindex < bytesused +
SIZEOFDIR ) {
261 log_msg(
"Dir struct of %s, full.", filename );
265 log_msg(
"SDD ver or type of %s, invalid.", filename );
271 log_msg(
"File %s has faulty dir size", filename );
286 lseek( fd, (off_t)dirl, SEEK_SET );
298 lseek( fd, (off_t)dirl, SEEK_SET );
304 if( scan == dir.
scan )
317 lseek( fd, (off_t)max, SEEK_SET );
319 if(read(fd, (
char *)head,
sizeof(
struct HEADER) )<0)
321 perror(
"read header");
329 strncpy( tmode, head->
obsmode, 4);
332 if(strstr(tmode,
"CONT"))
335 if(strstr(tmode,
"LINE"))
int log_perror(char *msg)
int modefield(int id, char *field)
int log_msg(const char *fmt,...)
int checkIgnoreScans(int v, double s)
unsigned int num_entries_used
int fixVel(struct HEADER *head)
int checkBoot(struct BOOTSTRAP *b, char *fn)
int peekScan(double scan, char *filename, int *be, int *modeid, struct HEADER *head)
unsigned int num_index_rec