summaryrefslogtreecommitdiff
path: root/src/postprocess/cutfile.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2014-02-20 02:46:41 +0100
committerDirk Engling <erdgeist@erdgeist.org>2014-02-20 02:46:41 +0100
commit64c85dfc1d3b546dd4b5f84168e9256817f3a741 (patch)
treee3de2e7a99362bfa1dfcde3d4bad3e76af179c61 /src/postprocess/cutfile.c
parent632c350fcf2021620afd032994e6e32c34c6dbfb (diff)
clean up source directory
Diffstat (limited to 'src/postprocess/cutfile.c')
-rw-r--r--src/postprocess/cutfile.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/postprocess/cutfile.c b/src/postprocess/cutfile.c
new file mode 100644
index 0000000..a2c87dc
--- /dev/null
+++ b/src/postprocess/cutfile.c
@@ -0,0 +1,33 @@
1#include "mystdlib.h"
2#include <unistd.h>
3
4int main( int argc, char **argv )
5{
6 MAP file = NULL;
7 unsigned long i = 0;
8
9 if( !(file = map_file( argv[1], 0 ) ) ) exit( 1 );
10
11 if( file->size & 15 )
12 puts( "WARNING: File size not multiple of 16" );
13
14 while( i < file->size && *(unsigned long*)(file->addr+i) < 2911418625UL )
15 i+= 16;
16
17 if( i < file->size)
18 {
19 if( i ) {
20 off_t newsize = (off_t)i;
21 printf( "%s reduced by %8d bytes. (Offending offset: %09lu)\n", argv[1], (unsigned long)(file->size - i ), *(unsigned long*)(file->addr+i) );
22 ftruncate( file->fh, newsize );
23 } else {
24 printf( "%s removed. (Offending offset: %09lu)\n", argv[1], *(unsigned long*)(file->addr+i) );
25 unlink( argv[1] );
26 }
27 }
28
29 unmap_file( &file );
30
31
32 return 0;
33}