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

📄 rdseed.c

📁 解吸SEED格式的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
			lrecord_ptr = precord;		}		if (lrecord_ptr[6] == 'T')			break;			lrecord_ptr += LRECL;		offset += LRECL;		} while (1);	return 1;}/* ------------------------------------------------------------------ */int process_station_lrecs(inputfile, which_station)FILE *inputfile;int which_station;{	offset = 0;	/* read in a 32768 buffer */	memset(precord, ' ', PRECL);	num_bytes_read = fread(precord, 1, PRECL, inputfile);   	lrecord_ptr = precord_ptr = precord; 	offset = 0;	while (1)	{		read_logical_record(lrecord_ptr); 		if (input.type != 'S')		{			if (offset == 0)			{				/* so subsequent read() in "main" will be right */				fseek(inputfile, -num_bytes_read, 1);			}				lrecord_ptr -= LRECL;			offset -= LRECL;			return;	/* bale */		}		else		{			if (process_stnh() == 0)				/* took a look and the station isn't wanted */				return;		}		/* don't look if at end of station list, just bale, see above */		if (which_station < type11.number_stations - 1)				/* if current logical record is <= the next stations, we are done */			if (input.recordnumber >= type11.station[which_station+1].sequence_number - 1)			{				return;	/* finished with this station */			}		/* if a blockette happens to exactly match the end of LRECL 		 * buffer, procees_stnh() returns, but there is really more		 */		if (offset + LRECL >= PRECL)		{			/* we've exhausted this buffer, grab some more */			/* but clear precord first in case we are already 			 * at EOF. 			 */			memset(precord, ' ', PRECL); 			num_bytes_read = fread(precord, 1, PRECL, inputfile);			lrecord_ptr = precord_ptr = precord; 			offset = 0;		}		else		{			/* not quite done with the big buffer */			lrecord_ptr = precord + offset + LRECL;			offset += LRECL;		}	}		/* while not finished */	return;}/*=====================================================================*//* SEED reader    |         parse_option            |    subprocedure *//*=====================================================================*/int parse_option(option, arg)int option;char *arg;{	switch (option)	{	case 'a':		abbrev_flag = TRUE;		fprintf (stderr,"\ta = read abbreviation dictionaries\n");		break;	case 'b':		seis_buffer_length = atoi(arg);		fprintf(stderr, "\tb = set sample buffer length : %d\n", seis_buffer_length);		break;	case 'C':		if (strcasecmp(arg, "STN") == 0)		{			station_comments_flag = TRUE;			fprintf(stderr, "Output station comments selected\n");		}		else		if (strcasecmp(arg, "CHN") == 0)		{			channel_comments_flag = TRUE; 			fprintf(stderr, "Output channel comments selected\n");		}                	else 		{			fprintf(stderr, "Output station and channel comments selected (default)\n");			station_comments_flag = channel_comments_flag = 1;		}		break;	case 'c':		contents_flag = TRUE;		fprintf (stderr,"\tc = read volume table of contents\n");		break;	case 'd':		data_flag = TRUE;		fprintf (stderr,"\td = read data from tape\n");		break;	case 'e':		fprintf(stderr,"\te = extract event/station data\n");               	event_flag = TRUE;               	break;	case 'f':		strcpy (inputfilename, arg);		fprintf (stderr,"\tTaking input from %s\n", inputfilename);		break;	case 'g':		fprintf (stderr,"\tUsing alt response file(s): %s\n", arg);		close_alt_files();		init_alt_files(arg);		break;	case 'i':		fprintf(stderr, "\ti = ignore network codes\n");		ignore_net_codes = TRUE;		break;		case 'k':                fprintf(stderr, "\tk = strip records w zero samples\n");                strip_flag = TRUE;                break;  	case 'l':		snoop_flag = TRUE;		if (abbrev_flag || contents_flag || 			stations_flag || times_flag || data_flag)		{			fprintf (stderr, "l is an exclusive option.\n");			usage ();		}		fprintf (stderr,"\tl = list contents of each logical record\n");		break;	case 'o':		outputformat_flag = TRUE;		switch (*arg)		{			case '1' : 				output_format = 0; 				break;			case '2' : 				output_format = 1; 				break;			case '3' : 				output_format = 2; 				break;			case '4' : 				output_format = 3; 				mini_flag = TRUE;				break;  /* miniseed */			case '5' : 				output_format = 4;				break;  /* seed */			case '6' :				output_format = 5;				break;  /* sac ascii */			case '7' :				output_format = 6;				break;			default:   				output_format = 0; 				break;		}		break;	case 'p':		fprintf(stderr,"\tp = output poles and zeros\n");                Output_PnZs = TRUE;                break;	case 'q':		strcpy(output_dir, arg);		break;	case 'Q':		switch (*arg) 		{			case('D') : 				q_flag = 'D';				fprintf(stderr,"\tQ = scanning for Undetermined Quality\n");				break;			case('R') :				q_flag = 'R';				fprintf(stderr,"\tQ = scanning for Raw Quality\n");				break;			case('Q') :				q_flag = 'Q';				fprintf(stderr,"\tQ = scanning for Quality controlled data \n");				break;			default :	                       	q_flag = 'E';				fprintf(stderr,"\tQ = scanning for all data \n");				break;		}		break; 						case 'R':		fprintf(stderr,"\tR = print response data (with addressing for evresp)\n");		outresp_flag = TRUE;		break;	case 'S':	    	fprintf(stderr,"\tS = extract station data\n");		ex_stn_flag = TRUE;		break;	case 's':		stations_flag = TRUE;		fprintf (stderr,"\ts = read station headers\n");		break;	case 't':		times_flag = TRUE;		if (abbrev_flag || contents_flag || snoop_flag ||				stations_flag || data_flag)		{			fprintf (stderr, "t is an exclusive option.\n");			usage ();		}		fprintf (stderr,"\tt = list start/stop times\n");		break;	case 'u':		if (inputfile != NULL) fclose (inputfile);		usage ();		exit (1);	case 'v':		sscanf(arg,"%d",&volume_number);		if (volume_number < 1 || volume_number >100) 			volume_number = 1;		fprintf(stderr,"\tv = volume number %d selected\n",volume_number);		break;	case 'x':         	read_summary_flag = TRUE;               	/* if not io_error */               	read_summary_flag = 		     read_summary_file(arg);		data_flag = TRUE;		break;	case 'z':		sscanf(arg,"%d",&check_reverse);		if (check_reverse < 0 || check_reverse > 3) 			check_reverse = 0;		fprintf(stderr,"\tz = check reversal %d selected\n",check_reverse);		break;	default:		break;	}}/*                 +=======================================+                 *//*======================================================================*//* SEED reader    |         option_prompt             |    subprocedure *//*======================================================================*//* read interactive user input */option_prompt(){	char buffer[120], *p, *p2;	int i, comments_flag;	comments_flag = FALSE;	/* signal "weed" that the request has cycled */	if (from_weed)	{		kill(getppid(), SIGUSR1); 		sleep(3);	}	i = 1;	while (i)	{		printf("Input  File (/dev/nrst0) or 'Quit' to Exit: ");		fflush(stdout);		if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit (0);		NO_NL(buffer);		strip_blanks(buffer, buffer);		if (strcasecmp(buffer,"QUIT") == 0) 		{			exit(0);			if (rdseed_alert)                		fprintf(stderr, "Attention, please note there are alert messages in the rdseed alert file: rdseed.alert_log.todays_date\n");		}		if (strlen(buffer) != 0) strcpy(inputfilename,buffer);		if ((inputfile = fopen(inputfilename, "r")) == NULL)		{			fprintf (stderr, "ERROR... Input file %s unavailable for reading.\n", inputfilename);			perror("rdseed");		}		else i = 0;	}	/* take a look see to see what version SEED we are dealing with,	 * that way we will know whether to prompt for network. 	 */#if 0	if (!get_type10(alt_headerfile?alt_headerfile:inputfile))		type10.version = 2.3;#endif	fclose(inputfile);	printf("Output File (stdout)\t: ");	fflush(stdout);	if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit (0); 	NO_NL(buffer);	strip_blanks(buffer, buffer);	if (strlen(buffer) != 0)	{		if ((outputfile = fopen(buffer, "w")) == NULL)		{			fprintf(stderr,"!!! Error - Invalid Output File Name... Device will be STDOUT\n");			outputfile = stdout;			output_pipe = TRUE;		}	}	else	{		outputfile = stdout;		output_pipe = TRUE;	}	printf("Volume #  [(1)-N]\t: ");        fflush(stdout); 	if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0);	NO_NL(buffer);	i = sscanf(buffer,"%d",&volume_number);	if (i == 0) volume_number = 1;	printf("Options [acCsSpRtde]\t: ");        fflush(stdout); 	if (fgets(buffer,sizeof(buffer),stdin) == NULL) exit(0);	NO_NL(buffer);	i = 0;	while(buffer[i])	{		switch (buffer[i++])		{			case 'a': abbrev_flag 	= TRUE;		break;			case 'c': contents_flag = TRUE;		break;			case 'C': comments_flag = TRUE;		break;			case 's': stations_flag = TRUE;		break;			case 'p': Output_PnZs   = TRUE;		break;			case 't': times_flag 	= TRUE;		break;			case 'd': data_flag 	= TRUE;		break; 			case 'R': outresp_flag 	= TRUE;		break;			case 'e': event_flag 	= TRUE;		break;			case 'S': ex_stn_flag 	= TRUE;		break;		}	}	if (comments_flag)	{			/* ask whether station or channel or both */		printf("Station/Channel comments or both (S/C/CR)\t:");		fgets(buffer,sizeof(buffer),stdin);		NO_NL(buffer);		if (buffer[0] == 's' || buffer[0] == 'S')			station_comments_flag = TRUE;		else		if (buffer[0] == 'c' || buffer[0] == 'C')			channel_comments_flag = TRUE;		else			station_comments_flag=channel_comments_flag=TRUE;			}	if (data_flag||mini_flag)	{		char *summary_fname;		/* ask for summary file */		printf("Summary file (None)\t:");		fgets(buffer, sizeof(buffer), stdin);		NO_NL(buffer);		if (strcmp(buffer, "") != 0)		{			read_summary_flag = TRUE;						/* Format of input can be "sum_file_name event_flag" */			summary_fname = strtok(buffer, " ");			if (strtok(NULL, " ") != NULL)				/* assume any param is a flag */				EventDirFlag = TRUE;			/* if not io_error */			read_summary_flag = read_summary_file(summary_fname);		}	}	if (data_flag||mini_flag||stations_flag||ex_stn_flag||		outresp_flag || outresp_old_flag || 			comments_flag || Output_PnZs /* whew */) 	{		if (!read_summary_flag)		{		printf("Station List (ALL)\t: ");	        fflush(stdout); 		if (fgets(station_list, sizeof(station_list), stdin) == NULL) 			exit(0);		NO_NL(station_list);		station_count = 0;			p = strtok(station_list," ,");		while(p != NULL)		{			station_point[station_count] = p;			station_count++;			p = strtok(NULL," ,");		}		printf("Channel List (ALL)\t: ");	        fflush(stdout); 		if (fgets(channel_list, sizeof(channel_list), stdin) == NULL) 				exit(0);		NO_NL(channel_list);		channel_count = 0;			p = strtok(channel_list," ,");			while(p != NULL)		{			channel_point[channel_count] = p;			channel_count++;			p = strtok(NULL," ,");		}		printf("Network List (ALL)\t: ");	        fflush(stdout);         	if (fgets(network_list, sizeof(network_list), stdin) == NULL)            		exit(0);		NO_NL(network_list);         	network_count = 0;

⌨️ 快捷键说明

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