Run clang-format and enable CI check for it (#755)

* pre-commit: Update and enable clang-format check

There is newer version from clang-format so use that. We do not yet want
18 as that is little bit too new.

* Format some thing by hand which clang-format "breaks"

Clang-format will format some things little bit off in some cases.
Format some things by hand so we get cleaner end result.

* Run clang-format with

```
pre-commit run --all-files clang-format
```

We have already in previously checked places where clang-format does not
make good format and ignored those (hopefully most of the things).

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
Kari Argillander
2024-08-30 19:20:58 +03:00
committed by GitHub
parent 622a9e609e
commit f806c5829b
547 changed files with 18286 additions and 16575 deletions
+56 -55
View File
@@ -1,10 +1,10 @@
/**************************************************************************
*
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
*
* SPDX-License-Identifier: MIT
*
*********************************************************************/
*
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
*
* SPDX-License-Identifier: MIT
*
*********************************************************************/
#ifndef BIP_H
#define BIP_H
@@ -16,7 +16,7 @@
/* specific defines for BACnet/IP over Ethernet */
#define BIP_HEADER_MAX (1 + 1 + 2)
#define BIP_MPDU_MAX (BIP_HEADER_MAX+MAX_PDU)
#define BIP_MPDU_MAX (BIP_HEADER_MAX + MAX_PDU)
#define BVLL_TYPE_BACNET_IP (0x81)
@@ -24,69 +24,70 @@
extern "C" {
#endif /* __cplusplus */
/* note: define init, set_interface, and cleanup in your port */
/* on Linux, ifname is eth0, ath0, arc0, and others.
on Windows, ifname is the dotted ip address of the interface */
bool bip_init(char *ifname);
void bip_set_interface(const char *ifname);
void bip_cleanup(void);
/* note: define init, set_interface, and cleanup in your port */
/* on Linux, ifname is eth0, ath0, arc0, and others.
on Windows, ifname is the dotted ip address of the interface */
bool bip_init(char *ifname);
void bip_set_interface(const char *ifname);
void bip_cleanup(void);
/* Convert uint8_t IPv4 to uint32 */
uint32_t convertBIP_Address2uint32(const uint8_t * bip_address);
void convertUint32Address_2_uint8Address(uint32_t ip,
uint8_t * address);
/* common BACnet/IP functions */
void bip_set_socket(uint8_t sock_fd);
uint8_t bip_socket(void);
bool bip_valid(void);
void bip_get_broadcast_address(BACNET_ADDRESS * dest); /* destination address */
void bip_get_my_address(BACNET_ADDRESS * my_address);
/* Convert uint8_t IPv4 to uint32 */
uint32_t convertBIP_Address2uint32(const uint8_t *bip_address);
void convertUint32Address_2_uint8Address(uint32_t ip, uint8_t *address);
/* common BACnet/IP functions */
void bip_set_socket(uint8_t sock_fd);
uint8_t bip_socket(void);
bool bip_valid(void);
void bip_get_broadcast_address(BACNET_ADDRESS *dest); /* destination address */
void bip_get_my_address(BACNET_ADDRESS *my_address);
/* function to send a packet out the BACnet/IP socket */
/* returns zero on success, non-zero on failure */
int bip_send_pdu(BACNET_ADDRESS * dest, /* destination address */
/* function to send a packet out the BACnet/IP socket */
/* returns zero on success, non-zero on failure */
int bip_send_pdu(
BACNET_ADDRESS *dest, /* destination address */
BACNET_NPDU_DATA * npdu_data, /* network information */
BACNET_NPDU_DATA *npdu_data, /* network information */
uint8_t * pdu, /* any data to be sent - may be null */
uint8_t *pdu, /* any data to be sent - may be null */
unsigned pdu_len); /* number of bytes of data */
unsigned pdu_len); /* number of bytes of data */
/* receives a BACnet/IP packet */
/* returns the number of octets in the PDU, or zero on failure */
uint16_t bip_receive(BACNET_ADDRESS * src, /* source address */
/* receives a BACnet/IP packet */
/* returns the number of octets in the PDU, or zero on failure */
uint16_t bip_receive(
BACNET_ADDRESS *src, /* source address */
uint8_t * pdu, /* PDU data */
uint8_t *pdu, /* PDU data */
uint16_t max_pdu, /* amount of space available in the PDU */
uint16_t max_pdu, /* amount of space available in the PDU */
unsigned timeout); /* milliseconds to wait for a packet */
unsigned timeout); /* milliseconds to wait for a packet */
/* use host byte order for setting */
void bip_set_port(uint16_t port);
/* returns host byte order */
uint16_t bip_get_port(void);
/* use host byte order for setting */
void bip_set_port(uint16_t port);
/* returns host byte order */
uint16_t bip_get_port(void);
/* use network byte order for setting */
void bip_set_addr(const uint8_t * net_address);
/* returns network byte order */
uint8_t *bip_get_addr(void);
/* use network byte order for setting */
void bip_set_addr(const uint8_t *net_address);
/* returns network byte order */
uint8_t *bip_get_addr(void);
/* use network byte order for setting */
void bip_set_broadcast_addr(const uint8_t * net_address);
/* returns network byte order */
uint8_t *bip_get_broadcast_addr(void);
/* use network byte order for setting */
void bip_set_broadcast_addr(const uint8_t *net_address);
/* returns network byte order */
uint8_t *bip_get_broadcast_addr(void);
/* gets an IP address by name, where name can be a
string that is an IP address in dotted form, or
a name that is a domain name
returns 0 if not found, or
an IP address in network byte order */
long bip_getaddrbyname(const char *host_name);
/* gets an IP address by name, where name can be a
string that is an IP address in dotted form, or
a name that is a domain name
returns 0 if not found, or
an IP address in network byte order */
long bip_getaddrbyname(const char *host_name);
void bip_debug_enable(void);
void bip_debug_enable(void);
void bip_debug_disable(void);
void bip_debug_disable(void);
#ifdef __cplusplus
}