skipstone/examples/pack.c

36 lines
882 B
C
Raw Normal View History

2020-09-21 21:34:39 -05:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <skipstone/message.h>
int main(int argc, char **argv) {
uint8_t buf[SKIPSTONE_MESSAGE_MAX_PAYLOAD];
ssize_t len;
if ((len = skipstone_message_pack(buf,
SKIPSTONE_MESSAGE_MAX_PAYLOAD,
"CCCCzz",
2020-09-21 21:34:39 -05:00
1,
2,
3,
4,
"KMFDM",
"Nihil")) < 0) {
2020-09-21 21:34:39 -05:00
fprintf(stderr, "%s: %s: %s\n", argv[0],
"skipstone_message_pack()", strerror(errno));
goto error_message_pack;
}
write(1, buf, len);
return 0;
error_message_pack:
return 1;
}