From 423d7bf82414f8a68198528796d3a6e59d9bda73 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 5 Jan 2024 12:24:52 +0100 Subject: [PATCH] MT#59086 Unify header files. In the header files follow the rules: 1. Firstly goes ifndef/define construction, then one empty row. 2. Secondly go system headers, so in angle-brackets, then one empty row. 3. If there are important pre-processor definitions, which affect the following custom file headers, they are added next, then one empty row. 4. Thirdly custom header files, so in double quotes, then at least one empty row. 5. If there is "xt_RTPENGINE.h", it's mentioned next, but separately, then one empty row. 6. Then pre-processor definitions, and one empty row before the code. In some situations it's allowed to step aside from the rules, when inclusions are dependent on each other, so on specific sequence, and also possibly on some inline objects definitions. But, if possible to follow the rules, it should be done. Change-Id: I6bec69b508653947c04e7785775373d21112eb58 --- include/audio_player.h | 2 +- include/call.h | 6 ++---- include/call_interfaces.h | 3 +-- include/cdr.h | 7 ------- include/codec.h | 3 ++- include/control_tcp.h | 7 ------- include/control_udp.h | 9 +-------- include/cookie_cache.h | 1 + include/crypto.h | 5 +---- include/dtls.h | 10 ---------- include/dtmf.h | 3 +-- include/graphite.h | 7 ------- include/helpers.h | 6 +----- include/homer.h | 2 -- include/ice.h | 13 +------------ include/iptables.h | 4 ---- include/janus.h | 1 - include/jitter_buffer.h | 6 ++---- include/kernel.h | 12 ++---------- include/main.h | 2 +- include/media_player.h | 4 +--- include/media_socket.h | 6 ++---- include/mqtt.h | 2 +- include/recording.h | 3 +-- include/redis.h | 13 ++++--------- include/rtcp.h | 4 ++-- include/rtp.h | 12 +----------- include/sdp.h | 2 +- include/ssrc.h | 8 +------- include/statistics.h | 4 ---- include/stun.h | 5 +---- include/t38.h | 12 ------------ include/tcp_listener.h | 1 - include/timerthread.h | 4 ++-- include/udp_listener.h | 1 + include/websocket.h | 2 +- 36 files changed, 36 insertions(+), 156 deletions(-) diff --git a/include/audio_player.h b/include/audio_player.h index 7a9201911..582f15571 100644 --- a/include/audio_player.h +++ b/include/audio_player.h @@ -6,8 +6,8 @@ #include #include #include -#include "types.h" +#include "types.h" /* * Similar to the existing media_player, but instead of simply producing diff --git a/include/call.h b/include/call.h index dba821601..54be4205e 100644 --- a/include/call.h +++ b/include/call.h @@ -1,12 +1,9 @@ #ifndef __CALL_H__ #define __CALL_H__ - - /* XXX split everything into call_signalling.[ch] and call_packets.[ch] or w/e */ #include - #include #include #include @@ -27,9 +24,10 @@ #include "statistics.h" #include "codeclib.h" #include "t38.h" -#include "xt_RTPENGINE.h" #include "types.h" +#include "xt_RTPENGINE.h" + #define UNDEFINED ((unsigned int) -1) enum termination_reason { diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 6fd9ea254..01e047326 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -1,9 +1,8 @@ #ifndef _CALL_INTERFACES_H_ #define _CALL_INTERFACES_H_ - - #include + #include "str.h" #include "bencode.h" #include "socket.h" diff --git a/include/cdr.h b/include/cdr.h index 8af085a65..c6f7aa1b6 100644 --- a/include/cdr.h +++ b/include/cdr.h @@ -1,10 +1,3 @@ -/* - * cdr.h - * - * Created on: Mar 14, 2017 - * Author: fmetz - */ - #ifndef CDR_H_ #define CDR_H_ diff --git a/include/codec.h b/include/codec.h index d9a6280d0..c345a730a 100644 --- a/include/codec.h +++ b/include/codec.h @@ -4,14 +4,15 @@ #include #include #include + #include "str.h" #include "codeclib.h" #include "helpers.h" #include "rtplib.h" #include "timerthread.h" -#include "xt_RTPENGINE.h" #include "types.h" +#include "xt_RTPENGINE.h" struct call_media; struct codec_handler; diff --git a/include/control_tcp.h b/include/control_tcp.h index 264073b9d..fc6f7b5f3 100644 --- a/include/control_tcp.h +++ b/include/control_tcp.h @@ -1,8 +1,6 @@ #ifndef __CONTROL_H__ #define __CONTROL_H__ - - #include #include #include @@ -13,7 +11,6 @@ #include "helpers.h" #include "socket.h" - #define RE_TCP_RL_CMD 1 #define RE_TCP_RL_CALLID 2 #define RE_TCP_RL_STREAMS 3 @@ -32,10 +29,6 @@ struct control_tcp; struct streambuf_stream; - - struct control_tcp *control_tcp_new(const endpoint_t *); - - #endif diff --git a/include/control_udp.h b/include/control_udp.h index f17421d59..9839b7938 100644 --- a/include/control_udp.h +++ b/include/control_udp.h @@ -1,22 +1,17 @@ #ifndef __CONTROL_UDP_H__ #define __CONTROL_UDP_H__ - - - - #include #include #include #include + #include "obj.h" #include "helpers.h" #include "cookie_cache.h" #include "udp_listener.h" #include "socket.h" - - #define RE_UDP_COOKIE 1 #define RE_UDP_UL_CMD 2 #define RE_UDP_UL_FLAGS 3 @@ -38,8 +33,6 @@ #define RE_UDP_V_FLAGS 19 #define RE_UDP_V_PARMS 20 - - struct control_udp { struct obj obj; diff --git a/include/cookie_cache.h b/include/cookie_cache.h index 83cb5d3e5..d08893730 100644 --- a/include/cookie_cache.h +++ b/include/cookie_cache.h @@ -3,6 +3,7 @@ #include #include + #include "helpers.h" #include "str.h" diff --git a/include/crypto.h b/include/crypto.h index f74a9ed9e..b06b28a12 100644 --- a/include/crypto.h +++ b/include/crypto.h @@ -1,10 +1,9 @@ #ifndef _CRYPTO_H_ #define _CRYPTO_H_ - - #include #include + #include "compat.h" #include "str.h" #include "helpers.h" @@ -16,8 +15,6 @@ #define SRTP_MAX_SESSION_SALT_LEN 14 #define SRTP_MAX_SESSION_AUTH_LEN 20 - - struct crypto_context; struct rtp_header; struct rtcp_packet; diff --git a/include/dtls.h b/include/dtls.h index f5dedf137..b9b836b48 100644 --- a/include/dtls.h +++ b/include/dtls.h @@ -1,8 +1,6 @@ #ifndef _DTLS_H_ #define _DTLS_H_ - - #include #include #include @@ -14,19 +12,11 @@ #include "socket.h" #include "types.h" - - - #define DTLS_MAX_DIGEST_LEN 64 - - - struct packet_stream; struct sockaddr_in6; - - struct dtls_hash_func { const char *name; unsigned int num_bytes; diff --git a/include/dtmf.h b/include/dtmf.h index 27ec0b04b..6ac7e5830 100644 --- a/include/dtmf.h +++ b/include/dtmf.h @@ -5,16 +5,15 @@ #include #include #include + #include "str.h" #include "socket.h" #include "call.h" - struct media_packet; struct call_media; struct call_monologue; - struct dtmf_event { int code; // char for start, zero for end int volume; diff --git a/include/graphite.h b/include/graphite.h index 06aded203..758d0b213 100644 --- a/include/graphite.h +++ b/include/graphite.h @@ -1,10 +1,3 @@ -/* - * graphite.h - * - * Created on: Jan 19, 2015 - * Author: fmetz - */ - #ifndef GRAPHITE_H_ #define GRAPHITE_H_ diff --git a/include/helpers.h b/include/helpers.h index b27f7c6a2..b36533927 100644 --- a/include/helpers.h +++ b/include/helpers.h @@ -1,8 +1,6 @@ #ifndef __HELPERS_H__ #define __HELPERS_H__ - - #include #include #include @@ -18,6 +16,7 @@ #include #include #include + #include "compat.h" #include "auxlib.h" @@ -25,9 +24,6 @@ #define __THREAD_DEBUG 1 #endif - - - /*** PROTOTYPES ***/ typedef bool (*parse_func)(char **, void **, void *); diff --git a/include/homer.h b/include/homer.h index de86f13ea..54868eb24 100644 --- a/include/homer.h +++ b/include/homer.h @@ -3,11 +3,9 @@ #include "socket.h" - void homer_sender_init(const endpoint_t *, int, int); int homer_send(GString *, const str *, const endpoint_t *, const endpoint_t *, const struct timeval *tv); int has_homer(void); - #endif diff --git a/include/ice.h b/include/ice.h index 8dcd7c418..d9ff31a47 100644 --- a/include/ice.h +++ b/include/ice.h @@ -1,13 +1,12 @@ #ifndef __ICE_H__ #define __ICE_H__ - - #include #include #include #include #include + #include "str.h" #include "obj.h" #include "helpers.h" @@ -16,9 +15,6 @@ #include "timerthread.h" #include "types.h" - - - #define MAX_COMPONENTS 2 #define TIMER_RUN_INTERVAL 20 /* ms */ #define STUN_RETRANSMIT_INTERVAL 100 /* ms, with exponential backoff */ @@ -26,8 +22,6 @@ #define MAX_ICE_CANDIDATES 100 #define ICE_FOUNDATION_LENGTH 16 - - #define ICE_AGENT_COMPLETED 0x0002 #define ICE_AGENT_CONTROLLING 0x0004 #define ICE_AGENT_NOMINATING 0x0008 @@ -58,8 +52,6 @@ #define AGENT_CLEAR3(p, f, g, h) \ bf_clear(&(p)->agent_flags, ICE_AGENT_ ## f | ICE_AGENT_ ## g | ICE_AGENT_ ## h) - - struct logical_intf; struct local_intf; struct packet_stream; @@ -68,9 +60,6 @@ struct stream_params; struct stun_attrs; struct call_monologue; - - - enum ice_candidate_type { ICT_UNKNOWN = 0, ICT_HOST, diff --git a/include/iptables.h b/include/iptables.h index e92e178e5..85297673a 100644 --- a/include/iptables.h +++ b/include/iptables.h @@ -1,15 +1,11 @@ #ifndef _IPTABLES_H_ #define _IPTABLES_H_ - #include "socket.h" #include "str.h" - void iptables_init(void); extern int (*iptables_add_rule)(const socket_t *local_sock, const str *comment); extern int (*iptables_del_rule)(const socket_t *local_sock); - - #endif diff --git a/include/janus.h b/include/janus.h index b261bbc44..6496d669e 100644 --- a/include/janus.h +++ b/include/janus.h @@ -7,7 +7,6 @@ struct janus_session; struct call_monologue; struct call_media; - void janus_init(void); void janus_free(void); diff --git a/include/jitter_buffer.h b/include/jitter_buffer.h index 44f61ba95..addb8e290 100644 --- a/include/jitter_buffer.h +++ b/include/jitter_buffer.h @@ -5,12 +5,10 @@ #include "socket.h" #include "timerthread.h" #include "media_socket.h" -//#include "codec.h" -// -//struct packet_handler_ctx; + struct jb_packet; struct media_packet; -// + struct jb_packet { struct timerthread_queue_entry ttq_entry; char *buf; diff --git a/include/kernel.h b/include/kernel.h index f1770fd4b..131457811 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -1,30 +1,22 @@ #ifndef __KERNEL_H__ #define __KERNEL_H__ - - #include #include #include -#include "xt_RTPENGINE.h" -#include "containers.h" - +#include "containers.h" +#include "xt_RTPENGINE.h" #define UNINIT_IDX ((unsigned int) -1) - - - struct rtpengine_target_info; struct rtpengine_destination_info; struct rtpengine_send_packet_info; struct re_address; struct rtpengine_ssrc_stats; - - struct kernel_interface { unsigned int table; int fd; diff --git a/include/main.h b/include/main.h index 9f84968b2..bf815b8fc 100644 --- a/include/main.h +++ b/include/main.h @@ -1,9 +1,9 @@ #ifndef _MAIN_H_ #define _MAIN_H_ +#include #include "helpers.h" -#include #include "socket.h" #include "auxlib.h" diff --git a/include/media_player.h b/include/media_player.h index 822726d0c..f9951727e 100644 --- a/include/media_player.h +++ b/include/media_player.h @@ -1,14 +1,12 @@ #ifndef _MEDIA_PLAYER_H_ #define _MEDIA_PLAYER_H_ +#include #include "auxlib.h" #include "timerthread.h" #include "str.h" #include "types.h" -#include - - struct call_media; struct call_monologue; diff --git a/include/media_socket.h b/include/media_socket.h index 7691f03b7..001d413f2 100644 --- a/include/media_socket.h +++ b/include/media_socket.h @@ -1,22 +1,20 @@ #ifndef _MEDIA_SOCKET_H_ #define _MEDIA_SOCKET_H_ - #include #include #include + #include "str.h" #include "obj.h" #include "helpers.h" #include "dtls.h" #include "crypto.h" #include "socket.h" -#include "xt_RTPENGINE.h" #include "containers.h" #include "types.h" - - +#include "xt_RTPENGINE.h" struct media_packet; struct transport_protocol; diff --git a/include/mqtt.h b/include/mqtt.h index c366cf0e7..c9af703a6 100644 --- a/include/mqtt.h +++ b/include/mqtt.h @@ -2,12 +2,12 @@ #define _MQTT_H_ #include + #include "main.h" #include "types.h" struct call_media; - #ifdef HAVE_MQTT diff --git a/include/recording.h b/include/recording.h index 6d6d40fdc..a7d7177cc 100644 --- a/include/recording.h +++ b/include/recording.h @@ -4,7 +4,6 @@ * Handles call recording to PCAP files and recording metadata. * Mostly filesystem operations */ - #ifndef __RECORDING_H__ #define __RECORDING_H__ @@ -12,12 +11,12 @@ #include #include #include + #include "str.h" #include "helpers.h" #include "bencode.h" #include "types.h" - struct packet_stream; struct media_packet; enum call_opmode; diff --git a/include/redis.h b/include/redis.h index 737e6fbb3..99373ea57 100644 --- a/include/redis.h +++ b/include/redis.h @@ -1,24 +1,19 @@ #ifndef __REDIS_MOD_H__ #define __REDIS_MOD_H__ - - - #include -#include "compat.h" -#include "socket.h" -#include "helpers.h" - #include #include #include + +#include "compat.h" +#include "socket.h" +#include "helpers.h" #include "call.h" #include "str.h" - #define REDIS_RESTORE_NUM_THREADS 4 - enum redis_role { MASTER_REDIS_ROLE = 0, SLAVE_REDIS_ROLE = 1, diff --git a/include/rtcp.h b/include/rtcp.h index 1074511ac..cfc41fc33 100644 --- a/include/rtcp.h +++ b/include/rtcp.h @@ -1,11 +1,11 @@ #ifndef _RTCP_H_ #define _RTCP_H_ +#include + #include "str.h" #include "call.h" #include "media_socket.h" -#include - struct crypto_context; struct rtcp_packet; diff --git a/include/rtp.h b/include/rtp.h index 62e4a4465..241196462 100644 --- a/include/rtp.h +++ b/include/rtp.h @@ -1,13 +1,10 @@ #ifndef _RTP_H_ #define _RTP_H_ - +#include #include "str.h" #include "types.h" -#include - - struct crypto_context; struct rtp_header; @@ -16,10 +13,6 @@ enum ssrc_dir; struct ssrc_ctx; struct codec_store; - - - - const rtp_payload_type *get_rtp_payload_type(unsigned int, struct codec_store *); int rtp_avp2savp(str *, struct crypto_context *, struct ssrc_ctx *); @@ -30,7 +23,4 @@ int srtp_payloads(str *to_auth, str *to_decrypt, str *auth_tag, str *mki, int auth_len, int mki_len, const str *packet, const str *payload); - - - #endif diff --git a/include/sdp.h b/include/sdp.h index 8b46760f5..e8cd81e16 100644 --- a/include/sdp.h +++ b/include/sdp.h @@ -1,8 +1,8 @@ #ifndef _SDP_H_ #define _SDP_H_ - #include + #include "str.h" #include "call.h" #include "media_socket.h" diff --git a/include/ssrc.h b/include/ssrc.h index 0b28c3a82..57c0cab69 100644 --- a/include/ssrc.h +++ b/include/ssrc.h @@ -1,29 +1,23 @@ #ifndef _SSRC_H_ #define _SSRC_H_ - #include #include + #include "compat.h" #include "helpers.h" #include "obj.h" #include "codeclib.h" #include "types.h" - - - struct call_media; struct timeval; struct ssrc_entry; struct ssrc_entry_call; enum ssrc_dir; - - typedef struct ssrc_entry *(*ssrc_create_func_t)(void *uptr); - struct ssrc_hash { GHashTable *ht; GQueue q; diff --git a/include/statistics.h b/include/statistics.h index d450cdd89..fe6860e3a 100644 --- a/include/statistics.h +++ b/include/statistics.h @@ -6,7 +6,6 @@ #include "rtpengine_config.h" struct packet_stream; - struct stream_stats { atomic64 packets; atomic64 bytes; @@ -18,12 +17,9 @@ struct stream_stats { #endif }; - - #include "control_ng.h" #include "graphite.h" - // "gauge" style stats struct global_stats_gauge { #define F(x) atomic64 x; diff --git a/include/stun.h b/include/stun.h index 30561c75c..b5b08a494 100644 --- a/include/stun.h +++ b/include/stun.h @@ -1,20 +1,17 @@ #ifndef _STUN_H_ #define _STUN_H_ - #include #include #include + #include "compat.h" #include "call.h" #include "str.h" #include "socket.h" - #define STUN_COOKIE 0x2112A442UL - - struct stun_attrs { str username; char *msg_integrity_attr; diff --git a/include/t38.h b/include/t38.h index 5bdcafbef..cc7a3d4bd 100644 --- a/include/t38.h +++ b/include/t38.h @@ -1,7 +1,6 @@ #ifndef _T38_H_ #define _T38_H_ - struct t38_gateway; struct t38_options { @@ -25,12 +24,8 @@ struct t38_options { unsigned int no_iaf:1; }; - - #ifdef WITH_TRANSCODING - - #include #include #include @@ -45,13 +40,10 @@ struct t38_options { #include "codeclib.h" #include "types.h" - - struct call_media; struct media_packet; struct media_player; - struct t38_gateway { struct obj obj; // use refcount as this struct is shared between two medias mutex_t lock; @@ -74,8 +66,6 @@ struct t38_gateway { unsigned long long pts; }; - - void t38_init(void); int t38_gateway_pair(struct call_media *t38_media, struct call_media *pcm_media, const struct t38_options *); @@ -92,7 +82,6 @@ INLINE void t38_gateway_put(struct t38_gateway **tp) { *tp = NULL; } - #else #include "compat.h" @@ -103,7 +92,6 @@ INLINE void t38_gateway_start(struct t38_gateway *tg) { } INLINE void t38_gateway_stop(struct t38_gateway *tg) { } INLINE void t38_gateway_put(struct t38_gateway **tp) { } - #endif #endif diff --git a/include/tcp_listener.h b/include/tcp_listener.h index a89c653cc..374695a3e 100644 --- a/include/tcp_listener.h +++ b/include/tcp_listener.h @@ -6,7 +6,6 @@ #include "helpers.h" #include "containers.h" - struct obj; struct streambuf_callback; struct streambuf_stream; diff --git a/include/timerthread.h b/include/timerthread.h index 5a2c1505f..742acebf2 100644 --- a/include/timerthread.h +++ b/include/timerthread.h @@ -1,11 +1,11 @@ #ifndef _TIMERTHREAD_H_ #define _TIMERTHREAD_H_ -#include "obj.h" #include #include -#include "auxlib.h" +#include "auxlib.h" +#include "obj.h" struct timerthread { GTree *tree; diff --git a/include/udp_listener.h b/include/udp_listener.h index 7612cb10c..3548806c9 100644 --- a/include/udp_listener.h +++ b/include/udp_listener.h @@ -2,6 +2,7 @@ #define _UDP_LISTENER_H_ #include + #include "poller.h" #include "str.h" #include "socket.h" diff --git a/include/websocket.h b/include/websocket.h index f0f0f6838..899e8a609 100644 --- a/include/websocket.h +++ b/include/websocket.h @@ -2,8 +2,8 @@ #define __WEBSOCKET_H__ #include -#include "str.h" +#include "str.h" struct websocket_conn; struct websocket_message;