#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; //support masks int c_write( cmd_arg_t *arg) { /* 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; } 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; ibuf, buf, strlen(argv[0])/2 ); fret = file_write_blk( g_file, g_buf->buf ); free( buf ); if ( fret < 0) { printf("Couldnt write block to file\n"); return -1; } return 0; }