[segyio] 107/376: Matlab uses segy_file over FILE
Jørgen Kvalsvik
jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:16 UTC 2017
This is an automated email from the git hooks/post-receive script.
jokva-guest pushed a commit to branch debian
in repository segyio.
commit c09beae7d7d672c7a9cf655da6a5227747e0c7f5
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date: Wed Nov 9 12:38:58 2016 +0100
Matlab uses segy_file over FILE
---
mex/segy_get_header_mex.c | 6 +++---
mex/segy_get_ntraces_mex.c | 4 ++--
mex/segy_get_segy_header_mex.c | 4 ++--
mex/segy_get_trace_header_mex.c | 4 ++--
mex/segy_get_traces_mex.c | 6 +++---
mex/segy_put_headers_mex.c | 6 +++---
mex/segy_put_traces_mex.c | 6 +++---
mex/segy_read_write_line_mex.c | 10 +++++-----
mex/segyutil.c | 6 +++---
mex/segyutil.h | 6 ++++--
10 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/mex/segy_get_header_mex.c b/mex/segy_get_header_mex.c
index 37c9780..31a6323 100644
--- a/mex/segy_get_header_mex.c
+++ b/mex/segy_get_header_mex.c
@@ -16,7 +16,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
int err;
const char* filename = mxArrayToString( prhs[ 0 ] );
- FILE* fp = segyfopen( prhs[ 0 ], "rb" );
+ segy_file* fp = segyfopen( prhs[ 0 ], "rb" );
int field = mxGetScalar( prhs[ 1 ] );
@@ -48,13 +48,13 @@ void mexFunction(int nlhs, mxArray *plhs[],
out[ i ] = f;
}
- fclose( fp );
+ segy_close( fp );
plhs[ 1 ] = mxCreateDoubleScalar( fmt.traces );
return;
cleanup:
- fclose( fp );
+ segy_close( fp );
cleanup_fopen:
mexErrMsgIdAndTxt( msg1, msg2 );
diff --git a/mex/segy_get_ntraces_mex.c b/mex/segy_get_ntraces_mex.c
index 66e8ae2..09d1d8c 100644
--- a/mex/segy_get_ntraces_mex.c
+++ b/mex/segy_get_ntraces_mex.c
@@ -6,9 +6,9 @@
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]) {
- FILE* fp = segyfopen( prhs[ 0 ], "rb" );
+ segy_file* fp = segyfopen( prhs[ 0 ], "rb" );
struct segy_file_format fmt = filefmt( fp );
- fclose( fp );
+ segy_close( fp );
plhs[0] = mxCreateDoubleScalar( fmt.traces );
}
diff --git a/mex/segy_get_segy_header_mex.c b/mex/segy_get_segy_header_mex.c
index 8ef5f76..b5664c1 100644
--- a/mex/segy_get_segy_header_mex.c
+++ b/mex/segy_get_segy_header_mex.c
@@ -14,7 +14,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
char* msg2;
int err;
- FILE* fp = segyfopen( prhs[ 0 ], "rb" );
+ segy_file* fp = segyfopen( prhs[ 0 ], "rb" );
char* textheader = mxMalloc( segy_textheader_size() );
err = segy_read_textheader( fp, textheader );
@@ -39,6 +39,6 @@ void mexFunction(int nlhs, mxArray *plhs[],
return;
cleanup:
- fclose( fp );
+ segy_close( fp );
mexErrMsgIdAndTxt( msg1, msg2 );
}
diff --git a/mex/segy_get_trace_header_mex.c b/mex/segy_get_trace_header_mex.c
index 1d4305a..2bdedc6 100644
--- a/mex/segy_get_trace_header_mex.c
+++ b/mex/segy_get_trace_header_mex.c
@@ -14,7 +14,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
char* msg2;
int err;
- FILE* fp = segyfopen( prhs[ 0 ], "rb" );
+ segy_file* fp = segyfopen( prhs[ 0 ], "rb" );
struct segy_file_format fmt = filefmt( fp );
int traceno = mxGetScalar( prhs[ 1 ] );
@@ -26,7 +26,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
plhs[ 0 ] = mxCreateCharArray( 1, dims );
err = segy_traceheader( fp, traceno, mxGetData( plhs[ 0 ] ), fmt.trace0, fmt.trace_bsize );
- fclose( fp );
+ segy_close( fp );
if( err != 0 ) {
msg1 = "segy:get_trace_header:os";
diff --git a/mex/segy_get_traces_mex.c b/mex/segy_get_traces_mex.c
index 10aec29..8583b91 100644
--- a/mex/segy_get_traces_mex.c
+++ b/mex/segy_get_traces_mex.c
@@ -14,7 +14,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
char* msg2;
int err;
- FILE* fp = segyfopen( prhs[ 0 ], "rb" );
+ segy_file* fp = segyfopen( prhs[ 0 ], "rb" );
int first_trace = mxGetScalar( prhs[ 1 ] );
int last_trace = mxGetScalar( prhs[ 2 ] );
int notype = mxGetScalar( prhs[ 3 ] );
@@ -54,7 +54,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
}
}
- fclose( fp );
+ segy_close( fp );
if( notype != -1 )
fmt.format = notype;
@@ -69,7 +69,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
return;
cleanup:
- fclose( fp );
+ segy_close( fp );
cleanup_fopen:
mexErrMsgIdAndTxt( msg1, msg2 );
diff --git a/mex/segy_put_headers_mex.c b/mex/segy_put_headers_mex.c
index 8835019..3b5b3b9 100644
--- a/mex/segy_put_headers_mex.c
+++ b/mex/segy_put_headers_mex.c
@@ -14,7 +14,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
char* msg2;
int err;
- FILE* fp = segyfopen( prhs[ 0 ], "r+b" );
+ segy_file* fp = segyfopen( prhs[ 0 ], "r+b" );
double* headers = mxGetPr( prhs[ 1 ] );
int field = mxGetScalar( prhs[ 2 ] );
@@ -53,10 +53,10 @@ void mexFunction(int nlhs, mxArray *plhs[],
}
}
- fclose( fp );
+ segy_close( fp );
return;
cleanup:
- fclose( fp );
+ segy_close( fp );
mexErrMsgIdAndTxt( msg1, msg2 );
}
diff --git a/mex/segy_put_traces_mex.c b/mex/segy_put_traces_mex.c
index 51acf19..4f6de85 100644
--- a/mex/segy_put_traces_mex.c
+++ b/mex/segy_put_traces_mex.c
@@ -14,7 +14,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
char* msg2;
int err;
- FILE* fp = segyfopen( prhs[ 0 ], "r+b" );
+ segy_file* fp = segyfopen( prhs[ 0 ], "r+b" );
plhs[ 0 ] = mxDuplicateArray( prhs[ 1 ] );
int first_trace = mxGetScalar( prhs[ 2 ] );
int last_trace = mxGetScalar( prhs[ 3 ] );
@@ -53,7 +53,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
}
}
- fclose( fp );
+ segy_close( fp );
segy_to_native( fmt.format, fmt.samples * fmt.traces, out );
@@ -62,7 +62,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
return;
cleanup:
- fclose( fp );
+ segy_close( fp );
segy_to_native( fmt.format, fmt.samples * fmt.traces, out );
mexErrMsgIdAndTxt( msg1, msg2 );
diff --git a/mex/segy_read_write_line_mex.c b/mex/segy_read_write_line_mex.c
index 8ccf929..08c0a16 100644
--- a/mex/segy_read_write_line_mex.c
+++ b/mex/segy_read_write_line_mex.c
@@ -42,7 +42,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
uint32_t stride = (uint32_t)mxGetScalar(mx_stride);
- FILE* fp;
+ segy_file* fp;
unsigned int line_trace0;
@@ -52,7 +52,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
}
if (read) {
- fp = fopen( spec.filename, "rb" );
+ fp = segy_open( spec.filename, "rb" );
if (fp == NULL) {
goto CLEANUP;
}
@@ -71,7 +71,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
}
}
else {
- fp = fopen( spec.filename, "r+b" );
+ fp = segy_open( spec.filename, "r+b" );
if (fp == NULL) {
goto CLEANUP;
}
@@ -96,11 +96,11 @@ void mexFunction(int nlhs, mxArray *plhs[],
}
}
- fclose(fp);
+ segy_close(fp);
return;
CLEANUP:
- fclose(fp);
+ segy_close(fp);
ERROR:
{
int nfields = 1;
diff --git a/mex/segyutil.c b/mex/segyutil.c
index 313ff5d..64abd25 100644
--- a/mex/segyutil.c
+++ b/mex/segyutil.c
@@ -51,7 +51,7 @@ struct segy_file_format buffmt( const char* binary ) {
return fmt;
}
-struct segy_file_format filefmt( FILE* fp ) {
+struct segy_file_format filefmt( segy_file* fp ) {
char binary[SEGY_BINARY_HEADER_SIZE];
int err = segy_binheader( fp, binary );
@@ -74,10 +74,10 @@ struct segy_file_format filefmt( FILE* fp ) {
mexErrMsgIdAndTxt( msg1, msg2 );
}
-FILE* segyfopen( const mxArray* filename, const char* mode ) {
+segy_file* segyfopen( const mxArray* filename, const char* mode ) {
const char* fname = mxArrayToString( filename );
- FILE* fp = fopen( fname, mode );
+ segy_file* fp = segy_open( fname, mode );
int err = errno;
mxFree( (void*)fname );
diff --git a/mex/segyutil.h b/mex/segyutil.h
index 2b006ab..c9fe634 100644
--- a/mex/segyutil.h
+++ b/mex/segyutil.h
@@ -6,6 +6,8 @@
#include <mex.h>
+#include <segyio/segy.h>
+
#include "spec/segyspec.h"
@@ -20,7 +22,7 @@ struct segy_file_format {
};
struct segy_file_format buffmt( const char* );
-struct segy_file_format filefmt( FILE* );
-FILE* segyfopen( const mxArray* filename, const char* mode );
+struct segy_file_format filefmt( segy_file* );
+segy_file* segyfopen( const mxArray* filename, const char* mode );
#endif //SEGYIO_SEGYUTIL_H
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/segyio.git
More information about the debian-science-commits
mailing list