[segyio] 350/376: Add version printer to apputils

Jørgen Kvalsvik jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:57 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 8bc40b2e171d34507e4105ed0aac266fd27f34c6
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date:   Wed Aug 16 14:06:45 2017 +0200

    Add version printer to apputils
---
 applications/CMakeLists.txt | 20 ++++----------------
 applications/apputils.c     |  5 +++++
 applications/apputils.h     |  1 +
 applications/segyio-catb.c  |  8 +-------
 applications/segyio-cath.c  |  7 +------
 applications/segyio-catr.c  |  7 +------
 applications/segyio-crop.c  |  7 +------
 7 files changed, 14 insertions(+), 41 deletions(-)

diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt
index d1d0235..fb68c90 100644
--- a/applications/CMakeLists.txt
+++ b/applications/CMakeLists.txt
@@ -11,6 +11,10 @@ endif()
 
 add_library(apputils STATIC apputils.c)
 target_link_libraries(apputils segyio)
+target_compile_definitions(apputils PUBLIC
+    -Dsegyio_MAJOR=${segyio_MAJOR}
+    -Dsegyio_MINOR=${segyio_MINOR}
+)
 
 add_executable(segyinfo segyinfo.c)
 target_link_libraries(segyinfo segyio)
@@ -20,31 +24,15 @@ target_link_libraries(segyinspect segyio)
 
 add_executable(segyio-cath segyio-cath.c)
 target_link_libraries(segyio-cath segyio apputils)
-target_compile_definitions(segyio-cath PRIVATE
-    -Dsegyio_MAJOR=${segyio_MAJOR}
-    -Dsegyio_MINOR=${segyio_MINOR}
-)
 
 add_executable(segyio-catb segyio-catb.c)
 target_link_libraries(segyio-catb segyio apputils)
-target_compile_definitions(segyio-catb PRIVATE
-    -Dsegyio_MAJOR=${segyio_MAJOR}
-    -Dsegyio_MINOR=${segyio_MINOR}
-)
 
 add_executable(segyio-catr segyio-catr.c)
 target_link_libraries(segyio-catr segyio apputils)
-target_compile_definitions(segyio-catr PRIVATE
-    -Dsegyio_MAJOR=${segyio_MAJOR}
-    -Dsegyio_MINOR=${segyio_MINOR}
-)
 
 add_executable(segyio-crop segyio-crop.c)
 target_link_libraries(segyio-crop segyio apputils)
-target_compile_definitions(segyio-crop PRIVATE
-    -Dsegyio_MAJOR=${segyio_MAJOR}
-    -Dsegyio_MINOR=${segyio_MINOR}
-)
 
 install(TARGETS segyinfo DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
 install(TARGETS segyinspect DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
diff --git a/applications/apputils.c b/applications/apputils.c
index 8fd03af..63ca1bf 100644
--- a/applications/apputils.c
+++ b/applications/apputils.c
@@ -46,3 +46,8 @@ int trfield( const char* header, int field ) {
     if( err ) return -1;
     return f;
 }
+
+int printversion( const char* name ) {
+    printf( "%s (segyio version %d.%d)\n", name, segyio_MAJOR, segyio_MINOR );
+    return 0;
+}
diff --git a/applications/apputils.h b/applications/apputils.h
index b2dc550..83d40c0 100644
--- a/applications/apputils.h
+++ b/applications/apputils.h
@@ -6,5 +6,6 @@ int errmsg2( int errcode, const char* prelude, const char* msg );
 int parseint( const char* str, int* x );
 int bfield( const char* header, int field );
 int trfield( const char* header, int field );
+int printversion( const char* name );
 
 #endif //SEGYIO_APPUTILS_H
diff --git a/applications/segyio-catb.c b/applications/segyio-catb.c
index d1a7fe2..c5b5770 100644
--- a/applications/segyio-catb.c
+++ b/applications/segyio-catb.c
@@ -21,12 +21,6 @@ static int printhelp(){
     return 0;
 }
 
-static int printversion(){
-    printf( "segyio-catb (segyio version %d.%d)\n",
-             segyio_MAJOR, segyio_MINOR );
-    return 1;
-}
-
 static int get_binary_value( char* binheader, int bfield ){
     int32_t f;
     segy_get_bfield( binheader, bfield, &f );
@@ -152,7 +146,7 @@ int main( int argc, char** argv ){
     struct options opts = parse_options( argc, argv );
    
     if( opts.help )    return printhelp();
-    if( opts.version ) return printversion();
+    if( opts.version ) return printversion( "segyio-catb" );
 
     for( int i = optind; i < argc; ++i ){
         segy_file* fp = segy_open( argv[ i ], "r" );
diff --git a/applications/segyio-cath.c b/applications/segyio-cath.c
index b3120b4..3187469 100644
--- a/applications/segyio-cath.c
+++ b/applications/segyio-cath.c
@@ -28,11 +28,6 @@ static int help() {
     return 0;
 }
 
-static int printversion() {
-    printf( "segyio-cath (segyio version %d.%d)\n", segyio_MAJOR, segyio_MINOR );
-    return 0;
-}
-
 static int ext_headers( segy_file* fp ) {
     char binary[ SEGY_BINARY_HEADER_SIZE ];
     int err = segy_binheader( fp, binary );
@@ -106,7 +101,7 @@ int main( int argc, char** argv ) {
         }
     }
 
-    if( version ) return printversion();
+    if( version ) return printversion( "segyio-cath" );
 
     char header[ SEGY_TEXT_HEADER_SIZE + 1 ] = { 0 };
 
diff --git a/applications/segyio-catr.c b/applications/segyio-catr.c
index b28115a..e05804d 100644
--- a/applications/segyio-catr.c
+++ b/applications/segyio-catr.c
@@ -316,11 +316,6 @@ static int help() {
     return 0;
 }
 
-static int printversion() {
-    printf( "segyio-catr (segyio version %d.%d)\n", segyio_MAJOR, segyio_MINOR );
-    return 0;
-}
-
 typedef struct { int start, stop, step; } range;
 
 struct options {
@@ -467,7 +462,7 @@ int main( int argc, char** argv ) {
     struct options opts = parse_options( argc, argv );
 
     if( opts.help ) return help();
-    if( opts.version ) return printversion();
+    if( opts.version ) return printversion( "segyio-catr" );
     if( opts.errmsg ) return errmsg( EINVAL, opts.errmsg );
 
     int strict = opts.strict;
diff --git a/applications/segyio-crop.c b/applications/segyio-crop.c
index 9cf1364..795a92d 100644
--- a/applications/segyio-crop.c
+++ b/applications/segyio-crop.c
@@ -36,11 +36,6 @@ static int help() {
     return 0;
 }
 
-static int printversion() {
-    printf( "segyio-crop (segyio version %d.%d)\n", segyio_MAJOR, segyio_MINOR );
-    return 0;
-}
-
 struct delay {
     int delay;
     int skip;
@@ -322,7 +317,7 @@ int main( int argc, char** argv ) {
     struct options opts = parse_options( argc, argv );
 
     if( opts.help ) return help() + (opts.errmsg ? 2 : 0);
-    if( opts.version ) return printversion();
+    if( opts.version ) return printversion( "segyio-crop" );
     if( opts.errmsg ) return errmsg( EINVAL, opts.errmsg );
 
     int ibeg = opts.ibeg;

-- 
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