#include "buf.h" #include "core.h" #include "libcmd/cmd.h" #include "libcmd/cmd_parse.h" extern file_t *g_file; extern Buf *g_buf; extern int g_flags; /* anonymous function */ uint8_t hex2u8( uint8_t *buf ) { uint8_t ret = 0x00; unsigned long int uli; char str[3]; str[0] = buf[0]; str[1] = buf[1]; str[2] = 0; uli = strtoul( str, NULL, 16 ); ret = uli; return ret; } //support masks int c_write( cmd_arg_t *arg) { int argc = arg->argc; char **argv = arg->argv; int i; uint8_t *buf = NULL; int fret; if ( argc != 1 ) { printf("One argument needed\n"); return -1; } if ( (strlen(argv[0])%2) != 0 ) { printf("Input string should be ( str mod 2 == 0) \n"); return -1; } for (i=0;i g_buf->size()*2) { printf("Input param bigger then buffer\n"); return -1; } for (i=0; iset((char *)buf,strlen(argv[0])/2); g_buf->get_ptr(&buf_ptr,&sz); fret = file_write_blk( g_file, (uint8_t *)buf_ptr, sz ); free( buf ); if ( fret < 0) { printf("Couldnt write block to file\n"); return -1; } return 0; } int h_write( cmd_arg_t *arg ) { printf("[HEXBUF] - hex data writen to buf and back to file"); return 0; }