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

📄 build_lrec.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*===========================================================================*//* DMC Interim out |             build_lrec                |    SEED Headers *//*===========================================================================*//*	Name:		build_lrec	Purpose:	construct SEED logical records from properly-sized data streams	Usage:		void build_lrec ();				char *header_data;				char type;				int continuation;				int length;				build_lrec (header_data, type, continuation, length);	Input:		header_data = ptr to beginning of a data stream				type = a valid SEED data type (V, A, S, T, D)				continuation = continuation flag (TRUE or FALSE)				length = number of characters in input data stream	Output:		none	Externals:	Debug - setting of environment variable DEBUG (globals.h)				Headers_head and Headers_tail	Messages:	none	Warnings:	none	Errors:		none	Fatals:		none	Called by:	make_lrec	Calls to:	error_handler - handle error conditions	Algorithm:	receive a datastream of at most LRECL - 8 characters;				allocate space for a logical record; put the 6 character				sequence number spaceholder (all zeroes), the data type, and				' ' or '*' as continuation flag into the record; put the				data stream into the record.  Link the result into the				header linked list.	Notes:		none	Problems:	none known	Debug:		level D_MIN - print out start and finish notices				level D_MED -				level D_MAX -	References:	none	Language:	C, more or less ANSI standard, under Sun OS 3.5	Revisions:	03/03/89  Dennis O'Neill  original version				03/06/89 mark wiederspahn re-written*/#include "output.h"int build_lrec (header_data, type, continuation, length )char *header_data;								/* ptr to data stream */char type;										/* SEED block type */int continuation;								/* continuation flag */int length;										/* length of input string */{	char *header;								/* output stream */	register char *p;							/* buffer fill ptr */	int error;									/* error value */	error = FALSE;	if (Debug >= D_MIN) fprintf (D_OUT, "[build_lrec] Started.\n");	if( length < 0 || length > Lrecl-8 )	{		error = error_handler( FATAL,"[build_lrec] length bad");		return( error );	}                   /*=====================================*//*=================|   allocate space for logical record   |=================*/                   /*=====================================*/	if ((header = (char *) malloc (Lrecl * sizeof (char))) == NULL)	{		error = error_handler (FATAL,			"[build_lrec] Unable to malloc sufficient space.");		return( error );	}                   /*=====================================*//*=================|          construct leader             |=================*/                   /*=====================================*/	strncpy( header, "000000", 6 );	*(header+6) = type;	*(header+7) = continuation ? '*' : SPACE ;                   /*=====================================*//*=================|      put data into logical record     |=================*/                   /*=====================================*/	if( length > 0 ) memcpy( header+8, header_data, length );	/* if necessary, blank-pad out to logical record length */	p = header+8+length;	length = (Lrecl-8) - length;	while( length-- ) *p++ = SPACE;                   /*=====================================*//*=================|     link logical record into list     |=================*/                   /*=====================================*//* * create and link a node into list, set it to point to our new log rec */	(void)make_logrec( &Headers_head, &Headers_tail );	Headers_tail->record = header;	if( Debug >= D_MIN ) fprintf (D_OUT, "[build_lrec] Completed.\n");	return( error );}

⌨️ 快捷键说明

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