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

📄 dmc_entry.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*	dmc_entry.c	02feb89 mwiederspahn utig * * modifed 07jul89 mw	if open for a+ fails, open for r * * This package permits random access to interim DMC holdings files. * * Higher level access to holdings entries is found in "dmc_holding.c" * which knows the assumptions built into the sort order of the file. * (This module has never been written, nor an interface designed.) * * This package assumes only: * a) read/write disk file, b) fixed length records * c) format strings and structures in "DMC.h" apply. * * This package is BSD UNIX specific (due to include files). *//* * open_DMC_entry( name, file, size )	open a holdings file * read_DMC_entry( file, rec, buf )		read a record into buf * get_DMC_entry( file, rec, entry )	read a record into struct entry * write_DMC_entry( file, rec, buf )	write a record from buf * put_DMC_entry( file, rec, entry )	write a record from struct entry * close_DMC_entry( file )				close a holdings file */#include <stdio.h>#include <string.h>#include <sys/file.h>#include <sys/types.h>#include <sys/stat.h>#include "DMC.h"int read_DMC_entry( file, rec, buf )FILE *file;			/* open file */int rec;			/* record number, 0=next */char *buf;			/* output string [DMC_reclen] */{int status;if( rec != 0 )	if( (status=fseek( file, (rec-1)*DMC_entry_reclen,0 )) < 0)		return( status );return( fread( buf, sizeof(char), DMC_entry_reclen, file ) );}int get_DMC_entry( file, rec, entry )FILE *file;				/* open file */int rec;			/* record number, 0=next */struct DMC_entry *entry;	/* returned entry */{	char	*p;	if(fscanf(file, DMC_entry_scan_format, 			entry->statn,			entry->network,			entry->chn,			entry->location,			entry->start, 			entry->end,			entry->file,			entry->superfile) == DMC_entry_count)	{		if((p = strchr(entry->file, ' ' )) != NULL ) *p='\0';		if((p = strchr(entry->superfile, ' ' )) != NULL ) *p='\0';		/* make sure the station name and channel and network are 		 * padded with spaces to field length		 */		if (strlen(entry->statn) < 5) 		{			strncpy(&entry->statn[strlen(entry->statn)], 					"     ", 					5 - strlen(entry->statn));		}		if (strlen(entry->chn) < 3)                {			strncpy(&entry->chn[strlen(entry->chn)], 					"     ", 					3 - strlen(entry->chn));                } 		if (strlen(entry->network) < 2)                {			strncpy(&entry->network[strlen(entry->network)], 				"     ", 				2 - strlen(entry->network));                }		if (strlen(entry->location) < 2)                {                        strncpy(&entry->location[strlen(entry->location)],                                "     ",                                 2 - strlen(entry->location));                  }		return(0);	}	else		return( -1 );}

⌨️ 快捷键说明

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