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

📄 is_in_twindow.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*===========================================================================*//*                 |                                       |                 *//*===========================================================================*//*	Name:		is_in_twindow	Purpose:	determine if a blockette overlaps a time window	Usage:			Input:			Output:		returns +1 if this blockette's effective time				was explicit and was in window, 0 if blockette time				was disjoint with window.	Externals:		Warnings:		Errors:			Fatals:	Called by:		Calls to:		Algorithm:		Notes:			Problems:		References:		Language:		Author:		03/??/89	Mark WIederspahn	Revisions:	mm/dd/yy  pgmr name  change				06/21/89	mw	fix incorrect start offset for find_btime								of 059 blockettes: was 9, should be 7.				15may90		mw	enhancement								allow 043-048 as abbreviation blockettes								allow 060 as blockette for SEED v2.1 spec.				24apr91		mw	change								this routine is called so often, do not								print out debug start/end unless DEBUG is								at a high level.				05dec91		mw	change								blockette 041 abbreviation blockette,								061 is legal blockette for v2.2 SEED				18mar99		Stephane Zuzlewski								Blockette 042 abbreviation blockette,								062 is legal blockette for v2.3 SEED*/#include "output.h"int is_in_twindow( top, btype, blen, start, end )char	*top;				/* start of blockette */int		btype;				/* blockette's type */int		blen;				/* blockette's length */struct	input_time	start;	/* start time of desired window */struct	input_time	end;	/* end time of desired window */{	int	result;					/* what we decided */	struct input_time zeros;	/* null time */	struct input_time bstart;	/* blockette start time */	struct input_time bend;		/* blockette end time */	int	err;					/* oops flag */	int	ivers;					/* seed version, sort of */	if( Debug >= D_MAX ) fprintf( D_OUT,"[is_in_twindow] start\n" );	memset( &zeros, 0, sizeof( struct input_time ) );	result = FALSE;							/* do not accept this blockette *//* * abbreviation blockettes are always accepted. However, what a legal * abbreviation blockette number is, depends on what version we write. * * for v2.0: only   30-35 * for v2.1: v2.0 + 43-48 * for v2.2: v2.1 + 41 * for v2.3: v2.2 + 42 */	if( btype >= 30 && btype <= 35 ||	    btype == 41                ||	    btype == 42		       ||		btype >= 43 && btype <= 48 )		/* an abbreviation blockette */	{		if( SEED_Version >= 20 )			if( btype >= 30 && btype <=35 ) result = TRUE;		if( SEED_Version >= 21 )			if( btype >= 43 && btype <= 48 ) result = TRUE;		if( SEED_Version >= 22 )			if( btype == 41 )                result = TRUE;		if( SEED_Version >= 23 )			if( btype == 42 )                result = TRUE;	}	else if( (btype >= 50) && (btype <= 62) )	/* station/channel blockette */	{/* * find_btime gets the effective times of the blockette, using a "clever" * scheme which depends on the SEED format of the blockette. This is * similar, but not identical, for each of the interesting blockettes. * This is what the three mysterious constants do here: * count = how many ~ terminated strings occur BEFORE the start time. * offset = how far from the ~+1 byte does the start time begin? * max = how many bytes (worst case) before we give up finding a ~. * (max should *never* be needed...) */		if( (btype == 50) ||			(btype == 51) ||			(btype == 52) ||			(btype == 59) )		{			if( btype == 50 )				err=find_btime( top, 1, 9, 108, &bstart, &bend );			else if( btype == 51 )				err=find_btime( top, 0, 7, 999, &bstart, &bend );			else if( btype == 52 )				err=find_btime( top, 2, 0, 156, &bstart, &bend );			else if( btype == 59 )				err=find_btime( top, 0, 7, 999, &bstart, &bend );			if( err )				(void) error_handler( ERROR,"[is_in_twindow] bad blockette" );/* * if the blockette start is the same as the end time, do not include it. * this prevents incorrect inclusion when the blockette really ends at * 23:59:59.9999, but says 00:00:00.0000 of the next day. */			if( cmp_longtime( bend, zeros ) == 0 )	/* if a null end time */			{				if( cmp_longtime( bstart, end ) <  0 ) result = TRUE;				if( Debug >= D_MAX ) fprintf(D_OUT,					"[is_in_twindow] B%d is, end null\n", btype );			}			else			{				if( cmp_longtime( bstart, end   ) <  0 &&					cmp_longtime( bend,   start ) >= 0 )				{					result = TRUE;					if( Debug >= D_MAX ) fprintf(D_OUT,						"[is_in_twindow] B%d is, end explicit\n", btype );				}			}		}		else	/* btype =50,51,52,59 */		{/* *			accept any (53-58) since we can't tell the time *			and accept 60,61,62 depending on version we write */			if( btype >= 53 && btype <= 58 )			{				result = TRUE;			}			else			{				if( SEED_Version >= 21 && btype == 60 ) result = TRUE;				if( SEED_Version >= 22 && btype == 61 ) result = TRUE;				if( SEED_Version >= 23 && btype == 62 ) result = TRUE;			}			if( result && Debug >= D_MAX ) fprintf(D_OUT,				"[is_in_twindow] assume B%d is\n", btype );		}	}	else	{		fprintf( D_OUT,"bad blockette: btype=%d blen=%d top=%.7s\n",			btype, blen, top );		(void) error_handler( FATAL,"[is_in_twindow] illegal blockette" );		result = 0;	}	if( result == FALSE )		if( Debug >= D_MAX )			fprintf( D_OUT,"[is_in_twindow] B%d ain't\n", btype);	if( Debug >= D_MAX ) fprintf( D_OUT,"[is_in_twindow] end\n" );	return( result );}

⌨️ 快捷键说明

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