aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/write-service.example.c
blob: 45283e16dcc62d79e68b7054341c3b9988864ed7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <libsparklepaw/service.h>

void main() {
  struct sprkl_tagval_pair pair = {
    .tag = { .upper = 0xFFFFFFFFFFFFFFFF, .lower = 0 },
    .valuesz = 8,
    .value = "hello!!!"
  };
  struct sprkl_record record = {
    .paircnt = 1,
    .pairs = &pair
  };
  uint8_t signature[4] = { 0x12, 0x34, 0x56, 0x78 };
  struct sprkl_service service = {
    .sigsz = sizeof(signature),
    .signature = signature,
    .index = 0x6969,
    .flags = 0,
    .reccnt = 1,
    .records = &record
  };

  int n = sprkl_service_write(&service, stdout);
  fprintf(stderr, "\nWrote %d bytes\n", n);
}