summaryrefslogtreecommitdiff
path: root/cmd/cmd_writes.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/cmd_writes.c')
-rw-r--r--cmd/cmd_writes.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/cmd/cmd_writes.c b/cmd/cmd_writes.c
index 7d7eeed..0b555be 100644
--- a/cmd/cmd_writes.c
+++ b/cmd/cmd_writes.c
@@ -7,7 +7,7 @@
#include "libcmd/cmd_parse.h"
extern file_t *g_file;
-extern buf_t *g_buf;
+extern Buf *g_buf;
extern int g_flags;
//white spaces should be supported
@@ -23,16 +23,22 @@ int c_writes( cmd_arg_t *arg )
return -1;
}
- if (((g_buf == NULL) || (g_file == NULL)) || (g_buf->buf == NULL))
+ if (((g_buf == NULL) || (g_file == NULL)))
{
printf("Buffer or file not initialised");
return -1;
}
- if ( strlen(argv[0]) <= g_buf->size )
+ if ( strlen(argv[0]) <= g_buf->size() )
{
- memcpy( g_buf->buf, argv[0], strlen(argv[0]) );
- fret = file_write_blk( g_file, g_buf->buf );
+ //memcpy( g_buf->buf, argv[0], strlen(argv[0]) );
+ //check if can save all string in dat buffer
+ g_buf->set(argv[0],strlen(argv[0]));
+
+ char *buf_ptr;
+ int sz;
+ g_buf->get_ptr(&buf_ptr,&sz);
+ fret = file_write_blk( g_file, (uint8_t *)buf_ptr, sz );
if ( fret < 0 )
{
printf("Couldnt write block to file\n");
@@ -40,7 +46,7 @@ int c_writes( cmd_arg_t *arg )
}
} else
{
- printf("Input bigger then buffer buf %d input %zu\n", g_buf->size, strlen(argv[0]));
+ printf("Input bigger then buffer buf %d input %zu\n", g_buf->size(), strlen(argv[0]));
return -1;
}