From fa3b51266bdc13a6b5fafdc2518f89b03e5f084f Mon Sep 17 00:00:00 2001 From: iphydf Date: Tue, 30 Aug 2016 17:50:59 +0100 Subject: [PATCH] Add missing #includes to headers and rename tox_old to tox_group. Also, no longer #include the group code into tox.c. Instead, compile it separately in tox_group.c. This is a bit less surprising to someone looking around the code. Having some implementations in a .h file is certainly a bit surprising to a disciplined C programmer, especially when there is no technical reason to do it. --- CMakeLists.txt | 5 ++-- other/apidsl/tox.in.h | 2 +- toxcore/Makefile.inc | 6 ++--- toxcore/assoc.h | 8 +++++- toxcore/ping.h | 5 ++++ toxcore/tox.c | 2 -- toxcore/tox.h | 2 +- toxcore/{tox_old_code.h => tox_group.c} | 35 +++++++++++++++++++++++++ toxcore/{tox_old.h => tox_group.h} | 6 +++++ 9 files changed, 61 insertions(+), 10 deletions(-) rename toxcore/{tox_old_code.h => tox_group.c} (89%) rename toxcore/{tox_old.h => tox_group.h} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c716f825..0db88621 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,7 +173,8 @@ target_link_libraries(toxgroup toxmessenger) # LAYER 8: Public API # ------------------- add_library(toxcore ${LIBTYPE} - toxcore/tox.c) + toxcore/tox.c + toxcore/tox_group.c) target_link_libraries(toxcore toxgroup) @@ -365,7 +366,7 @@ install(TARGETS install(FILES toxav/toxav.h toxcore/tox.h - toxcore/tox_old.h + toxcore/tox_group.h toxdns/toxdns.h toxencryptsave/toxencryptsave.h DESTINATION "include/tox") diff --git a/other/apidsl/tox.in.h b/other/apidsl/tox.in.h index 806fb76c..a280348a 100644 --- a/other/apidsl/tox.in.h +++ b/other/apidsl/tox.in.h @@ -2198,7 +2198,7 @@ inline namespace self { } // class tox %{ -#include "tox_old.h" +#include "tox_group.h" #ifdef __cplusplus } diff --git a/toxcore/Makefile.inc b/toxcore/Makefile.inc index d6b67eb2..f73ac3e9 100644 --- a/toxcore/Makefile.inc +++ b/toxcore/Makefile.inc @@ -2,7 +2,7 @@ lib_LTLIBRARIES += libtoxcore.la libtoxcore_la_include_HEADERS = \ ../toxcore/tox.h \ - ../toxcore/tox_old.h + ../toxcore/tox_group.h libtoxcore_la_includedir = $(includedir)/tox @@ -28,6 +28,7 @@ libtoxcore_la_SOURCES = ../toxcore/DHT.h \ ../toxcore/ping.c \ ../toxcore/tox.h \ ../toxcore/tox.c \ + ../toxcore/tox_group.c \ ../toxcore/util.h \ ../toxcore/util.c \ ../toxcore/group.h \ @@ -50,8 +51,7 @@ libtoxcore_la_SOURCES = ../toxcore/DHT.h \ ../toxcore/TCP_connection.c \ ../toxcore/list.c \ ../toxcore/list.h \ - ../toxcore/misc_tools.h \ - ../toxcore/tox_old_code.h + ../toxcore/misc_tools.h libtoxcore_la_CFLAGS = -I$(top_srcdir) \ -I$(top_srcdir)/toxcore \ diff --git a/toxcore/assoc.h b/toxcore/assoc.h index f3def699..62eecee1 100644 --- a/toxcore/assoc.h +++ b/toxcore/assoc.h @@ -1,7 +1,13 @@ - #ifndef __ASSOC_H__ #define __ASSOC_H__ +#include "DHT.h" +#include "logger.h" +#include "network.h" + +#include +#include + /* used by rendezvous */ #define ASSOC_AVAILABLE diff --git a/toxcore/ping.h b/toxcore/ping.h index 904ad844..ed0caafa 100644 --- a/toxcore/ping.h +++ b/toxcore/ping.h @@ -24,6 +24,11 @@ #ifndef __PING_H__ #define __PING_H__ +#include "DHT.h" +#include "network.h" + +#include + typedef struct PING PING; /* Add nodes to the to_ping list. diff --git a/toxcore/tox.c b/toxcore/tox.c index ab5ed439..a98e8aa7 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -1341,5 +1341,3 @@ uint16_t tox_self_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error) return 0; } } - -#include "tox_old_code.h" diff --git a/toxcore/tox.h b/toxcore/tox.h index 2424ab8d..5d528e16 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -2462,7 +2462,7 @@ uint16_t tox_self_get_udp_port(const Tox *tox, TOX_ERR_GET_PORT *error); */ uint16_t tox_self_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error); -#include "tox_old.h" +#include "tox_group.h" #ifdef __cplusplus } diff --git a/toxcore/tox_old_code.h b/toxcore/tox_group.c similarity index 89% rename from toxcore/tox_old_code.h rename to toxcore/tox_group.c index 2a422575..2228ed88 100644 --- a/toxcore/tox_old_code.h +++ b/toxcore/tox_group.c @@ -1,3 +1,38 @@ +/* tox.c + * + * The Tox public API. + * + * Copyright (C) 2013 Tox project All Rights Reserved. + * + * This file is part of Tox. + * + * Tox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tox. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "Messenger.h" +#include "group.h" + +#define TOX_DEFINED +typedef struct Messenger Tox; + +#include "tox.h" + /**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/ /* Set the callback for group invites. diff --git a/toxcore/tox_old.h b/toxcore/tox_group.h similarity index 98% rename from toxcore/tox_old.h rename to toxcore/tox_group.h index a926cdf7..51beb570 100644 --- a/toxcore/tox_old.h +++ b/toxcore/tox_group.h @@ -1,3 +1,8 @@ +#ifndef TOX_GROUP_H +#define TOX_GROUP_H + +#include "tox.h" + /**********GROUP CHAT FUNCTIONS ************/ /* Group chat types for tox_callback_group_invite function. @@ -171,3 +176,4 @@ uint32_t tox_get_chatlist(const Tox *tox, int32_t *out_list, uint32_t list_size) */ int tox_group_get_type(const Tox *tox, int groupnumber); +#endif /* TOX_GROUP_H */