diff options
| author | Loic Guegan <loic.guegan@mailbox.org> | 2024-02-01 15:25:11 +0100 |
|---|---|---|
| committer | Loic Guegan <loic.guegan@mailbox.org> | 2024-02-01 15:25:11 +0100 |
| commit | 5bb2a260f5f2ccde8379796b5666ac42e4a9422a (patch) | |
| tree | 4a675ed207317730db23e66bd05f4447ec14f820 /src | |
| parent | bcd7e7f5ff6e532c512c3c9ab43a65030417e63a (diff) | |
Minor changes
Diffstat (limited to 'src')
| -rw-r--r-- | src/subscriber.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/subscriber.c b/src/subscriber.c index 44a2a41..1471a58 100644 --- a/src/subscriber.c +++ b/src/subscriber.c @@ -1,6 +1,7 @@ #include <zmq.h> #include <assert.h> #include <signal.h> +#include <stdlib.h> // Access to system() #include "utils.h" /// @brief Set to non-zero to stop the processes @@ -60,6 +61,7 @@ int main (int argc, char *argv []) char client[STATIC_LEN]; long int interval; FILE *fptr; + char path[STATIC_LEN]=""; // Output file path int line=1; while(token != NULL){ if(line==2) @@ -72,7 +74,6 @@ int main (int argc, char *argv []) if(line==4){ double size_mib=size/(1024*1024); printf("Data received: key=%s client=%s interval=%ld msgsize=%.2lfMiB\n",key, client, interval,size_mib); - char path[STATIC_LEN]=""; // Create dir if not exists: sprintf(path,"%s/%s/%s/",cdatadir,key,client); if(!DIR_EXISTS(path)){ @@ -81,7 +82,7 @@ int main (int argc, char *argv []) // Now open output file: sprintf(path,"%s/%s/%s/%ld",cdatadir,key,client,interval); char exists=FILE_EXISTS(path); - fptr=fopen(path,"a"); + fptr=fopen(path,"a"); // AT SOME POINT WE MUST CHECK IF WORKED!! OTHERWISE PROBLEM if(!exists){ fwrite(CSV_HEADER"\n", strlen(CSV_HEADER)+1, 1, fptr); } @@ -97,10 +98,15 @@ int main (int argc, char *argv []) line++; } fclose(fptr); +#ifdef RCV_CMD + char cmd[STATIC_LEN*2]=""; + sprintf(cmd,"%s %s",STRINGIFY(RCV_CMD),path); // Run the command with new file as argument + system(cmd); // Allow to run a supplied user command on receive +#endif } zmq_close (subscriber); zmq_ctx_destroy (context); return 0; -}
\ No newline at end of file +} |
