summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/command.c b/command.c
index b222997..3dc07e6 100644
--- a/command.c
+++ b/command.c
@@ -11,6 +11,7 @@
#include "nfcommander.h"
#include "command.h"
#include "config.h"
+#include "reader.h"
#define COMMAND_ALIVE 1
#define COMMAND_STOPPED 2
@@ -43,7 +44,15 @@ static int command_scan_input(command_t* cmd, size_t bytes){
cmd->input[cmd->input_head + n] = 0;
//handle line
if(!strncmp((char*) cmd->input, "UPDATE ", strlen("UPDATE "))){
- printf("Update: %s\n", cmd->input + 7);
+ if(cmd->tag && strlen((char*) (cmd->input + 7)) < cmd->tag->dynamic_max){
+ free(cmd->tag->dynamic_data);
+ cmd->tag->dynamic_data = (uint8_t*) strdup((char*) (cmd->input + 7));
+ cmd->tag->dynamic_length = strlen((char*) cmd->tag->dynamic_data);
+ reader_write(cmd->tag, TAG_WRITE_DYNAMIC);
+ }
+ else{
+ printf("Failed to update tag dynamic data\n");
+ }
}
//find beginning of next line
@@ -63,6 +72,9 @@ static int command_scan_input(command_t* cmd, size_t bytes){
//try to find another sentence
return command_scan_input(cmd, bytes - n);
}
+ else if(!isprint(cmd->input[cmd->input_head + n])){
+ cmd->input[cmd->input_head + n] = ' ';
+ }
}
if(cmd->input_head + bytes > INPUT_BUFFER_MAX - 10){
@@ -146,6 +158,7 @@ static int command_spawn(command_t* cmd, char* command_name, char* command_stati
char* handler = config_get("command", "handler");
size_t bytes;
char tag_uid[12] = "";
+ char dynsize[10] = "";
printf("Starting command %s, static %s\n", command_name, command_static);
if(pipe(cmd->iopipe)){
@@ -186,8 +199,9 @@ static int command_spawn(command_t* cmd, char* command_name, char* command_stati
cmd->tag->uid[4], cmd->tag->uid[5],
cmd->tag->uid[6]);
}
+ snprintf(dynsize, sizeof(dynsize), "%ld", cmd->tag->dynamic_max);
setenv("TAG_UID", tag_uid, 1);
- //DYNAMIC_SIZE
+ setenv("MAX_DATA_LENGTH", dynsize, 1);
//run actual command
if(handler){