Prototype which initializes Tox and prints address
This commit is contained in:
parent
6798f06310
commit
c3298d2f66
1 changed files with 29 additions and 0 deletions
29
main.c
29
main.c
|
@ -1,4 +1,33 @@
|
||||||
|
#include <tox/tox.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
struct Tox_Options tox_options;
|
||||||
|
memset(&tox_options, 0, sizeof(struct Tox_Options));
|
||||||
|
tox_options_default(&tox_options);
|
||||||
|
|
||||||
|
TOX_ERR_NEW err;
|
||||||
|
|
||||||
|
Tox *tox = tox_new(&tox_options, &err);
|
||||||
|
|
||||||
|
if (err != TOX_ERR_NEW_OK)
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
char address[TOX_ADDRESS_SIZE];
|
||||||
|
tox_self_get_address(tox, (uint8_t*)address);
|
||||||
|
|
||||||
|
printf("ID: ");
|
||||||
|
|
||||||
|
for (int i = 0; i < TOX_ADDRESS_SIZE; ++i) {
|
||||||
|
char d[3];
|
||||||
|
snprintf(d, sizeof(d), "%02X", address[i] & 0xFF);
|
||||||
|
printf("%s", d);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue