@@ -42,14 +42,20 @@ char *read_cmd() {
4242char * * split_cmd (char * cmd ) {
4343 char * * tokens = NULL ;
4444 char * token ;
45+ int w = 0 ;
4546 ssize_t nb_tok = 1 ;
4647 token = strtok (cmd , " " );
48+ if (token && 0 == strcmp (token , "w" ))
49+ w ++ ;
4750 /* walk through other tokens */
4851 while (token != NULL ) {
4952 tokens = realloc (tokens , nb_tok * sizeof (char * ));
5053 tokens [nb_tok - 1 ] = token ;
5154 nb_tok ++ ;
52- token = strtok (NULL , " " );
55+ if (nb_tok == 4 && w == 1 )
56+ token = strtok (NULL , "\0" );
57+ else
58+ token = strtok (NULL , " " );
5359 }
5460 tokens = realloc (tokens , nb_tok * sizeof (char * ));
5561 tokens [nb_tok - 1 ] = NULL ;
@@ -83,6 +89,7 @@ void execute(char **args, unsigned short leader) {
8389 " w `address` `datasize` `data` | write at the address the data of size datasize |\n"
8490 " r `address` `datasize` | read datasize bytes at address |\n"
8591 " d `address` | dump in as text all data of the block stored in address |\n"
92+ " d net | dump all allocation |\n"
8693 " d `address` `file` | dump address data in file |\n"
8794 " snap | give user a snap of the network (print) |\n"
8895 " snap `file` | same as snap but stored in file |\n"
@@ -180,7 +187,7 @@ void execute(char **args, unsigned short leader) {
180187 } else if (0 == strcmp (args [0 ], "d" )) {
181188 // ERRORS
182189 if (l <= 1 ) {
183- error_msg ("d requires minimum 1 argument and maximum 2 : 'address' and 'file'" );
190+ error_msg ("d requires minimum 1 argument and maximum 2 : 'address' | 'net and 'file'" );
184191 return ;
185192 } else if (l >= 4 ) {
186193 error_msg ("d do not support more than 2 arguments, check command h" );
@@ -189,12 +196,17 @@ void execute(char **args, unsigned short leader) {
189196
190197 // Execution
191198 size_t address = 0 ;
192- if (1 == sscanf (args [1 ], "%zu" , & address )) {
199+ if (0 == strcmp (args [1 ], "net" )) {
200+ printf ("Execute DUMP_ALL" );
201+ send_command (OP_DUMP_ALL , NULL , leader );
202+ } else if (1 == sscanf (args [1 ], "%zu" , & address )) {
193203
194204 // d address
195205 if (l == 2 ) {
196206 printf ("Execute Dump of %zu\n" , address );
197-
207+ struct data_address * d_a = generate_data_address (address );
208+ send_command (OP_DUMP , d_a , leader );
209+ free (d_a );
198210 }
199211
200212 // d address file
0 commit comments