Skip to content

Commit

Permalink
compat/htonl.->compat/net.h
Browse files Browse the repository at this point in the history
It can be used in place of other network-related headers, not just for
htonl and family.

+ compat for fd_t and INVALID_SOCKET (that has been in config_*.h)
  • Loading branch information
MartinPulec committed Sep 30, 2024
1 parent 745c7f9 commit 9adf7b6
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/blackmagic_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
#include <unordered_map>
#include <utility>

#include "compat/htonl.h"
#include "compat/misc.h" // for strncasecmp
#include "compat/net.h" // for htonl, ntohl
#include "DeckLinkAPIVersion.h"
#include "blackmagic_common.hpp"
#include "debug.h"
Expand Down
13 changes: 11 additions & 2 deletions src/compat/htonl.h → src/compat/net.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* @file compat/htonl.h
* @file compat/net.h
* @author Martin Pulec <[email protected]>
*
* This file just picks the correct header for [nh]to[nh]l functions.
* This file includes the correct header for network-related functions
* (also htonl and the family).
*/
/*
* Copyright (c) 2024 CESNET, z. s. p. o.
Expand Down Expand Up @@ -37,8 +38,16 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef COMPAT_NET_H_EF7499D8_4939_4F86_A585_2EED8221D056
#define COMPAT_NET_H_EF7499D8_4939_4F86_A585_2EED8221D056

#ifdef _WIN32
#include <winsock2.h>
typedef SOCKET fd_t;
#else
#include <arpa/inet.h>
typedef int fd_t;
#define INVALID_SOCKET (-1)
#endif

#endif // defined COMPAT_NET_H_EF7499D8_4939_4F86_A585_2EED8221D056
2 changes: 1 addition & 1 deletion src/config_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static inline void *aligned_malloc(size_t size, size_t alignment)
}
#define aligned_free free

#define INVALID_SOCKET -1
#define INVALID_SOCKET (-1)
#define CLOSESOCKET close

#define _ftelli64 ftell
Expand Down
2 changes: 1 addition & 1 deletion src/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#include "capture_filter.h"
#include "compat/platform_pipe.h"
#include "compat/strings.h" // strdupa
#include "config_unix.h" // for fd_t
#include "compat/net.h" // for fd_t
#include "cuda_wrapper.h" // for cudaDeviceReset
#include "debug.h"
#include "keyboard_control.h"
Expand Down
2 changes: 1 addition & 1 deletion src/libavcodec/to_lavc_vid_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <stdint.h>

#include "color.h"
#include "compat/htonl.h" // for htonl
#include "compat/net.h" // for htonl
#include "compat/qsort_s.h"
#include "debug.h"
#include "host.h"
Expand Down
2 changes: 1 addition & 1 deletion src/rtp/audio_decoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#include "audio/resampler.hpp" // for audio_frame2_resampler
#include "audio/types.h" // for audio_frame2, audio_desc, AC_PCM
#include "audio/utils.h" // for channel_map, calculate_rms, mux_...
#include "compat/htonl.h" // for ntohl, sockaddr_storage
#include "compat/net.h" // for ntohl, sockaddr_storage
#include "compat/strings.h" // for strcasecmp
#include "control_socket.h"
#include "crypto/openssl_decrypt.h" // for openssl_decrypt_info, OPENSSL_DE...
Expand Down
2 changes: 1 addition & 1 deletion src/rtp/rtpdec_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <stdlib.h> // for free, malloc, NULL
#include <string.h> // for memcpy

#include "compat/htonl.h" // for ntohs
#include "compat/net.h" // for ntohs
#include "debug.h"
#include "rtp/rtp.h"
#include "rtp/pbuf.h"
Expand Down
2 changes: 1 addition & 1 deletion src/rtp/video_decoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
#include <utility> // for pair, move
#include <vector> // for vector

#include "compat/htonl.h" // for ntohl
#include "compat/net.h" // for ntohl
#include "crypto/openssl_decrypt.h"
#include "crypto/openssl_encrypt.h" // for openssl_mode
#include "control_socket.h"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#endif

#include "audio/types.h"
#include "compat/htonl.h" // for htons, htonl
#include "compat/net.h" // for htons, htonl
#include "compat/strings.h" // for strcasecmp
#include "config.h" // for SDP_HTTP
#include "debug.h"
Expand Down
2 changes: 1 addition & 1 deletion src/video_capture/decklink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
#include "blackmagic_common.hpp"
#include "audio/types.h"
#include "audio/utils.h"
#include "compat/htonl.h"
#include "compat/net.h" // for ntohl
#include "compat/strings.h"
#include "debug.h"
#include "host.h"
Expand Down
2 changes: 1 addition & 1 deletion src/video_capture/testcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

#include "audio/types.h"
#include "audio/utils.h"
#include "compat/htonl.h"
#include "compat/net.h" // for ntohs
#include "debug.h"
#include "host.h"
#include "lib_common.h"
Expand Down
2 changes: 1 addition & 1 deletion src/video_display/decklink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

#include "audio/types.h"
#include "blackmagic_common.hpp"
#include "compat/htonl.h"
#include "compat/net.h" // for ntohl
#include "compat/strings.h"
#include "debug.h"
#include "host.h"
Expand Down
2 changes: 1 addition & 1 deletion src/video_display/sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#include <string.h> // for NULL, strlen, strcmp, strstr, strchr
#include <time.h> // for timespec_get, TIME_UTC, timespec

#include "compat/htonl.h" // for htonl
#include "compat/net.h" // for htonl
#include "debug.h" // for log_msg, LOG_LEVEL_ERROR, LOG_LEVEL_W...
#include "host.h" // for get_commandline_param, exit_uv, ADD_T...
#include "keyboard_control.h" // for keycontrol_register_key, keycontrol_s...
Expand Down

0 comments on commit 9adf7b6

Please sign in to comment.