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

📄 patch_field.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*===========================================================================*//* DMC Interim     |             patch_field.c            |                 *//*===========================================================================*//*	Name:		patch_field.c	Purpose:	patch a field in a SEED header blockettes	Usage:			Input:		buf		the blockette				count	the number of variable length strings to skip						(may be 0) before applying "offset"				offset	offset from the next character after the "count'th"						variable length string terminator to the start time.				maxlen	maximum possible chars before the count'th						terminator MUST be found. This gets around infinite						loops in case of a mangled blockette.				nb		number of bytes in the "D" field to be patched				value	value to right-justified in "D" field	Output:			Externals:		Warnings:		Errors:		blockette is mangled; terminator not found	Fatals:	Called by:	load_data	Calls to:		Algorithm:		Notes:			Problems:		References:		Language:		Author:	    04/20/89 Kevin MacKenzie	Revisions:	mm/dd/yy  pgmr name  change				06/22/89	mw	fix several usage bugs:							no initial value for "op" caused random overwrite							incorrect return value from sprintf was used -							is char *, not char count; benign error.*/#include "output.h"int patch_field ( buf, count, offset, maxlen, value, fmt )char	*buf;				/* where the blockette is */int		count;				/* number of terminators to skip, may be 0 */int		offset;				/* distance from STR_TERM+1 to start time */int		maxlen;				/* how long to look for STR_TERM before giving up */int		value;				/* the integer value to use in the patch */char	*fmt;				/* the format string to use to control the patch */{	int				err;			/* return status */	register char	*ip;			/* input pointer */	register char	*op;			/* output pointer */	char			lbuf[100];		/* output temp (avoid null insertion) */	if( Debug ) fprintf( D_OUT,"[patch_field] start\n" );	err = FALSE;	ip = buf;	op = lbuf;	(void)sprintf (op, fmt, value);	/* format the value based on fmt */	while( count-- )	{		while( *ip++ != STR_TERM && maxlen-- );	/* skip variable length field */		if( maxlen < 0 ) break;	}	if( maxlen >= 0 )			/* we did not exhaust search limit */	{		ip += offset;			/* point to start of the field */		while( *op ) *ip++ = *op++;		/* copy string upto NULL */	}	else	{		fprintf( D_OUT,"[patch_field] bad input:\n%.*s\n", maxlen, buf );		err = ERROR;	}	if( Debug ) fprintf( D_OUT,"[patch_field] end\n" );	return( err );}

⌨️ 快捷键说明

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