summaryrefslogtreecommitdiff
path: root/toxcore/util.c
AgeCommit message (Collapse)Author
2017-01-06Revert "Revert "Portability fixes""David Zero
This reverts commit 59e2a844f04a8725e8079f854158aa86ef5988b2, and defines _DARWIN_C_SOURCE in toxcore/network.c
2017-01-05Revert "Portability fixes"endoffile78
This reverts commit f3469070fe899e8e4fd88665386a55bad9f77cd8.
2017-01-04Portability fixesDavid Zero
- CFLAG gnu99 was changed to c99. - CXXFLAG c++98 was changed to c++11. - CFLAG -pedantic-errors was added so that non-ISO C now throws errors. - _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3 and c99 definitions in modules that required them. - Fixed tests (and bootstrap daemon logging) that were failing due to the altered build flags. - Avoid string suffix misinterpretation; explicit narrowing conversion. - Misc. additions to .gitignore to make sure build artifacts don't wind up in version control.
2016-12-22Improve documentation of crypto_core.iphydf
2016-12-22Wrap all sodium/nacl functions in crypto_core.c.iphydf
2016-09-24Move ring buffer out of toxcore/util into toxav.iphydf
Toxcore itself doesn't use this data structure. Only toxav does, so now toxav owns the code for it.
2016-09-24Make toxcore code C++ compatible.iphydf
It is still C code, so still compatible with C compilers as well. This change lets us see more clearly where implicit conversions occur by making them explicit.
2016-09-13Add some astyle options to make it do more.iphydf
It now enforces a bit more formatting. In particular, padding inside parentheses is removed. I would like it to remove padding after unary operators, but there seems to be no option for that.
2016-09-13Group #include directives in 3-4 groups.iphydf
1. Current module (if C file). 2. Headers from current library. 3. Headers from other library (e.g. toxcore includes in toxav). 4. System headers.
2016-09-06Improve static and const correctness.iphydf
- Any non-externally-visible declarations should be `static`. - Casting away the `const` qualifier from pointers-to-const is dangerous. All but one instance of this are now correct. The one instance where we can't keep `const` is one where toxav code actually writes to a chunk of memory marked as `const`. This code also assumes 4 byte alignment of data packets. I don't know whether that is a valid assumption, but it's likely unportable, and *not* obviously correct. - Replaced empty parameter lists with `(void)` to avoid passing parameters to it. Empty parameter lists are old style declarations for unknown number and type of arguments. - Commented out (as `#if DHT_HARDENING` block) the hardening code that was never executed. - Minor style fix: don't use `default` in enum-switches unless the number of enumerators in the default case is very large. In this case, it was 2, so we want to list them both explicitly to be warned about missing one if we add one in the future. - Removed the only two function declarations from nTox.h and put them into nTox.c. They are not used outside and nTox is not a library.
2016-09-06Improve C standard compliance.iphydf
- Don't cast between object and function pointers. - Use standard compliant `__VA_ARGS__` in macros. - Add explicit `__extension__` on unnamed union in struct (it's a GNU extension). - Remove ; after function definitions. - Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`. Folding integral constants like that as compile time constants is a GNU extension. Arrays allocated with `foo` as dimension are VLAs on strictly compliant C99 compilers. - Replace empty initialiser list `{}` with zero-initialiser-list `{0}`. The former is a GNU extension meaning the latter. - Cast `T*` (where `T != void`) to `void *` in format arguments. While any object pointer can be implicitly converted to and from `void *`, this conversion does not happen in variadic function calls. - Replace arithmetic on `void *` with arithmetic on `char *`. The former is non-compliant. - Replace non-`int`-derived types (like `uint16_t`, which is `short`-derived) in bit fields with `int`-derived types. Using any type other than `int` or `unsigned int` (or any of their aliases) in bit fields is a GNU extension.
2016-08-31Remove redundant `return` statements.iphydf
2016-08-31Add braces to all if statements.iphydf
2016-08-18Make tox_callback_friend_name stateless.iphydf
See #27 and #40 for details.
2016-08-17Add missing DHT_bootstrap to CMakeLists.txt.iphydf
- This PR also adds a DEBUG cmake option that enables -DTOX_DEBUG. - We also remove `-Wall`, because there are too many warnings, and nobody really looks at them at the moment. We'll see about fixing them soon. We'll also want to enable `-Werror` at some point. - Finally, this PR enables `-O3` to make sure toxcore still works correctly under heavy compiler optimisations.
2016-01-27 fix: compare sensitive data with sodium_memcmpRoman Proskuryakov
fix: make increment_nonce & increment_nonce_number independent of user-controlled input fix: make crypto_core more stable agains null ptr dereference
2015-11-03Astyle.irungentoo
2015-10-10New Adaptive BR algorithm, cleanups and fixesEniz Vukovic
2015-08-09Updated with upstreammannol
2015-08-07Removed a useless define.irungentoo
2015-07-17Allow savedata to be slightly smaller than the allocated buffer.irungentoo
2015-04-13Started custom RTCPmannol
2014-11-29Fixed bug where video didn't work anymore.irungentoo
Some other cleanups.
2014-11-29Merge branch 'mutex-1' of https://github.com/mannol/toxcoreirungentoo
2014-11-29More av cleanupmannol
2014-10-24Portability saving fixes for big endian systems.irungentoo_trip
Saves should now be portable from big endian to little endian systems though I need someone to actually test it to be sure I didn't mess up.
2014-10-22Load file portability code for big endian.irungentoo_trip
Warning: only loads, doesn't save.
2014-09-30Rework toxav/rtp.c to use ntohl/htonl and ntohs/htonssin
Now we can also remove the helper routines from toxcore/util.[ch].
2014-06-10Const correctness in various interdependent filesMarc Schütz
2014-06-10Const correctness for toxcore/util.cMarc Schütz
2014-06-01Fixed TOX_MAX_MESSAGE_LENGTH define.irungentoo
Removed some useless code from toxcore. Astyled core code with new version of astyle.
2014-05-31Fixed byte order and removed log functions from misc_toolsmannol
2014-05-20Merge upstream and other stuffmannol
2014-04-27Yeah many callsmannol
2014-01-19Added no_replay and added some things to the docs.irungentoo
2013-12-15Code cleanups.irungentoo
No functionality changed.
2013-11-10Merge branch 'master' into hardenirungentoo
Conflicts: toxcore/DHT.c
2013-11-06Behind #define LOGGING: Correct usage of now() to replacement unix_time().Coren[m]
2013-10-28Merge branch 'master' into hardenirungentoo
Also removed some old, useless loading code.
2013-10-24Merge remote-tracking branch 'upstream/master' into ↵Coren[m]
cleanup_unix_time_id_eq_cpy_is_timeout Conflicts: toxcore/net_crypto.c
2013-10-24Astyled some files.irungentoo
2013-10-24Move unix_time(), id_cpy()/id_eq(), is_timeout() to util.*Coren[m]
unix_time(): - returns local value for current epoch - value is updated explicitly with unix_time_update() called at new_DHT()/doMessenger()/do_DHT() is_timeout(): - uses the local value for current epoch id_cpy()/id_eq() => id_copy()/id_equal(): - centralized duplicate definitions - replaced (most) memcpy()/memcmp() of (*, *, CLIENT_ID_SIZE) with id_copy()/id_equal()
2013-10-23Code cleanups.irungentoo
2013-10-20Main: Eliminate TOX_ENABLE_IPV6 (then always on), CLIENT_ONETOONE_IP (then ↵Coren[m]
always off). Additionally (besides cleanups): network.h/tox.h: - WIN32: fix a strange sa_family_t definition - WIN32: define EWOULDBLOCK to WSAEWOULDBLOCK - WIN32: kill macro for an existing function (IN6_ADDR_EQUAL) network.c: - use EWOULDBLOCK instead of EAGAIN (same value, but EWOULDBLOCK is more "popular") - new_networking(): only try to enable IPv4-in-IPv6 if it's not already enabled per default - inet_ntop()/inet_pton(): WIN32: remove partial initializers in favor of a simple memset() - ip_equal(): WIN32: use an existing function - logging: networking_wait_execute(): only dump result if not timeout - logging: loglogdata(): kill an unused variable LAN_discovery.c: - send_broadcasts(): re-enabled, can only support IPv4 by principle, split into fetch_broadcast_info() (to fetch the addresses once) and send_broadcasts() (actual sending) DHT.c: - DHT_load_state_callback(): enclosed a fprintf(stderr, ...) into #ifdef DEBUG Lossless_UDP.c: - change_handshake(): harden against strange sa_family_t definitions Messenger.c: - logging: fix ID to string conversion util.c: - logging: eliminate a signed-warning
2013-10-13tox A/V: integration of A/V code into toxmannol
Also-by: Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
2013-10-02Add tox_wait() for socket, allow tox.h include in tox.cCoren[m]
tox.*, Messenger.*, network.*; - new function tox_wait() => waitMessenger() => networking_wait(): - waits for a given amount of time for any sort of socket activity - mustn't change anything inside, mustn't poll or do other stuff - the point is to be able to call this asynchronously from a second thread - the outside shall follow up with an immediate tox_do() when there's socket activity tox.*: - allow inclusion of tox.h into tox.c, ensuring that the outside interface and the internal always match util.c: - squished a few warnings about questionable format strings
2013-09-27Astyled the code.irungentoo
2013-09-18Allow loginit() to be delayed, store loglog() data in intermediate buffer ↵Coren[m]
and flush it out when loginit() is called util.c: - handle loglog() before loginit() by storing the lines into an expanding buffer - when loginit() is called, write out and kill the buffer network.c: - push loginit() to the point where we know the actually used port
2013-09-17Tests of state loading/saving lead to two fixes for DHT.c and util.cCoren[m]
util.c: - fix in empty section at the end of the state, showed as bug when having an empty name DHT.c: - fix in saving less data than originally announced, showed as bug when not having reached any clients ever (no clients or only with timestamp of zero)
2013-09-16Toxcore should never print anything when built normally.irungentoo