*** init.c.orig Wed Jun 26 19:06:31 1996 --- init.c Fri Dec 3 01:12:41 1999 *************** *** 48,58 **** Server_image mainmousehints; - - - Rect *rect; /* pointer to a rectangle pointer */ - Panel_item p_item; - Display *dpy; XColor temp_color; Colormap cmap; --- 48,53 ---- *************** *** 66,72 **** int count; int not_monochrome; ! int i; char c_nm[40]; char file_name[255]; --- 61,67 ---- int count; int not_monochrome; ! int i, pin; char c_nm[40]; char file_name[255]; *************** *** 76,81 **** --- 71,79 ---- char l_name[200]; char c_path[200]; + + #define MAX_PITEM 15 + Panel_item pitem[MAX_PITEM]; *************** *** 149,163 **** iscolor = (XDisplayCells (dpy, DefaultScreen(dpy)) > 2); - if (but_narrow) panel = (Panel) xv_create(frame, PANEL, ! WIN_ROWS, 5, NULL); - else - panel = (Panel) xv_create(frame, PANEL, - WIN_ROWS, 3, - NULL); - /* set up the interrupt default procedures */ /* notify_set_input_func(read_client, --- 147,155 ---- iscolor = (XDisplayCells (dpy, DefaultScreen(dpy)) > 2); panel = (Panel) xv_create(frame, PANEL, ! WIN_ROWS, but_narrow ? 4:3, NULL); /* set up the interrupt default procedures */ /* notify_set_input_func(read_client, *************** *** 174,225 **** msgsock); */ xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, next_proc, PANEL_LABEL_STRING, "Next", /* PANEL_DEFAULT_ITEM, */ NULL); xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, prev_proc, PANEL_LABEL_STRING, "Prev", NULL); xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, defaults_proc, PANEL_LABEL_STRING, "Controls", NULL); xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, select_proc, PANEL_LABEL_STRING, "Select All", NULL); xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, deselect_proc, PANEL_LABEL_STRING, "Deselect All", NULL); if (but_narrow) xv_create(panel, PANEL_BUTTON, PANEL_NEXT_ROW, -1, ! PANEL_NOTIFY_PROC, magnify_sel_proc, ! PANEL_LABEL_STRING, "Magnify", NULL); else xv_create(panel, PANEL_BUTTON, ! PANEL_NOTIFY_PROC, magnify_sel_proc, ! PANEL_LABEL_STRING, "Magnify", NULL); ! ! xv_create(panel, PANEL_BUTTON, ! PANEL_NOTIFY_PROC, transform_sel_proc, ! PANEL_LABEL_STRING, "Spectra", NULL); xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, screendump_proc_main, PANEL_LABEL_STRING, "Screendump", NULL); xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, make_default_file, PANEL_LABEL_STRING, "Set Defaults", NULL); #ifdef TTIME if (use_ttime) { /*added, Song 4/11/95*/ xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, mark_button, PANEL_LABEL_STRING, "Mark", NULL); --- 166,229 ---- msgsock); */ + pin = 0; + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, next_proc, PANEL_LABEL_STRING, "Next", /* PANEL_DEFAULT_ITEM, */ NULL); + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, prev_proc, PANEL_LABEL_STRING, "Prev", NULL); + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, defaults_proc, PANEL_LABEL_STRING, "Controls", NULL); + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, select_proc, PANEL_LABEL_STRING, "Select All", NULL); + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, deselect_proc, PANEL_LABEL_STRING, "Deselect All", NULL); + pitem[pin++] = + xv_create(panel, PANEL_BUTTON, + PANEL_NOTIFY_PROC, magnify_sel_proc, + PANEL_LABEL_STRING, "Magnify", NULL); + if (but_narrow) + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NEXT_ROW, -1, ! PANEL_NOTIFY_PROC, transform_sel_proc, ! PANEL_LABEL_STRING, "Spectra", NULL); else + pitem[pin++] = xv_create(panel, PANEL_BUTTON, ! PANEL_NOTIFY_PROC, transform_sel_proc, ! PANEL_LABEL_STRING, "Spectra", NULL); + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, screendump_proc_main, PANEL_LABEL_STRING, "Screendump", NULL); + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, make_default_file, PANEL_LABEL_STRING, "Set Defaults", NULL); #ifdef TTIME if (use_ttime) { /*added, Song 4/11/95*/ + pitem[pin++] = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, mark_button, PANEL_LABEL_STRING, "Mark", NULL); *************** *** 227,239 **** #endif /* TTIME */ ! p_item = xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, about_pql_proc, PANEL_LABEL_STRING, "About PQL", NULL); #ifdef CHECK_BOXES P_plot_amp = (Panel_item) xv_create(panel, PANEL_CHECK_BOX, PANEL_NEXT_ROW, -1, PANEL_NOTIFY_PROC, cont_defaults_proc, --- 231,259 ---- #endif /* TTIME */ ! pitem[pin++] = ! xv_create(panel, PANEL_BUTTON, PANEL_NOTIFY_PROC, about_pql_proc, PANEL_LABEL_STRING, "About PQL", NULL); + + #ifdef VER2p1 + if (!no_sockets) + pitem[pin++] = + xv_create(panel, PANEL_BUTTON, + PANEL_NOTIFY_PROC, sort_traces_proc, + PANEL_LABEL_STRING, "Sort Traces", NULL); + #endif /* VER2p1*/ + + pitem[pin++] = + xv_create(panel, PANEL_BUTTON, + PANEL_NOTIFY_PROC, quit_proc, + PANEL_LABEL_STRING, "Quit", NULL); + #ifdef CHECK_BOXES + pitem[pin++] = P_plot_amp = (Panel_item) xv_create(panel, PANEL_CHECK_BOX, PANEL_NEXT_ROW, -1, PANEL_NOTIFY_PROC, cont_defaults_proc, *************** *** 243,248 **** --- 263,269 ---- NULL); + pitem[pin++] = P_amp_units = (Panel_item) xv_create(panel, PANEL_CHECK_BOX, PANEL_NOTIFY_PROC, cont_defaults_proc, PANEL_LABEL_STRING, "in:", *************** *** 250,255 **** --- 271,277 ---- PANEL_VALUE, plot_units, NULL); #else + pitem[pin++] = P_plot_amp = (Panel_item) xv_create(panel, PANEL_CHOICE, PANEL_NEXT_ROW, -1, PANEL_NOTIFY_PROC, cont_defaults_proc, *************** *** 259,264 **** --- 281,287 ---- NULL); + pitem[pin++] = P_amp_units = (Panel_item) xv_create(panel, PANEL_CHOICE, PANEL_NOTIFY_PROC, cont_defaults_proc, PANEL_LABEL_STRING, "in:", *************** *** 268,299 **** #endif if (but_narrow) P_start_time = (Panel_item) xv_create(panel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1, PANEL_LABEL_STRING, "Start Time: 0000 000:00:00:00.000", NULL); else P_start_time = (Panel_item) xv_create(panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Start Time: 0000 000:00:00:00.000", NULL); ! ! #ifdef VER2p1 ! if (!no_sockets) ! xv_create(panel, PANEL_BUTTON, ! PANEL_NOTIFY_PROC, sort_traces_proc, ! PANEL_LABEL_STRING, "Sort Traces", NULL); ! ! #endif /* VER2p1*/ ! ! rect = (Rect *)xv_get(p_item,XV_RECT); ! ! xv_create(panel, PANEL_BUTTON, ! PANEL_NOTIFY_PROC, quit_proc, ! PANEL_LABEL_STRING, "Quit", NULL); ! ! /* place the mouse hints a certain distance from the last button */ xv_create(panel, PANEL_MESSAGE, ! XV_X, rect_right(rect) + 20, XV_Y, 5, PANEL_LABEL_IMAGE, mainmousehints , NULL); --- 291,313 ---- #endif if (but_narrow) + pitem[pin++] = P_start_time = (Panel_item) xv_create(panel, PANEL_MESSAGE, PANEL_NEXT_ROW, -1, PANEL_LABEL_STRING, "Start Time: 0000 000:00:00:00.000", NULL); else + pitem[pin++] = P_start_time = (Panel_item) xv_create(panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Start Time: 0000 000:00:00:00.000", NULL); ! /* place the mouse hints a certain distance from rightmost button */ ! if (pin > MAX_PITEM) { ! fprintf(stderr, "init: Oh oh, too many panels (%d), expecting max of MAX_PITEM (%d) -- recompile.\n",pin,MAX_PITEM); ! exit(1); ! } xv_create(panel, PANEL_MESSAGE, ! XV_X, prx(pitem, pin) + 20, XV_Y, 5, PANEL_LABEL_IMAGE, mainmousehints , NULL); *************** *** 319,325 **** ButtonPressMask, NULL); ! xv_set(wind, WIN_CONSUME_EVENTS, LOC_DRAG, NULL); --- 333,339 ---- ButtonPressMask, NULL); ! xv_set(wind, WIN_CONSUME_EVENTS, LOC_DRAG, NULL, NULL); *************** *** 327,333 **** mag_wind = canvas_paint_window(mag_canvas); xv_set(mag_wind, WIN_EVENT_PROC, mag_event_proc, WIN_CONSUME_EVENTS, LOC_DRAG, KBD_USE, NULL); ! */ file_frame = (Frame) xv_create(frame, FRAME_CMD, --- 341,347 ---- mag_wind = canvas_paint_window(mag_canvas); xv_set(mag_wind, WIN_EVENT_PROC, mag_event_proc, WIN_CONSUME_EVENTS, LOC_DRAG, KBD_USE, NULL); ! */ file_frame = (Frame) xv_create(frame, FRAME_CMD, *************** *** 1282,1290 **** */ mag_wind = canvas_paint_window(mag_canvas); ! xv_set(mag_wind, WIN_EVENT_PROC, mag_event_proc, ! WIN_CONSUME_EVENTS, LOC_DRAG, KBD_USE, NULL); ! window_fit(magnify_panel); --- 1296,1303 ---- */ mag_wind = canvas_paint_window(mag_canvas); ! xv_set(mag_wind, WIN_EVENT_PROC, mag_event_proc, NULL); ! xv_set(mag_wind, WIN_CONSUME_EVENTS, LOC_DRAG, KBD_USE, NULL, NULL); window_fit(magnify_panel); *************** *** 1711,1717 **** NULL); xv_set(trans_wind, WIN_EVENT_PROC, trans_event_proc, ! WIN_CONSUME_EVENTS, LOC_DRAG, NULL); --- 1724,1730 ---- NULL); xv_set(trans_wind, WIN_EVENT_PROC, trans_event_proc, ! WIN_CONSUME_EVENTS, LOC_DRAG, NULL, NULL); *************** *** 2025,2028 **** --- 2038,2061 ---- return 0; + } + + prx(panels, n) + /* prx -- Return rightmost location of a bunch of items. + + panels - array of panels; + n - number of items in array + */ + Panel_item panels[]; + int n; + { + Rect *rect; + int i, max; + + rect = (Rect *)xv_get(panels[0],XV_RECT); max = rect_right(rect); + for(i=1;i #define HDR_OFFSET 48 /* default header offset */ + #define SWAP(what) (swap ? swap_2byte(what) : (what)) + int get_max_samples(); int eval_rate(Sample_rate_factor, Sample_rate_multiplier ) *************** *** 68,73 **** --- 70,76 ---- float *temp_float_p; long *temp_long_p; long *t_long_p; + int swap; int get_mseed_hedr(fp, rec_no) FILE *fp; *************** *** 138,143 **** --- 141,165 ---- /* Read first 64-byte header and determine file characteristics */ fread( (char *) data_hdr, 48, 1, fp); + /* Use heuristic to decide whether binary info in header is byte-swapped */ + { unsigned short swyear, swdoy, swsec; + unsigned short usyear, usdoy, ussec; + swyear = swap_2byte(data_hdr->Record_start_time.year); + swdoy = swap_2byte(data_hdr->Record_start_time.day); + swsec = swap_2byte(data_hdr->Record_start_time.frac_secs); + usyear = data_hdr->Record_start_time.year; + usdoy = data_hdr->Record_start_time.day; + ussec = data_hdr->Record_start_time.frac_secs; + if (1900<=usyear && 2500 >= usyear && + 1 <= usdoy && 366 >= usdoy && + ussec <= 9999) swap = 0; + else if (1900<=swyear && 2500 >= swyear && + 1 <= swdoy && 366 >= swdoy && + swsec <= 9999) swap = 1; + else + swap = -1; + } + for ( number = 0; number < (int) data_hdr->Number_of_blockettes_follow; *************** *** 170,175 **** --- 192,201 ---- free(block_100); return (-1); } + if (swap<0) { + fprintf(stderr,"Can't determine byte order of data header, assuming no swapping needed\n"); + swap = 0; + } /* Fill in PQL header info */ if ((head[rec_no] = (struct generic_head *) *************** *** 190,206 **** if (head.year < 1970) head.year = 1970; */ ! date.yr = data_hdr->Record_start_time.year; ! date.day = data_hdr->Record_start_time.day; date.hr = data_hdr->Record_start_time.hours; date.mn = data_hdr->Record_start_time.minutes; ! date.sec = data_hdr->Record_start_time.seconds; passcal_month_day(&date, date.day); F_start_time[rec_no] = passcal_htoe(&date) + ! ((double) data_hdr->Record_start_time.frac_secs)/10000.; strncpy(F_sensor_id[rec_no]," 0",8); --- 216,232 ---- if (head.year < 1970) head.year = 1970; */ ! date.yr = SWAP(data_hdr->Record_start_time.year); ! date.day = SWAP(data_hdr->Record_start_time.day); date.hr = data_hdr->Record_start_time.hours; date.mn = data_hdr->Record_start_time.minutes; ! date.sec = SWAP(data_hdr->Record_start_time.seconds); passcal_month_day(&date, date.day); F_start_time[rec_no] = passcal_htoe(&date) + ! ((double) SWAP(data_hdr->Record_start_time.frac_secs))/10000.; strncpy(F_sensor_id[rec_no]," 0",8); *************** *** 300,311 **** /* Read first 64-byte header and determine file characteristics */ fread( (char *) data_hdr, 48, 1, fp); for ( number = 0; number < (int) data_hdr->Number_of_blockettes_follow; number++) { ! fread( &cur_block, 2 ,1 ,fp); ! fread( &next_blk, 2, 1, fp); /* put file pointer back to place before block_number */ fseek( fp, -4, SEEK_CUR); --- 326,356 ---- /* Read first 64-byte header and determine file characteristics */ fread( (char *) data_hdr, 48, 1, fp); + /* Use heuristic to decide whether binary info in header is byte-swapped */ + { unsigned short swyear, swdoy, swsec; + unsigned short usyear, usdoy, ussec; + swyear = swap_2byte(data_hdr->Record_start_time.year); + swdoy = swap_2byte(data_hdr->Record_start_time.day); + swsec = swap_2byte(data_hdr->Record_start_time.frac_secs); + usyear = data_hdr->Record_start_time.year; + usdoy = data_hdr->Record_start_time.day; + ussec = data_hdr->Record_start_time.frac_secs; + if (1900<=usyear && 2500 >= usyear && + 1 <= usdoy && 366 >= usdoy && + ussec <= 9999) swap = 0; + else if (1900<=swyear && 2500 >= swyear && + 1 <= swdoy && 366 >= swdoy && + swsec <= 9999) swap = 1; + else + swap = -1; + } + for ( number = 0; number < (int) data_hdr->Number_of_blockettes_follow; number++) { ! fread( &cur_block, 2 ,1 ,fp); cur_block = SWAP(cur_block); ! fread( &next_blk, 2, 1, fp); next_blk = SWAP(next_blk); /* put file pointer back to place before block_number */ fseek( fp, -4, SEEK_CUR); *************** *** 318,329 **** fseek(fp, next_blk, SEEK_SET); } ! tot_samples = get_max_samples(fp); /* go to start of the data */ ! ret = fseek(fp, data_hdr->Beginning_of_data, SEEK_SET); if (ret != SUCCESS) { sprintf(msg[rec_no], "get_mseed_data: Error Reading data"); --- 363,377 ---- fseek(fp, next_blk, SEEK_SET); } ! if (swap<0) { ! fprintf(stderr,"Can't determine byte order of data header, assuming no swapping needed\n"); ! swap = 0; ! } tot_samples = get_max_samples(fp); /* go to start of the data */ ! ret = fseek(fp, SWAP(data_hdr->Beginning_of_data), SEEK_SET); if (ret != SUCCESS) { sprintf(msg[rec_no], "get_mseed_data: Error Reading data"); *************** *** 345,356 **** } head[rec_no]->data_form = MY_FLOAT; head[rec_no]->data_form = BIT32; ! head[rec_no]->year = data_hdr->Record_start_time.year; ! head[rec_no]->day = data_hdr->Record_start_time.day; head[rec_no]->hour = data_hdr->Record_start_time.hours; head[rec_no]->minute = data_hdr->Record_start_time.minutes; head[rec_no]->second = data_hdr->Record_start_time.seconds; ! head[rec_no]->m_secs = data_hdr->Record_start_time.frac_secs/10; head[rec_no]->gainConst = 1; head[rec_no]->scale_fac = 1; head[rec_no]->mean = 0.0; --- 393,404 ---- } head[rec_no]->data_form = MY_FLOAT; head[rec_no]->data_form = BIT32; ! head[rec_no]->year = SWAP(data_hdr->Record_start_time.year); ! head[rec_no]->day = SWAP(data_hdr->Record_start_time.day); head[rec_no]->hour = data_hdr->Record_start_time.hours; head[rec_no]->minute = data_hdr->Record_start_time.minutes; head[rec_no]->second = data_hdr->Record_start_time.seconds; ! head[rec_no]->m_secs = SWAP(data_hdr->Record_start_time.frac_secs)/10; head[rec_no]->gainConst = 1; head[rec_no]->scale_fac = 1; head[rec_no]->mean = 0.0; *************** *** 361,368 **** if ( ((int) xv_get(P_label_trace, PANEL_VALUE)) == LABEL_HEADER) { sprintf((head[rec_no]->descr1),"%i, %03i %02i:%02i" , ! data_hdr->Record_start_time.year, ! data_hdr->Record_start_time.day, data_hdr->Record_start_time.hours, data_hdr->Record_start_time.minutes); --- 409,416 ---- if ( ((int) xv_get(P_label_trace, PANEL_VALUE)) == LABEL_HEADER) { sprintf((head[rec_no]->descr1),"%i, %03i %02i:%02i" , ! SWAP(data_hdr->Record_start_time.year), ! SWAP(data_hdr->Record_start_time.day), data_hdr->Record_start_time.hours, data_hdr->Record_start_time.minutes); *************** *** 393,399 **** /* calculate the real value , where 1000000 = 1 sample per */ /* sec, 2000 = 500 samples per second */ ! sample_rate[rec_no] = (int) eval_rate(data_hdr->Sample_rate_factor, data_hdr->Sample_rate_multiplier); /* adjust sample_rate if blockeete 100 is present */ --- 441,447 ---- /* calculate the real value , where 1000000 = 1 sample per */ /* sec, 2000 = 500 samples per second */ ! sample_rate[rec_no] = (int) eval_rate(SWAP(data_hdr->Sample_rate_factor), SWAP(data_hdr->Sample_rate_multiplier)); /* adjust sample_rate if blockeete 100 is present */ *************** *** 459,466 **** number < (int) data_hdr->Number_of_blockettes_follow; number++) { ! fread( &cur_block, 2 ,1 ,fp); ! fread( &next_blk, 2, 1, fp); /* put file pointer back to place before block_number */ fseek( fp, -4, SEEK_CUR); --- 507,514 ---- number < (int) data_hdr->Number_of_blockettes_follow; number++) { ! fread( &cur_block, 2 ,1 ,fp); cur_block = SWAP(cur_block); ! fread( &next_blk, 2, 1, fp); next_blk = SWAP(next_blk); /* put file pointer back to place before block_number */ fseek( fp, -4, SEEK_CUR); *************** *** 475,481 **** } ! ret = fseek(fp,cur_pos + data_hdr->Beginning_of_data, SEEK_SET); /* Increment the cur_pos byte pointer. (point to next fixed */ /* header) */ cur_pos += num_bytes_block; --- 523,529 ---- } ! ret = fseek(fp,cur_pos + SWAP(data_hdr->Beginning_of_data), SEEK_SET); /* Increment the cur_pos byte pointer. (point to next fixed */ /* header) */ cur_pos += num_bytes_block; *************** *** 489,495 **** /* dont assume that the data starts at position 64 bytes, rely on */ /* the value stored in the fixed header itself. */ if ((fread( (char *) data_ptr, ! (int) (num_bytes_block - data_hdr->Beginning_of_data), 1, fp)) == -1) { sprintf(msg[rec_no], "get_mseed_data: Error reading compressed data, record #%d\n", rec_num); --- 537,543 ---- /* dont assume that the data starts at position 64 bytes, rely on */ /* the value stored in the fixed header itself. */ if ((fread( (char *) data_ptr, ! (int) (num_bytes_block - SWAP(data_hdr->Beginning_of_data)), 1, fp)) == -1) { sprintf(msg[rec_no], "get_mseed_data: Error reading compressed data, record #%d\n", rec_num); *************** *** 502,508 **** return (-1); } ! num_decoded += data_hdr->Number_of_samples; /* If there is more data to decode than space allocated, realloc more */ if (num_decoded > short_num_allocated) { --- 550,556 ---- return (-1); } ! num_decoded += SWAP(data_hdr->Number_of_samples); /* If there is more data to decode than space allocated, realloc more */ if (num_decoded > short_num_allocated) { *************** *** 526,534 **** seismic_data = tmp_ptr; short_num_allocated = num_decoded*2; ! num_allocated += data_hdr->Number_of_samples; seismic_data_ptr = seismic_data + num_decoded - ! data_hdr->Number_of_samples; } --- 574,582 ---- seismic_data = tmp_ptr; short_num_allocated = num_decoded*2; ! num_allocated += SWAP(data_hdr->Number_of_samples); seismic_data_ptr = seismic_data + num_decoded - ! SWAP(data_hdr->Number_of_samples); } *************** *** 540,547 **** /* case STEIM1_DATA: */ /* case STEIM2_DATA: */ ! decode_steim_1_2(data_ptr, data_hdr->Number_of_samples, ! num_decoded, format); /* break; */ /* } */ --- 588,596 ---- /* case STEIM1_DATA: */ /* case STEIM2_DATA: */ ! decode_steim_1_2(data_ptr, SWAP(data_hdr->Number_of_samples), ! num_decoded-SWAP(data_hdr->Number_of_samples), format, ! swap); /* break; */ /* } */ *************** *** 596,602 **** char *cptr; double expon; ! cptr= (char*) calloc (1, sizeof(DATA_HEADER)); fxd = (DATA_HEADER *) cptr; b1000 = (BLK_1000 *) (cptr+HDR_OFFSET); /* grab first blockette in this series */ --- 645,651 ---- char *cptr; double expon; ! cptr= (char*) calloc (1, sizeof(DATA_HEADER)+sizeof(BLK_1000)); fxd = (DATA_HEADER *) cptr; b1000 = (BLK_1000 *) (cptr+HDR_OFFSET); /* grab first blockette in this series */ *************** *** 610,638 **** blk_size = (int) pow((double) 2.0, expon); } ! date.yr = fxd->Record_start_time.year; date.hr = fxd->Record_start_time.hours; date.mn = fxd->Record_start_time.minutes; ! date.sec = (float) fxd->Record_start_time.seconds + (float) fxd->Record_start_time.frac_secs / (float)10000.0; ! passcal_month_day(&date, fxd->Record_start_time.day); ! rate = eval_rate(fxd->Sample_rate_factor, fxd->Sample_rate_multiplier)/1e6; ! epoch_start = passcal_htoe(date) + (double) fxd->Record_start_time.frac_secs / 10000.0; /* grab last blockette in this series */ fseek(fp, (long) -blk_size, SEEK_END); fread(fxd, blk_size, 1, fp); ! date.yr = fxd->Record_start_time.year; date.hr = fxd->Record_start_time.hours; date.mn = fxd->Record_start_time.minutes; ! date.sec = (float) fxd->Record_start_time.seconds + (float) fxd->Record_start_time.frac_secs / (float)10000.0; ! passcal_month_day(&date, fxd->Record_start_time.day); /* ! rate = eval_rate(fxd->Sample_rate_factor, fxd->Sample_rate_multiplier)/1e6; ! SS = (( ((double)fxd->Number_of_samples - 1.0) * (double) rate)); */ ! epoch_end = passcal_htoe(date) + (double) fxd->Record_start_time.frac_secs / 10000.0; ! cfree(fxd); return ((epoch_end - epoch_start) / rate); --- 659,688 ---- blk_size = (int) pow((double) 2.0, expon); } ! date.yr = SWAP(fxd->Record_start_time.year); date.hr = fxd->Record_start_time.hours; date.mn = fxd->Record_start_time.minutes; ! date.sec = (float) fxd->Record_start_time.seconds + (float) SWAP(fxd->Record_start_time.frac_secs) / (float)10000.0; ! passcal_month_day(&date, SWAP(fxd->Record_start_time.day)); ! rate = eval_rate(SWAP(fxd->Sample_rate_factor), SWAP(fxd->Sample_rate_multiplier))/1e6; ! epoch_start = passcal_htoe(&date) + (double) SWAP(fxd->Record_start_time.frac_secs) / 10000.0; /* grab last blockette in this series */ + fxd = (DATA_HEADER *) calloc (1, blk_size); fseek(fp, (long) -blk_size, SEEK_END); fread(fxd, blk_size, 1, fp); ! date.yr = SWAP(fxd->Record_start_time.year); date.hr = fxd->Record_start_time.hours; date.mn = fxd->Record_start_time.minutes; ! date.sec = (float) fxd->Record_start_time.seconds + (float) SWAP(fxd->Record_start_time.frac_secs) / (float)10000.0; ! passcal_month_day(&date, SWAP(fxd->Record_start_time.day)); /* ! rate = eval_rate(SWAP(fxd->Sample_rate_factor), SWAP(fxd->Sample_rate_multiplier))/1e6; ! SS = (( ((double)SWAP(fxd->Number_of_samples) - 1.0) * (double) rate)); */ ! epoch_end = passcal_htoe(&date) + (double) SWAP(fxd->Record_start_time.frac_secs) / 10000.0; ! cfree(fxd); cfree(cptr); return ((epoch_end - epoch_start) / rate);