⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdseed.c

📁 解吸SEED格式的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
					fprintf(stderr, "Volume header record\n");				}				/* minus the 32k read in above */				Volume_start = ftell(inputfile) - num_bytes_read;				process_volh ();				/* make check for version >= 2.3 if they				 * selected output to sub seed volume				 */				if (at_volume)				if ((type10.version < 2.3) && Seed_flag)				{					fprintf(stderr, "Unable to make a sub-seed volume from this seed volume as the version needs to be greater than 2.3\nFound version %1.1f\n", type10.version);					fclose(inputfile);					goto begin;									}				break;			case ' ':				if (!at_volume) break;				if (snoop_flag)				{					fprintf(stderr, "Blank record\n");					break;				}				process_blank ();				break;			default:				fprintf (stderr, "WARNING (rdseed):  ");				fprintf (stderr, "Record number %ld was of unknown type %c.\n", 					input.recordnumber, input.type);				fprintf (stderr, "\tExecution continuing.\n");		}		lrecord_ptr = lrecord_ptr + LRECL;		/* set up offset for next time around */		offset += LRECL;		if (offset >= num_bytes_read) 			offset = 0;	}	if (station_comments_flag && channel_comments_flag)		output_stn_chn_comments();	else	if (station_comments_flag)		output_stn_comments();	else	if (channel_comments_flag)		output_chn_comments();	if (event_flag)		output_event_info();	if (ex_stn_flag)		output_station_info();	if (data_hdr->nsamples)		dump_seismic_buffer();	close_b2k_file();	/* if open */	/* create seed volume - data and block 74 are extracted by now */	if (Seed_flag)	{		output_seed_volume();		/* removes files perhaps left behind */		clean_up_output_seed();	}	if (outresp_flag)	    output_resp();	if (times_flag)		times_data (1);	/* report volume header and time index of volume */	if (contents_flag)	{		print_volh ();		print_timeh ();	}	/* list all information for selected stations */	if (stations_flag)	{		print_volh ();		for (current_station = type50_head; 			 	current_station != NULL;				current_station = current_station->next)		{					print_stnh ();		}	}	/* write out the abbreviation dictionaries */	if (abbrev_flag)	{		if (snoop_flag)			fprintf(stderr, "Print Abbreviations\n");		print_volh ();		print_abrvd ();	}	if (Output_PnZs)		output_polesNzeros();/*===========|                clean up               |=================*//*           +=======================================+                 */	if (output_pipe) pclose(outputfile);	else fclose (outputfile);	outputfile = stdout;	fclose (inputfile);	if (inputfile = get_alt_file())	{		/* more alt files */		reading_alt_file = TRUE;		if (data_flag || mini_flag)			free((char *)seismic_data);		free_all(); 		rewind(save_file); /* start over with the original seed volume */		at_volume = FALSE;		goto MORE_ALT_FILES;	}	else		close_alt_files();		if (!read_summary_flag)	{		free(start_time_point);		free(end_time_point);	}	if (read_summary_flag)	{		free_stn_nodes();		read_summary_flag = FALSE;	}	if (opt_count == 0)	{		if (data_flag || mini_flag)			free((char *)seismic_data);		free_all();	/* free all memory */		goto begin;	}	if (rdseed_alert)		fprintf(stderr, "Attention, please note there are alert messages in the rdseed alert file: rdseed.alert_log.todays_date\n");	fprintf (stderr, "rdseed completed.\n");}struct data_blk_1000 *scan_for_blk_1000();/* -------------------------------------------------------------------- */int process_data_rec(){	struct data_blk_1000 *p;	struct input_data_hdr *hdr = (struct input_data_hdr *)(lrecord_ptr + 8);	int default_Lrecl;	char starttime[30];	int i;	default_Lrecl = LRECL;	sprintf(starttime, "%d,%d,%d:%d:%d.%d",                                hdr->time.year,                                hdr->time.day,                                hdr->time.hour,                                hdr->time.minute,                                hdr->time.second,                                hdr->time.fracsec);	LRECL = get_stn_chn_Lrecl(hdr->station,                                  hdr->channel,                                  type10.version >= 2.3 ?                                                hdr->network:                                                "",                                  hdr->location,                                  starttime); 	if (LRECL == 0 || (LRECL % 256 != 0))        {                fprintf(stderr, "Bad logical record length scanned for station %s; channel %s:location:%s. Assuming logical record length of %d\n",                        hdr->station,                        hdr->channel,                        hdr->location,                        default_Lrecl);                LRECL = default_Lrecl;         }	/* data_rec_length = get_LRECL(hdr, lrecord_ptr); */         if (hdr->bofb != 0)                p = scan_for_blk_1000(lrecord_ptr + hdr->bofb,                                        lrecord_ptr);        else                p = NULL;         if (p)                LRECL = (2 << (p->rec_length - 1));         else                LRECL = scan_for_lrecl(lrecord_ptr + 8);	for (i = 0; i < default_Lrecl/LRECL; i++)	{		read_logical_record (lrecord_ptr); 		times_data(0);		lrecord_ptr += LRECL;	}		LRECL = default_Lrecl;		return 1;	}/* -------------------------------------------------------------------- */int scan_for_lrecl(char *b){	int where;	struct input_data_hdr *hdr_1 = (struct input_data_hdr *)b;	struct input_data_hdr *hdr_2;	/* check 512 */	where = 512;			while (where <= 8092)	{		hdr_2 = (struct input_data_hdr *)&b[where];		if ((strncmp(hdr_1->station, hdr_2->station, 5) == 0) &&	    	    (strncmp(hdr_1->channel, hdr_2->channel, 3) == 0) &&	    	    (strncmp(hdr_1->location, hdr_2->location, 2) == 0) &&	    	    (strncmp(hdr_1->network, hdr_2->network, 2) == 0))			return where;			where += 2;	}	return where;	}/* -------------------------------------------------------------------- */struct data_blk_2000 *parse_type_2k();int process_blk_2k(struct input_data_hdr *hdr, char *buff){	int err;	struct data_blk_2000 *b_2k;	b_2k = parse_type_2k(buff);	err =  output_b2k(hdr, b_2k);		free_type_2k(b_2k);	free_type_2k(b_2k);	return err;}/* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- */int process_B70s(inputfile)FILE *inputfile;{	int i;	int seek_pos;	for (i = 0; i < type12.number_spans; i++)	{		/* relative to where we are */		seek_pos = ((type12.timespan[i].sequence_number - 1) * LRECL) - ftell(inputfile) + Volume_start;				fseek(inputfile, seek_pos, 1);		/* sequentially read thru the file until 0000D are found */		num_bytes_read = fread(precord, 1, PRECL, inputfile);		if (num_bytes_read == -1)		{			fprintf(stderr, "Unable to scan blockette 70s!\n");			perror("process_B70s");			return;		}		lrecord_ptr = precord;		offset = 0;		/* check for 'T' indicating timespan section.	  	 * We sometimes get garbage in the blockette 12s,		 * necessitating a check here 		 */		if (precord[6] != 'T')		{                        fseek(inputfile, 0, 0);			num_bytes_read = fread(precord, 1, PRECL, inputfile);                         if (num_bytes_read < 0)                        {				fprintf(stderr, "Unable to read volume for time series information\n"); 				perror("process_B70s");                                return;                         }			offset = 0;			lrecord_ptr = precord;			if (skip_to_T(inputfile) == 0)                        	return;		}		do 		{			if (lrecord_ptr[6] != 'T')			{				/* ### Kludge alert: if this is the first "chunk"				 * of precord, reset file pointer, as with the 				 * offset being zero will cause the "main" loop				 * to do an unnecessary read, missing this one				 */				if (offset == 0)					fseek(inputfile, -num_bytes_read, 1);				break;			}			read_logical_record(lrecord_ptr);			process_timeh ();					if (offset + LRECL >= PRECL)			{				num_bytes_read = fread(precord, 							1, PRECL, 							inputfile);                 		if (num_bytes_read < 0)                        		return;				offset = 0;				lrecord_ptr = precord;			}			else			{				lrecord_ptr += LRECL;				offset += LRECL;			}		} while (1);	}}int process_B11(inputfile)FILE *inputfile;{        int i;        int seek_pos;	char wrkstr[6];        for (i = 0; i < type11.number_stations; i++)        {		strcpy(wrkstr, type11.station[i].station_id);	        if (!chk_station(wrkstr))                	continue;                /* relative to where we are */                seek_pos = ((type11.station[i].sequence_number - 1) * LRECL) -ftell(inputfile) + Volume_start;                fseek(inputfile, seek_pos, 1);		process_station_lrecs(inputfile, i);	}}/* ------------------------------------------------------------------ */int skip_to_DRQ(inputfile)FILE *inputfile;{	int num_bytes_read;	do 	{		if (offset + LRECL > PRECL)		{                        num_bytes_read = read(fileno(inputfile), precord, PRECL);                        if (num_bytes_read < 0)			{				fprintf(stderr, "ERROR: skip_to_(): unable to read the inputfile while scanning for records\n");				perror("rdseed");				return 0;			}				/* didn't find any */				if (num_bytes_read == 0)				return 0;			offset = 0;			lrecord_ptr = precord;		}		if (lrecord_ptr[6] == 'D')			break;		if (lrecord_ptr[6] == 'R')			break;		if (lrecord_ptr[6] == 'Q')			break;			lrecord_ptr += LRECL;		offset += LRECL;		} while (1);	return num_bytes_read;}/* ------------------------------------------------------------------ */int skip_to_T(inputfile)FILE *inputfile;{	int num_bytes_read;	do 	{		if (offset + LRECL > PRECL)		{                        num_bytes_read = read(fileno(inputfile), precord, PRECL);                        if (num_bytes_read < 0)			{				fprintf(stderr, "ERROR: skip_to_(): unable to read the inputfile while scanning for records\n");				perror("rdseed");				return 0;			}				/* didn't find any */				if (num_bytes_read == 0)				return 0;			offset = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -