资源简介
要处理地震数据seed文件就必须使用的必要工具!
代码片段和文件信息
/* low level i/o routines for ah format records
* -- witte 6 june 85
*/
#include
#include
#include
#include
#ifndef _CYGWIN
#include
#else
#include
#endif
#include
#include “ahhead.h“
/* ah error processing */
int ah_errno = 0;
int ah_nerr = 10;
/* ah error numbers */
#define AE_RHED 1 /* error reading header */
#define AE_DTYPE 2 /* bad data type */
#define AE_WHED 3 /* error writing header */
#define AE_RDATA 4 /* error reading data */
#define AE_WDATA 5 /* error writing data */
#define AE_WRECORD 6 /* error writing record */
#define AE_RRECORD 7 /* error reading record */
#define AE_TTYOUT 8 /* binary going to tty */
#define AE_TTYIN 9 /* binary coming from tty */
/* ah errlist */
char *ah_errlist[] = {
“no error“ /* 0 no error */
“read header error“ /* 1 AE_RHED */
“bad data type“ /* 2 AE_DTYPE */
“write header error“ /* 3 AE_WHED */
“read data error“ /* 4 AE_RDATA */
“write data error“ /* 5 AE_WDATA */
“write record error“ /* 6 AE_WRECORD */
“read record error“ /* 7 AE_RRECORD */
“tty can‘t get binary“ /* 8 AE_TTYOUT */
“tty can‘t send binary“ /* 9 AE_TTYIN */
};
/* gethead
* gets the next header from the stream pointed to by
* file_pt and returns this header in the structure head.
* file_pt is assumed to be positioned at the next header
* and does not search.
* returns:
* 1 -> no error
* -1 -> not enough head to read
* -2 -> bad data type
*/
int gethead(headfile_pt)
FILE *file_pt;
ahhed *head;
{
int ierr = 0;
if((ierr = fread((char *)headsizeof(ahhed)1file_pt)) == 1)
{
if((head->record.type < TYPEMIN) || (head->record.type > TYPEMAX))
{
get_null_head(head);
ierr = -2; /* bad data type */
ah_errno= AE_DTYPE;
}
}
else /* not enough head */
{
get_null_head(head);
ierr = -1;
ah_errno= AE_RHED;
}
return(ierr);
}
/* puthead
* writes the header head onto the stream pointed to by
* file_pt.
* returns:
* 1 -> no error
* -1 -> error writing header
*/
int puthead(headfile_pt)
FILE *file_pt;
ahhed *head;
{
int ierr = 0;
if((ierr= fwrite((char *)headsizeof(ahhed)1file_pt)) != 1)
{
ah_errno= AE_WHED;
ierr= -1;
}
return(ierr);
}
/* size
* returns the size (in bytes) of the data type given by
* head->record.type.
* returns:
* size of data type -> no error
* -1 -> unknown data type
*/
int size(head)
ahhed *head;
{
int type_size = 0;
switch(head->record.type)
{
case 1: /* real time series */
type_size= sizeof(float);
break;
case 2: /* complex time series */
type_size= sizeof(complex);
break;
case 3: /* real xy pairs */
type_size= sizeof(vector);
break;
case 4: /* x real y complex or real xyz */
type_size= sizeof(tensor);
break;
case 5: /* complex xy pairs */
type_size= 2*sizeof(complex);
break;
case 6: /* double */
type_size=sizeof(double);
break;
default: /* unknown data typ
- 上一篇:stm32 adc多通道采集 库函数版本
- 下一篇:网页爬虫 非常实用工具
评论
共有 条评论