nTox.c:
- don't claim "Added friend" per default, check for returned ID first
- on '/q' SAVE... else everything but the keys is lost on each restart
- for that, split load_key() into load_data() and save_data()
- announce own nickname on startup
nTox.c:
- correct a message who claims we're going to exit when we actually aren't
- don't treat a failed close on reading the data file as failure of the reading
Merge remote-tracking branch 'upstream/master' into nTox
Merge remote-tracking branch 'upstream/master' into nTox
Made (load_/save_)data() functions static.
Rename load_old_key_or_save_new_one() to load_data_or_init().
State loading/saving: Instead of a blob, segment into sections marked with tags.

Primary rationale: The part that DHT saves changes if IP is expanded to IPv6. To let people keep their friends/name, change the datafile format now, while everybody is still on the same page.

Loading/Saving rewritten to allow a part of the file to be incomprehensible to the loading routine.
Added a magic cookie at the beginning to mark the file as tox's.
Changes in some part of the datafile can be skipped and the remaining parts still be consumed.
Allows a wide margin of forward compatibility (like the IP to IPv6 transition, but also e.g. a change in the key format).
As long as the file is not completely garbled, the routine will read as much as possible. Only the KEY section is considered mandatory: a malformed key section leads to a negative result.

util.*:
- holds the driving function which jumps from section to section and calls back with section length and tag (type)

Messenger.c,DHT.*:
- new loading functions call the util-function with a callback, which subsequently consumes the sections
- old routines are kept to fall back onto if the magic cookie at the beginning isn't present
- saving is still done in one local routine
Merge remote-tracking branch 'upstream/master' into MessengerLoadSave
Change sublength to 32 bits. Someone might have more than (sizeof(Friends) / 65536) friends...
Merge remote-tracking branch 'upstream/master' into nTox
Save datafile when adding a friend/accepting a friend request.
(Note to self: make clean is your friend. Those extra seconds are well spent.)
Merge remote-tracking branch 'upstream/master' into nTox
Fix leaks and null dereferences in net_crypto
Merge pull request #581 from stal888/csafixes

Fix leaks and null dereferences in net_crypto
Fix in ip_equal, plus testing code which led to that fix...

network.c:
- use the correct macro for IPv4-in-IPv6 test

network_test.c:
- bunch of tests for addr_resolve() and ip_equal()
Merge pull request #580 from FullName/networking_test

Fix in ip_equal, plus testing code which led to that fix...
Merge pull request #577 from FullName/nTox

nTox: Save data on friend operations/exit
Merge remote-tracking branch 'upstream/master' into MessengerLoadSave

Conflicts:
	toxcore/Messenger.c
	toxcore/util.c
	toxcore/util.h
additional length >= size checks

Messenger.c:
- additional size checks
- removed one pointless copying of data, instead using it directly

util.c:
- lost a newline vs. master
Fix warnings of -Wall -Wextra