diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/cmd_close.c | 7 | ||||
-rw-r--r-- | cmd/cmd_pos.c | 2 | ||||
-rw-r--r-- | cmd/cmd_read.c | 3 | ||||
-rw-r--r-- | cmd/cmd_resize.c | 40 | ||||
-rw-r--r-- | cmd/cmd_seek.c | 2 |
5 files changed, 50 insertions, 4 deletions
diff --git a/cmd/cmd_close.c b/cmd/cmd_close.c index d1d6fc7..a789cd0 100644 --- a/cmd/cmd_close.c +++ b/cmd/cmd_close.c @@ -22,5 +22,12 @@ int c_close( cmd_arg_t *arg ) return -1; } + // clean buf + if ( g_buf->buf != NULL ) + { + buf_zero( g_buf ); + buf_free( g_buf ); + } + return 0; }
\ No newline at end of file diff --git a/cmd/cmd_pos.c b/cmd/cmd_pos.c index 845d69d..272ba3f 100644 --- a/cmd/cmd_pos.c +++ b/cmd/cmd_pos.c @@ -19,7 +19,7 @@ int c_pos( cmd_arg_t *arg ) return -1; } - printf("POS:%d\n",fret); + printf("POS %d\n",fret); return 0; }
\ No newline at end of file diff --git a/cmd/cmd_read.c b/cmd/cmd_read.c index 965ae5a..1a4aa89 100644 --- a/cmd/cmd_read.c +++ b/cmd/cmd_read.c @@ -14,8 +14,7 @@ int c_read( cmd_arg_t *arg ) if ( g_buf->buf == NULL ) { - printf("Buffer mem not allocated\n"); - return -1; + buf_resize( g_buf, g_file->blk_size ); } ret = file_read_blk( g_file, g_buf->buf ); diff --git a/cmd/cmd_resize.c b/cmd/cmd_resize.c new file mode 100644 index 0000000..532c43c --- /dev/null +++ b/cmd/cmd_resize.c @@ -0,0 +1,40 @@ +#include "buf.h" +#include "core.h" + +#include "libcmd/cmd.h" +#include "libcmd/cmd_parse.h" + +extern file_t *g_file; +extern buf_t *g_buf; +extern int g_flags; + +int c_resize( cmd_arg_t *arg ) +{ + int argc = arg->argc; + char **argv = arg->argv; + int *type = arg->type; + + int resize; + + if ( argc != 1 ) + { + printf("Needed one argument\n"); + return -1; + } + + printf("%d %s\n",type[0],argv[0]); + + if ((type[0] != CMDT_INT) && (type[0] != CMDT_HEX) ) + { + printf("Unknown type of argument\n"); + return -1; + } + + resize = atoi( argv[0] ); + if (resize < 0) + return -1; + + file_resize( g_file, resize ); + + return 0; +}
\ No newline at end of file diff --git a/cmd/cmd_seek.c b/cmd/cmd_seek.c index b563231..fd3dcf5 100644 --- a/cmd/cmd_seek.c +++ b/cmd/cmd_seek.c @@ -51,7 +51,7 @@ int c_seek( cmd_arg_t *arg ) { fret = file_seek( g_file, offset ); } - if ( fret != 0 ) + if ( fret < 0 ) { printf("Cannot seek postion to %zd\n", offset); return -1; |