Revision 94488777 som/ChunkTrading/chunk_delivery.c

View differences:

som/ChunkTrading/chunk_delivery.c
4 4
 *  This is free software;
5 5
 *  see GPL.txt
6 6
 */
7
 //header to clean
8
#include <stdio.h>
9 7
#include <stdlib.h>
10 8
#include <stdint.h>
11 9

  
......
16 14

  
17 15
static struct nodeID *localID;
18 16

  
19
static void chunk_print(FILE *f, const struct chunk *c)
20
{
21
  const uint8_t *p;
22

  
23
  fprintf(f, "Chunk %d:\n", c->id);
24
  fprintf(f, "\tTS: %llu\n", c->timestamp);
25
  fprintf(f, "\tPayload size: %d\n", c->size);
26
  fprintf(f, "\tAttributes size: %d\n", c->attributes_size);
27
  p = c->data;
28
  fprintf(f, "\tPayload:\n");
29
  fprintf(f, "\t\t%c %c %c %c ...:\n", p[0], p[1], p[2], p[3]);
30
  if (c->attributes_size > 0) {
31
    p = c->attributes;
32
    fprintf(f, "\tAttributes:\n");
33
    fprintf(f, "\t\t%c %c %c %c ...:\n", p[0], p[1], p[2], p[3]);
34
  }
35
}
36

  
37 17
/**
38 18
 * Send a Chunk to a target Peer
39 19
 *
......
57 37
        return -1;
58 38
    }
59 39
    res = encodeChunk(c, buff + 1, buff_len);
60
    fprintf(stdout, "Encoding chunk %d in %d bytes\n",res, buff_len);
61
    chunk_print(stdout, c);
62 40
    buff[0] = 12;
63 41
    send_data(localID, to, buff, buff_len + 1);
64 42
    free(buff);

Also available in: Unified diff