aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/bindump.c
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2010-01-07 11:44:32 -0900
committerDavid M. Syzdek <david@syzdek.net>2010-01-07 11:48:25 -0900
commitf47c2341e09142c28da6ddb0bb799bf5302f87e1 (patch)
tree0fd37b6b93f68a6aca822e46f8c6a5a9b716f86d /src/bindump.c
parent55169fd31cf41d021bd31f4efdbec5a114efab6f (diff)
downloaddmstools-f47c2341e09142c28da6ddb0bb799bf5302f87e1.tar.gz
dmstools-f47c2341e09142c28da6ddb0bb799bf5302f87e1.tar.bz2
dmstools-f47c2341e09142c28da6ddb0bb799bf5302f87e1.tar.xz
dmstools-f47c2341e09142c28da6ddb0bb799bf5302f87e1.zip
Creating custom lseek function for bindump
Diffstat (limited to 'src/bindump.c')
-rw-r--r--src/bindump.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/bindump.c b/src/bindump.c
index 248920d..0e17c40 100644
--- a/src/bindump.c
+++ b/src/bindump.c
@@ -145,6 +145,9 @@ int main PARAMS((int argc, char * argv[]));
145// closes a file 145// closes a file
146int my_close PARAMS((BinDumpFile * file, uint32_t verbose)); 146int my_close PARAMS((BinDumpFile * file, uint32_t verbose));
147 147
148// preforms lseek on file
149int my_lseek PARAMS((BinDumpFile * file, size_t offset, uint32_t verbose));
150
148//displays usage information 151//displays usage information
149void my_usage PARAMS((void)); 152void my_usage PARAMS((void));
150 153
@@ -281,13 +284,8 @@ int main(int argc, char * argv[])
281 { 284 {
282 if (verbose > 2) 285 if (verbose > 2)
283 printf("offsetting by %zi bytes...\n", offset); 286 printf("offsetting by %zi bytes...\n", offset);
284 if ((lseek(file1.fd, (off_t)offset, SEEK_SET) == -1)) 287 if ((my_lseek(&file1, offset, verbose) == -1))
285 {
286 perror(PROGRAM_NAME ": lseek()");
287 my_close(&file1, verbose);
288 return(1); 288 return(1);
289 };
290 file1.pos += offset;
291 }; 289 };
292 290
293 // fill in white space so the offset markings align with the position in the file 291 // fill in white space so the offset markings align with the position in the file
@@ -361,6 +359,23 @@ int my_close(BinDumpFile * file, uint32_t verbose)
361} 359}
362 360
363 361
362/// preforms lseek on file
363/// @param[in] file file to use for operations
364/// @param[in] offset offset
365/// @param[in] verbose verbose level of messages to display
366int my_lseek(BinDumpFile * file, size_t offset, uint32_t verbose)
367{
368 if ((lseek(file->fd, (off_t)offset, SEEK_SET) == -1))
369 {
370 perror(PROGRAM_NAME ": lseek()");
371 my_close(file, verbose);
372 return(-1);
373 };
374 file->pos += offset;
375 return(0);
376}
377
378
364/// displays usage information 379/// displays usage information
365void my_usage() 380void my_usage()
366{ 381{