diff options
author | FreeArtMan <dos21h@gmail.com> | 2019-09-25 19:17:09 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2019-09-25 19:17:09 +0100 |
commit | 3e187c094f12ef41ea6de2f55d128c3e037b5c12 (patch) | |
tree | f0dbbc5df260532e284ca5264297d0a8044eaeb4 /cmd/cmd_writes.c | |
parent | bbd73385a0db271b457c63e4d6bab54f581410f9 (diff) | |
download | ihe-3e187c094f12ef41ea6de2f55d128c3e037b5c12.tar.gz ihe-3e187c094f12ef41ea6de2f55d128c3e037b5c12.zip |
Untested version, recompiled with new buf library and with c+
Diffstat (limited to 'cmd/cmd_writes.c')
-rw-r--r-- | cmd/cmd_writes.c | 18 |
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; } |