aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-12-18 22:32:59 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-12-18 22:32:59 +0100
commit6bbc30ef71cf23267937a73e34e185410ed73a10 (patch)
treefc562e55a9a46f5de081be70a6a78e6c2aabb482
parentea39819757f6888ed983d0c327286e6a7bac8523 (diff)
downloadlibgnunetchat-6bbc30ef71cf23267937a73e34e185410ed73a10.tar.gz
libgnunetchat-6bbc30ef71cf23267937a73e34e185410ed73a10.zip
Fixed problems loading configurations but still inconsistencies
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/gnunet_chat_context.c74
-rw-r--r--src/gnunet_chat_context.h3
-rw-r--r--src/gnunet_chat_group.c12
-rw-r--r--src/gnunet_chat_handle.c119
-rw-r--r--src/gnunet_chat_handle.h4
-rw-r--r--src/gnunet_chat_handle_intern.c134
-rw-r--r--src/gnunet_chat_util.c18
-rw-r--r--src/gnunet_chat_util.h8
8 files changed, 228 insertions, 144 deletions
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c
index a95c869..f2fadc3 100644
--- a/src/gnunet_chat_context.c
+++ b/src/gnunet_chat_context.c
@@ -136,7 +136,7 @@ context_load_config (struct GNUNET_CHAT_Context *context)
136 136
137 struct GNUNET_CONFIGURATION_Handle *config = GNUNET_CONFIGURATION_create(); 137 struct GNUNET_CONFIGURATION_Handle *config = GNUNET_CONFIGURATION_create();
138 138
139 if (GNUNET_OK != GNUNET_CONFIGURATION_load(config, directory)) 139 if (GNUNET_OK != GNUNET_CONFIGURATION_load(config, filename))
140 goto destroy_config; 140 goto destroy_config;
141 141
142 char* name = NULL; 142 char* name = NULL;
@@ -167,19 +167,24 @@ context_save_config (const struct GNUNET_CHAT_Context *context)
167 if (!directory) 167 if (!directory)
168 return; 168 return;
169 169
170 const struct GNUNET_HashCode *hash = GNUNET_MESSENGER_room_get_key( 170 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(
171 context->room 171 context->room
172 ); 172 );
173 173
174 struct GNUNET_CONFIGURATION_Handle *config = GNUNET_CONFIGURATION_create(); 174 struct GNUNET_CONFIGURATION_Handle *config = GNUNET_CONFIGURATION_create();
175 175
176 if (context->room)
177 GNUNET_CONFIGURATION_set_value_string(
178 config, "chat", "key", GNUNET_h2s_full(key)
179 );
180
176 if (context->nick) 181 if (context->nick)
177 GNUNET_CONFIGURATION_set_value_string( 182 GNUNET_CONFIGURATION_set_value_string(
178 config, "chat", "name", context->nick 183 config, "chat", "name", context->nick
179 ); 184 );
180 185
181 char* filename; 186 char* filename;
182 util_get_filename(directory, "chats", hash, &filename); 187 util_get_filename(directory, "chats", key, &filename);
183 188
184 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file(filename)) 189 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file(filename))
185 GNUNET_CONFIGURATION_write(config, filename); 190 GNUNET_CONFIGURATION_write(config, filename);
@@ -188,3 +193,66 @@ context_save_config (const struct GNUNET_CHAT_Context *context)
188 193
189 GNUNET_free(filename); 194 GNUNET_free(filename);
190} 195}
196
197enum GNUNET_GenericReturnValue
198callback_scan_for_configs (void *cls,
199 const char *filename)
200{
201 struct GNUNET_CHAT_Handle *handle = (struct GNUNET_CHAT_Handle*) cls;
202 struct GNUNET_PeerIdentity door;
203 struct GNUNET_HashCode key;
204
205 memset(&door, 0, sizeof(door));
206 memset(&key, 0, sizeof(key));
207
208 if ((!filename) ||
209 (GNUNET_OK != GNUNET_CRYPTO_get_peer_identity(handle->cfg, &door)))
210 return GNUNET_YES;
211
212 struct GNUNET_CONFIGURATION_Handle *config = GNUNET_CONFIGURATION_create();
213
214 if (GNUNET_OK != GNUNET_CONFIGURATION_load(config, filename))
215 goto destroy_config;
216
217 char* key_value = NULL;
218
219 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(
220 config, "chat", "key", &key_value)) &&
221 (GNUNET_OK == GNUNET_CRYPTO_hash_from_string(key_value, &key)))
222 GNUNET_MESSENGER_enter_room(
223 handle->messenger, &door, &key
224 );
225
226 if (key_value)
227 GNUNET_free(key_value);
228
229destroy_config:
230 GNUNET_CONFIGURATION_destroy(config);
231 return GNUNET_YES;
232}
233
234void
235context_scan_configs (struct GNUNET_CHAT_Handle *handle)
236{
237 GNUNET_assert((handle) && (handle->messenger));
238
239 const char *directory = handle->directory;
240
241 if (!directory)
242 return;
243
244 char* dirname;
245 util_get_dirname(handle->directory, "chats", &dirname);
246
247 if (GNUNET_YES != GNUNET_DISK_directory_test(dirname, GNUNET_YES))
248 goto free_dirname;
249
250 GNUNET_DISK_directory_scan(
251 dirname,
252 callback_scan_for_configs,
253 handle
254 );
255
256free_dirname:
257 GNUNET_free(dirname);
258}
diff --git a/src/gnunet_chat_context.h b/src/gnunet_chat_context.h
index 9830233..7880e1a 100644
--- a/src/gnunet_chat_context.h
+++ b/src/gnunet_chat_context.h
@@ -76,4 +76,7 @@ context_load_config (struct GNUNET_CHAT_Context *context);
76void 76void
77context_save_config (const struct GNUNET_CHAT_Context *context); 77context_save_config (const struct GNUNET_CHAT_Context *context);
78 78
79void
80context_scan_configs (struct GNUNET_CHAT_Handle *handle);
81
79#endif /* GNUNET_CHAT_CONTEXT_H_ */ 82#endif /* GNUNET_CHAT_CONTEXT_H_ */
diff --git a/src/gnunet_chat_group.c b/src/gnunet_chat_group.c
index 6091203..979af18 100644
--- a/src/gnunet_chat_group.c
+++ b/src/gnunet_chat_group.c
@@ -109,19 +109,19 @@ group_load_config (struct GNUNET_CHAT_Group *group)
109 if ((!directory) || (!(group->context))) 109 if ((!directory) || (!(group->context)))
110 return; 110 return;
111 111
112 const struct GNUNET_HashCode *hash = GNUNET_MESSENGER_room_get_key( 112 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(
113 group->context->room 113 group->context->room
114 ); 114 );
115 115
116 char* filename; 116 char* filename;
117 util_get_filename(directory, "groups", hash, &filename); 117 util_get_filename(directory, "groups", key, &filename);
118 118
119 if (GNUNET_YES != GNUNET_DISK_file_test(filename)) 119 if (GNUNET_YES != GNUNET_DISK_file_test(filename))
120 goto free_filename; 120 goto free_filename;
121 121
122 struct GNUNET_CONFIGURATION_Handle *config = GNUNET_CONFIGURATION_create(); 122 struct GNUNET_CONFIGURATION_Handle *config = GNUNET_CONFIGURATION_create();
123 123
124 if (GNUNET_OK != GNUNET_CONFIGURATION_load(config, directory)) 124 if (GNUNET_OK != GNUNET_CONFIGURATION_load(config, filename))
125 goto destroy_config; 125 goto destroy_config;
126 126
127 char* name = NULL; 127 char* name = NULL;
@@ -150,7 +150,7 @@ group_save_config (const struct GNUNET_CHAT_Group *group)
150 if ((!directory) || (!(group->context))) 150 if ((!directory) || (!(group->context)))
151 return; 151 return;
152 152
153 const struct GNUNET_HashCode *hash = GNUNET_MESSENGER_room_get_key( 153 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(
154 group->context->room 154 group->context->room
155 ); 155 );
156 156
@@ -161,14 +161,14 @@ group_save_config (const struct GNUNET_CHAT_Group *group)
161 struct GNUNET_HashCode topic_hash; 161 struct GNUNET_HashCode topic_hash;
162 GNUNET_CRYPTO_hash(group->topic, strlen(group->topic), &topic_hash); 162 GNUNET_CRYPTO_hash(group->topic, strlen(group->topic), &topic_hash);
163 163
164 if (0 == GNUNET_memcmp(hash, &topic_hash)) 164 if (0 == GNUNET_memcmp(key, &topic_hash))
165 GNUNET_CONFIGURATION_set_value_string( 165 GNUNET_CONFIGURATION_set_value_string(
166 config, "group", "topic", group->topic 166 config, "group", "topic", group->topic
167 ); 167 );
168 } 168 }
169 169
170 char* filename; 170 char* filename;
171 util_get_filename(directory, "groups", hash, &filename); 171 util_get_filename(directory, "groups", key, &filename);
172 172
173 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file(filename)) 173 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file(filename))
174 GNUNET_CONFIGURATION_write(config, filename); 174 GNUNET_CONFIGURATION_write(config, filename);
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
index 668aeec..03d2e26 100644
--- a/src/gnunet_chat_handle.c
+++ b/src/gnunet_chat_handle.c
@@ -126,18 +126,6 @@ handle_destroy (struct GNUNET_CHAT_Handle* handle)
126 if (handle->shutdown_hook) 126 if (handle->shutdown_hook)
127 GNUNET_SCHEDULER_cancel(handle->shutdown_hook); 127 GNUNET_SCHEDULER_cancel(handle->shutdown_hook);
128 128
129 if (handle->public_key)
130 GNUNET_free(handle->public_key);
131
132 if (handle->messenger)
133 GNUNET_MESSENGER_disconnect(handle->messenger);
134
135 if (handle->files)
136 GNUNET_FS_stop(handle->fs);
137
138 if (handle->arm)
139 GNUNET_ARM_disconnect(handle->arm);
140
141 GNUNET_CONTAINER_multihashmap_iterate( 129 GNUNET_CONTAINER_multihashmap_iterate(
142 handle->groups, it_destroy_handle_groups, NULL 130 handle->groups, it_destroy_handle_groups, NULL
143 ); 131 );
@@ -150,6 +138,18 @@ handle_destroy (struct GNUNET_CHAT_Handle* handle)
150 handle->contexts, it_destroy_handle_contexts, NULL 138 handle->contexts, it_destroy_handle_contexts, NULL
151 ); 139 );
152 140
141 if (handle->public_key)
142 GNUNET_free(handle->public_key);
143
144 if (handle->messenger)
145 GNUNET_MESSENGER_disconnect(handle->messenger);
146
147 if (handle->files)
148 GNUNET_FS_stop(handle->fs);
149
150 if (handle->arm)
151 GNUNET_ARM_disconnect(handle->arm);
152
153 GNUNET_CONTAINER_multihashmap_iterate( 153 GNUNET_CONTAINER_multihashmap_iterate(
154 handle->files, it_destroy_handle_files, NULL 154 handle->files, it_destroy_handle_files, NULL
155 ); 155 );
@@ -165,6 +165,101 @@ handle_destroy (struct GNUNET_CHAT_Handle* handle)
165 GNUNET_free(handle); 165 GNUNET_free(handle);
166} 166}
167 167
168int
169handle_request_context_by_room (struct GNUNET_CHAT_Handle *handle,
170 struct GNUNET_MESSENGER_Room *room)
171{
172 GNUNET_assert((handle) &&
173 (handle->contexts) &&
174 (room));
175
176 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room);
177
178 struct GNUNET_CHAT_Context *context = GNUNET_CONTAINER_multihashmap_get(
179 handle->contexts, key
180 );
181
182 struct GNUNET_CHAT_CheckHandleRoomMembers check;
183
184 if ((context) && (GNUNET_CHAT_CONTEXT_TYPE_GROUP != context->type))
185 goto check_context_type;
186 else if (context)
187 return GNUNET_OK;
188
189 context = context_create_from_room(handle, room);
190 context_load_config(context);
191
192 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
193 handle->contexts, key, context,
194 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
195 {
196 context_destroy(context);
197 return GNUNET_SYSERR;
198 }
199
200check_context_type:
201 check.ignore_key = GNUNET_MESSENGER_get_key(handle->messenger);
202 check.contact = NULL;
203
204 const int checks = GNUNET_MESSENGER_iterate_members(
205 room, check_handle_room_members, &check
206 );
207
208 if (GNUNET_SYSERR == checks)
209 {
210 GNUNET_CONTAINER_multihashmap_remove(handle->contexts, key, context);
211 context_destroy(context);
212 return GNUNET_SYSERR;
213 }
214
215 if ((check.contact) &&
216 (GNUNET_OK == intern_provide_contact_for_member(handle,
217 check.contact,
218 context)))
219 context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT;
220 else if (checks >= 2)
221 {
222 if ((context->contact) &&
223 (context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT))
224 {
225 struct GNUNET_CHAT_Contact *contact = handle_get_contact_from_messenger(
226 handle, check.contact
227 );
228
229 if ((contact) && (contact->context == context))
230 contact->context = NULL;
231
232 context->contact = NULL;
233 }
234
235 context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP;
236
237 GNUNET_MESSENGER_iterate_members(room, scan_handle_room_members, handle);
238
239 struct GNUNET_CHAT_Group *group = group_create_from_context(
240 handle, context
241 );
242
243 group_load_config(group);
244
245 if (group->topic)
246 group_publish(group);
247
248 if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(
249 handle->groups, key, group,
250 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
251 return GNUNET_OK;
252
253 group_destroy(group);
254
255 GNUNET_CONTAINER_multihashmap_remove(handle->contexts, key, context);
256 context_destroy(context);
257 return GNUNET_SYSERR;
258 }
259
260 return GNUNET_OK;
261}
262
168struct GNUNET_CHAT_Contact* 263struct GNUNET_CHAT_Contact*
169handle_get_contact_from_messenger (const struct GNUNET_CHAT_Handle *handle, 264handle_get_contact_from_messenger (const struct GNUNET_CHAT_Handle *handle,
170 const struct GNUNET_MESSENGER_Contact *contact) 265 const struct GNUNET_MESSENGER_Contact *contact)
diff --git a/src/gnunet_chat_handle.h b/src/gnunet_chat_handle.h
index c8afb0a..399de6b 100644
--- a/src/gnunet_chat_handle.h
+++ b/src/gnunet_chat_handle.h
@@ -73,6 +73,10 @@ handle_update_key (struct GNUNET_CHAT_Handle *handle);
73void 73void
74handle_destroy (struct GNUNET_CHAT_Handle* handle); 74handle_destroy (struct GNUNET_CHAT_Handle* handle);
75 75
76int
77handle_request_context_by_room (struct GNUNET_CHAT_Handle *handle,
78 struct GNUNET_MESSENGER_Room *room);
79
76struct GNUNET_CHAT_Contact* 80struct GNUNET_CHAT_Contact*
77handle_get_contact_from_messenger (const struct GNUNET_CHAT_Handle *handle, 81handle_get_contact_from_messenger (const struct GNUNET_CHAT_Handle *handle,
78 const struct GNUNET_MESSENGER_Contact *contact); 82 const struct GNUNET_MESSENGER_Contact *contact);
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
index d804545..70e4da4 100644
--- a/src/gnunet_chat_handle_intern.c
+++ b/src/gnunet_chat_handle_intern.c
@@ -217,7 +217,10 @@ intern_provide_contact_for_member(struct GNUNET_CHAT_Handle *handle,
217 if (contact) 217 if (contact)
218 { 218 {
219 if ((context) && (NULL == contact->context)) 219 if ((context) && (NULL == contact->context))
220 {
220 contact->context = context; 221 contact->context = context;
222 context->contact = member;
223 }
221 224
222 return GNUNET_OK; 225 return GNUNET_OK;
223 } 226 }
@@ -227,13 +230,19 @@ intern_provide_contact_for_member(struct GNUNET_CHAT_Handle *handle,
227 ); 230 );
228 231
229 if (context) 232 if (context)
233 {
230 contact->context = context; 234 contact->context = context;
235 context->contact = member;
236 }
231 237
232 if (GNUNET_OK == GNUNET_CONTAINER_multishortmap_put( 238 if (GNUNET_OK == GNUNET_CONTAINER_multishortmap_put(
233 handle->contacts, &shorthash, contact, 239 handle->contacts, &shorthash, contact,
234 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 240 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
235 return GNUNET_OK; 241 return GNUNET_OK;
236 242
243 if (context)
244 context->contact = NULL;
245
237 contact_destroy(contact); 246 contact_destroy(contact);
238 return GNUNET_SYSERR; 247 return GNUNET_SYSERR;
239} 248}
@@ -257,7 +266,7 @@ check_handle_room_members (void* cls,
257 GNUNET_MESSENGER_contact_get_key(member) 266 GNUNET_MESSENGER_contact_get_key(member)
258 ); 267 );
259 268
260 if (0 == GNUNET_memcmp(member_key, check->ignore_key)) 269 if ((member_key) && (0 == GNUNET_memcmp(member_key, check->ignore_key)))
261 return GNUNET_YES; 270 return GNUNET_YES;
262 271
263 if (check->contact) 272 if (check->contact)
@@ -271,94 +280,6 @@ check_handle_room_members (void* cls,
271} 280}
272 281
273int 282int
274request_handle_context_by_room (struct GNUNET_CHAT_Handle *handle,
275 struct GNUNET_MESSENGER_Room *room)
276{
277 GNUNET_assert((handle) &&
278 (handle->contexts) &&
279 (room));
280
281 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room);
282
283 struct GNUNET_CHAT_Context *context = GNUNET_CONTAINER_multihashmap_get(
284 handle->contexts, key
285 );
286
287 struct GNUNET_CHAT_CheckHandleRoomMembers check;
288
289 if ((context) && (GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN == context->type))
290 goto check_context_type;
291 else if (context)
292 return GNUNET_OK;
293
294 context = context_create_from_room(handle, room);
295 context_load_config(context);
296
297 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
298 handle->contexts, key, context,
299 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
300 {
301 context_destroy(context);
302 return GNUNET_SYSERR;
303 }
304
305check_context_type:
306 check.ignore_key = GNUNET_MESSENGER_get_key(handle->messenger);
307 check.contact = NULL;
308
309 const int checks = GNUNET_MESSENGER_iterate_members(
310 room, check_handle_room_members, &check
311 );
312
313 if ((check.contact) &&
314 (GNUNET_OK == intern_provide_contact_for_member(handle,
315 check.contact,
316 context)))
317 context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT;
318 else if (checks >= 2)
319 {
320 context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP;
321
322 struct GNUNET_CHAT_Group *group = group_create_from_context(
323 handle, context
324 );
325
326 group_load_config(group);
327
328 if (group->topic)
329 group_publish(group);
330
331 if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(
332 handle->groups, key, group,
333 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
334 return GNUNET_OK;
335
336 group_destroy(group);
337
338 GNUNET_CONTAINER_multihashmap_remove(handle->contexts, key, context);
339 context_destroy(context);
340 return GNUNET_SYSERR;
341 }
342
343 return GNUNET_OK;
344}
345
346int
347find_handle_rooms (void *cls,
348 struct GNUNET_MESSENGER_Room *room,
349 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member)
350{
351 struct GNUNET_CHAT_Handle *handle = cls;
352
353 GNUNET_assert((handle) && (room));
354
355 if (GNUNET_OK != request_handle_context_by_room(handle, room))
356 return GNUNET_NO;
357
358 return GNUNET_YES;
359}
360
361int
362scan_handle_room_members (void* cls, 283scan_handle_room_members (void* cls,
363 GNUNET_UNUSED struct GNUNET_MESSENGER_Room *room, 284 GNUNET_UNUSED struct GNUNET_MESSENGER_Room *room,
364 const struct GNUNET_MESSENGER_Contact *member) 285 const struct GNUNET_MESSENGER_Contact *member)
@@ -371,30 +292,6 @@ scan_handle_room_members (void* cls,
371 return GNUNET_NO; 292 return GNUNET_NO;
372} 293}
373 294
374int
375scan_handle_rooms (void *cls,
376 struct GNUNET_MESSENGER_Room *room,
377 GNUNET_UNUSED const struct GNUNET_MESSENGER_Contact *member)
378{
379 struct GNUNET_CHAT_Handle *handle = cls;
380
381 GNUNET_assert((handle) &&
382 (handle->groups) &&
383 (room));
384
385 const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room);
386
387 struct GNUNET_CHAT_Group *group = GNUNET_CONTAINER_multihashmap_get(
388 handle->groups, key
389 );
390
391 if (!group)
392 return GNUNET_YES;
393
394 GNUNET_MESSENGER_iterate_members(room, scan_handle_room_members, handle);
395 return GNUNET_YES;
396}
397
398void 295void
399on_handle_identity(void *cls, 296on_handle_identity(void *cls,
400 GNUNET_UNUSED struct GNUNET_MESSENGER_Handle *messenger) 297 GNUNET_UNUSED struct GNUNET_MESSENGER_Handle *messenger)
@@ -414,14 +311,7 @@ on_handle_identity(void *cls,
414 return; 311 return;
415 312
416 GNUNET_assert(handle->messenger); 313 GNUNET_assert(handle->messenger);
417 314 context_scan_configs(handle);
418 GNUNET_MESSENGER_find_rooms(
419 handle->messenger, NULL, find_handle_rooms, handle
420 );
421
422 GNUNET_MESSENGER_find_rooms(
423 handle->messenger, NULL, scan_handle_rooms, handle
424 );
425 315
426 if (!handle->msg_cb) 316 if (!handle->msg_cb)
427 return; 317 return;
@@ -449,7 +339,7 @@ on_handle_message (void *cls,
449 (msg) && 339 (msg) &&
450 (hash)); 340 (hash));
451 341
452 if ((GNUNET_OK != request_handle_context_by_room(handle, room)) || 342 if ((GNUNET_OK != handle_request_context_by_room(handle, room)) ||
453 (GNUNET_OK != intern_provide_contact_for_member(handle, sender, NULL))) 343 (GNUNET_OK != intern_provide_contact_for_member(handle, sender, NULL)))
454 return; 344 return;
455 345
diff --git a/src/gnunet_chat_util.c b/src/gnunet_chat_util.c
index 810c4f3..f8d98f2 100644
--- a/src/gnunet_chat_util.c
+++ b/src/gnunet_chat_util.c
@@ -185,6 +185,24 @@ util_decrypt_file (const char *filename,
185} 185}
186 186
187int 187int
188util_get_dirname (const char *directory,
189 const char *subdir,
190 char **filename)
191{
192 GNUNET_assert((filename) &&
193 (directory) &&
194 (subdir));
195
196 return GNUNET_asprintf (
197 filename,
198 "%s%c%s",
199 directory,
200 DIR_SEPARATOR,
201 subdir
202 );
203}
204
205int
188util_get_filename (const char *directory, 206util_get_filename (const char *directory,
189 const char *subdir, 207 const char *subdir,
190 const struct GNUNET_HashCode *hash, 208 const struct GNUNET_HashCode *hash,
diff --git a/src/gnunet_chat_util.h b/src/gnunet_chat_util.h
index 1a958d8..7497b67 100644
--- a/src/gnunet_chat_util.h
+++ b/src/gnunet_chat_util.h
@@ -51,7 +51,13 @@ util_decrypt_file (const char *filename,
51 const struct GNUNET_CRYPTO_SymmetricSessionKey *key); 51 const struct GNUNET_CRYPTO_SymmetricSessionKey *key);
52 52
53int 53int
54util_get_filename (const char *directory, const char *subdir, 54util_get_dirname (const char *directory,
55 const char *subdir,
56 char **filename);
57
58int
59util_get_filename (const char *directory,
60 const char *subdir,
55 const struct GNUNET_HashCode *hash, 61 const struct GNUNET_HashCode *hash,
56 char **filename); 62 char **filename);
57 63