summaryrefslogtreecommitdiff
path: root/other/fun/save-generator.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-19 22:58:04 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-19 23:15:01 +0000
commit7aa57afebad031993825b0bd1ef0760f524e1442 (patch)
tree3e7db61a8c138215c339277d1e3b2a9227570a22 /other/fun/save-generator.c
parent0e7cc197f4da06b62de1ca200e8c2ae02c4a8818 (diff)
Avoid redefining macros from different files.
Diffstat (limited to 'other/fun/save-generator.c')
-rw-r--r--other/fun/save-generator.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/other/fun/save-generator.c b/other/fun/save-generator.c
index e73a2f01..c0b5a8a5 100644
--- a/other/fun/save-generator.c
+++ b/other/fun/save-generator.c
@@ -7,16 +7,16 @@
7#include "../../toxcore/ccompat.h" 7#include "../../toxcore/ccompat.h"
8#include "../../toxcore/tox.h" 8#include "../../toxcore/tox.h"
9 9
10#define SAVE_FILE "save.tox" 10#define GENERATED_SAVE_FILE "save.tox"
11#define STATUS_MESSAGE "Hello World" 11#define GENERATED_STATUS_MESSAGE "Hello World"
12#define REQUEST_MESSAGE "Add me." 12#define GENERATED_REQUEST_MESSAGE "Add me."
13#define BOOTSTRAP_IP "185.14.30.213" 13#define BOOTSTRAP_IP "185.14.30.213"
14#define BOOTSTRAP_ADDRESS "2555763C8C460495B14157D234DD56B86300A2395554BCAE4621AC345B8C1B1B" 14#define BOOTSTRAP_ADDRESS "2555763C8C460495B14157D234DD56B86300A2395554BCAE4621AC345B8C1B1B"
15#define UDP_PORT 443 15#define BOOTSTRAP_UDP_PORT 443
16 16
17static bool write_save(const uint8_t *data, size_t length) 17static bool write_save(const uint8_t *data, size_t length)
18{ 18{
19 FILE *fp = fopen(SAVE_FILE, "w"); 19 FILE *fp = fopen(GENERATED_SAVE_FILE, "w");
20 20
21 if (!fp) { 21 if (!fp) {
22 return false; 22 return false;
@@ -41,7 +41,7 @@ static bool bootstrap_tox(Tox *tox)
41 } 41 }
42 42
43 Tox_Err_Bootstrap err; 43 Tox_Err_Bootstrap err;
44 tox_bootstrap(tox, BOOTSTRAP_IP, UDP_PORT, key, &err); 44 tox_bootstrap(tox, BOOTSTRAP_IP, BOOTSTRAP_UDP_PORT, key, &err);
45 free(key); 45 free(key);
46 46
47 if (err != TOX_ERR_BOOTSTRAP_OK) { 47 if (err != TOX_ERR_BOOTSTRAP_OK) {
@@ -80,7 +80,7 @@ static void print_information(Tox *tox)
80 printf("Tox ID: %.*s.\n", (int)TOX_ADDRESS_SIZE * 2, tox_id_str); 80 printf("Tox ID: %.*s.\n", (int)TOX_ADDRESS_SIZE * 2, tox_id_str);
81 printf("Nospam: %s.\n", nospam_str); 81 printf("Nospam: %s.\n", nospam_str);
82 printf("Name: %s.\n", name); 82 printf("Name: %s.\n", name);
83 printf("Status message: %s.\n", STATUS_MESSAGE); 83 printf("Status message: %s.\n", GENERATED_STATUS_MESSAGE);
84 printf("Number of friends: %zu.\n", tox_self_get_friend_list_size(tox)); 84 printf("Number of friends: %zu.\n", tox_self_get_friend_list_size(tox));
85 printf("----------------------------------\n"); 85 printf("----------------------------------\n");
86} 86}
@@ -121,7 +121,7 @@ int main(int argc, char *argv[])
121 printf("Failed to set name. Error number %d\n", err); 121 printf("Failed to set name. Error number %d\n", err);
122 } 122 }
123 123
124 tox_self_set_status_message(tox, (const uint8_t *)STATUS_MESSAGE, strlen(STATUS_MESSAGE), &err); 124 tox_self_set_status_message(tox, (const uint8_t *)GENERATED_STATUS_MESSAGE, strlen(GENERATED_STATUS_MESSAGE), &err);
125 125
126 if (err != TOX_ERR_SET_INFO_OK) { 126 if (err != TOX_ERR_SET_INFO_OK) {
127 printf("Failed to set status. Error number: %d\n", err); 127 printf("Failed to set status. Error number: %d\n", err);
@@ -130,7 +130,8 @@ int main(int argc, char *argv[])
130 for (unsigned int i = 2; i < argc; i++) { //start at 2 because that is where the tox ids are 130 for (unsigned int i = 2; i < argc; i++) { //start at 2 because that is where the tox ids are
131 uint8_t *address = hex_string_to_bin(argv[i]); 131 uint8_t *address = hex_string_to_bin(argv[i]);
132 Tox_Err_Friend_Add friend_err; 132 Tox_Err_Friend_Add friend_err;
133 tox_friend_add(tox, address, (const uint8_t *)REQUEST_MESSAGE, strlen(REQUEST_MESSAGE), &friend_err); 133 tox_friend_add(tox, address, (const uint8_t *)GENERATED_REQUEST_MESSAGE, strlen(GENERATED_REQUEST_MESSAGE),
134 &friend_err);
134 free(address); 135 free(address);
135 136
136 if (friend_err != TOX_ERR_FRIEND_ADD_OK) { 137 if (friend_err != TOX_ERR_FRIEND_ADD_OK) {
@@ -158,7 +159,7 @@ int main(int argc, char *argv[])
158 return -1; 159 return -1;
159 } 160 }
160 161
161 printf("Wrote tox save to %s\n", SAVE_FILE); 162 printf("Wrote tox save to %s\n", GENERATED_SAVE_FILE);
162 163
163 print_information(tox); 164 print_information(tox);
164 165