diff options
author | rubidium <rubidium@openttd.org> | 2007-01-04 21:48:52 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-01-04 21:48:52 +0000 |
commit | 73079f83bc99d17571e547cfcc7c2c9c6ff31217 (patch) | |
tree | 14ee5feed2ea48a5d6f3bc1965768ced6fa0dd4d | |
parent | b2f85eb044df4ea47ce53115f11a113d2914df24 (diff) | |
download | openttd-73079f83bc99d17571e547cfcc7c2c9c6ff31217.tar.xz |
(svn r7836) -Codechange: some constness for network/core.
-rw-r--r-- | src/network/core/core.c | 2 | ||||
-rw-r--r-- | src/network/core/os_abstraction.h | 4 | ||||
-rw-r--r-- | src/network/core/packet.c | 4 | ||||
-rw-r--r-- | src/network/core/packet.h | 4 | ||||
-rw-r--r-- | src/network/core/tcp.c | 2 | ||||
-rw-r--r-- | src/network/core/udp.c | 6 | ||||
-rw-r--r-- | src/network/core/udp.h | 8 | ||||
-rw-r--r-- | src/network/network_udp.c | 6 |
8 files changed, 18 insertions, 18 deletions
diff --git a/src/network/core/core.c b/src/network/core/core.c index a4131bdf2..ca953e5f0 100644 --- a/src/network/core/core.c +++ b/src/network/core/core.c @@ -68,7 +68,7 @@ bool NetworkCoreInitialize(void) void NetworkCoreShutdown(void) { #if defined(__MORPHOS__) || defined(__AMIGA__) - /* free allocated ressources */ + /* free allocated resources */ #if defined(__AMIGA__) if (TimerBase != NULL) CloseDevice((struct IORequest*)TimerRequest); // XXX This smells wrong if (TimerRequest != NULL) DeleteIORequest(TimerRequest); diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h index 792c42658..df3cf65b3 100644 --- a/src/network/core/os_abstraction.h +++ b/src/network/core/os_abstraction.h @@ -150,7 +150,7 @@ typedef unsigned long in_addr_t; # endif #endif // __MORPHOS__ || __AMIGA__ -static inline bool SetNonBlocking(int d) +static inline bool SetNonBlocking(const int d) { #ifdef WIN32 u_long nonblocking = 1; @@ -164,7 +164,7 @@ static inline bool SetNonBlocking(int d) #endif } -static inline bool SetNoDelay(int d) +static inline bool SetNoDelay(const int d) { /* XXX should this be done at all? */ #if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server diff --git a/src/network/core/packet.c b/src/network/core/packet.c index aed0b6299..d75d78c7e 100644 --- a/src/network/core/packet.c +++ b/src/network/core/packet.c @@ -22,7 +22,7 @@ extern void NORETURN CDECL error(const char *str, ...); * @param type the of packet * @return the newly created packet */ -Packet *NetworkSend_Init(PacketType type) +Packet *NetworkSend_Init(const PacketType type) { Packet *packet = malloc(sizeof(Packet)); /* An error is inplace here, because it simply means we ran out of memory. */ @@ -112,7 +112,7 @@ void NetworkSend_string(Packet *packet, const char* data) extern uint CloseConnection(NetworkClientState *cs); /** Is it safe to read from the packet, i.e. didn't we run over the buffer ? */ -static inline bool CanReadFromPacket(NetworkClientState *cs, Packet *packet, uint bytes_to_read) +static inline bool CanReadFromPacket(NetworkClientState *cs, const Packet *packet, const uint bytes_to_read) { /* Don't allow reading from a closed socket */ if (HasClientQuit(cs)) return false; diff --git a/src/network/core/packet.h b/src/network/core/packet.h index a44c6b50e..e42c65d5c 100644 --- a/src/network/core/packet.h +++ b/src/network/core/packet.h @@ -21,7 +21,7 @@ typedef struct NetworkClientState NetworkClientState; * @param cs the state to query * @param true if the connection should be considered dropped */ -bool HasClientQuit(NetworkClientState *cs); +bool HasClientQuit(const NetworkClientState *cs); typedef uint16 PacketSize; ///< Size of the whole packet. typedef uint8 PacketType; ///< Identifier for the packet @@ -49,7 +49,7 @@ typedef struct Packet { } Packet; -Packet *NetworkSend_Init(PacketType type); +Packet *NetworkSend_Init(const PacketType type); void NetworkSend_FillPacketSize(Packet *packet); void NetworkSend_uint8 (Packet *packet, uint8 data); void NetworkSend_uint16(Packet *packet, uint16 data); diff --git a/src/network/core/tcp.c b/src/network/core/tcp.c index 807288a86..9261ea049 100644 --- a/src/network/core/tcp.c +++ b/src/network/core/tcp.c @@ -46,7 +46,7 @@ NetworkRecvStatus CloseConnection(NetworkClientState *cs) * @param cs the client to check * @return true if the client has quit */ -bool HasClientQuit(NetworkClientState *cs) +bool HasClientQuit(const NetworkClientState *cs) { return cs->has_quit; } diff --git a/src/network/core/udp.c b/src/network/core/udp.c index 93c24a156..72d600157 100644 --- a/src/network/core/udp.c +++ b/src/network/core/udp.c @@ -20,7 +20,7 @@ * @param broadcast whether to allow broadcast sending/receiving * @return true if the listening succeeded */ -bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast) +bool NetworkUDPListen(SOCKET *udp, const uint32 host, const uint16 port, const bool broadcast) { struct sockaddr_in sin; @@ -85,7 +85,7 @@ void NetworkUDPClose(SOCKET *udp) * @param p the packet to send * @param recv the receiver (target) of the packet */ -void NetworkSendUDP_Packet(SOCKET udp, Packet *p, struct sockaddr_in *recv) +void NetworkSendUDP_Packet(const SOCKET udp, Packet *p, const struct sockaddr_in *recv) { int res; @@ -102,7 +102,7 @@ void NetworkSendUDP_Packet(SOCKET udp, Packet *p, struct sockaddr_in *recv) * Receive a packet at UDP level * @param udp the socket to receive the packet on */ -void NetworkUDPReceive(SOCKET udp) +void NetworkUDPReceive(const SOCKET udp) { struct sockaddr_in client_addr; socklen_t client_len; diff --git a/src/network/core/udp.h b/src/network/core/udp.h index ce8b0e88f..f0d4ed983 100644 --- a/src/network/core/udp.h +++ b/src/network/core/udp.h @@ -16,11 +16,11 @@ ///** Sending/receiving of UDP packets **//// -bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast); +bool NetworkUDPListen(SOCKET *udp, const uint32 host, const uint16 port, const bool broadcast); void NetworkUDPClose(SOCKET *udp); -void NetworkSendUDP_Packet(SOCKET udp, Packet *p, struct sockaddr_in *recv); -void NetworkUDPReceive(SOCKET udp); +void NetworkSendUDP_Packet(const SOCKET udp, Packet *p, const struct sockaddr_in *recv); +void NetworkUDPReceive(const SOCKET udp); /** * Function that is called for every received UDP packet. @@ -28,7 +28,7 @@ void NetworkUDPReceive(SOCKET udp); * @param packet the received packet * @param client_addr the address of the sender of the packet */ -void NetworkHandleUDPPacket(SOCKET udp, Packet *p, struct sockaddr_in *client_addr); +void NetworkHandleUDPPacket(const SOCKET udp, Packet *p, const struct sockaddr_in *client_addr); ///** Sending/receiving of (large) chuncks of UDP packets **//// diff --git a/src/network/network_udp.c b/src/network/network_udp.c index f64ebc2b9..5caec3b42 100644 --- a/src/network/network_udp.c +++ b/src/network/network_udp.c @@ -28,7 +28,7 @@ enum { ADVERTISE_RETRY_TIMES = 3 // give up readvertising after this much failed retries }; -#define DEF_UDP_RECEIVE_COMMAND(type) void NetworkPacketReceive_ ## type ## _command(Packet *p, struct sockaddr_in *client_addr) +#define DEF_UDP_RECEIVE_COMMAND(type) void NetworkPacketReceive_ ## type ## _command(Packet *p, const struct sockaddr_in *client_addr) static NetworkClientState _udp_cs; @@ -403,7 +403,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_NEWGRFS) * game information of some 'random' host. */ typedef struct NetworkUDPPacketAndSocket { - void (*callback)(Packet *p, struct sockaddr_in *client_addr); + void (*callback)(Packet *p, const struct sockaddr_in *client_addr); SOCKET *incoming_socket; } NetworkUPDPacketAndSocket; @@ -421,7 +421,7 @@ static const NetworkUPDPacketAndSocket _network_udp_packet[PACKET_UDP_END] = { { RECEIVE_COMMAND(PACKET_UDP_SERVER_NEWGRFS), &_udp_client_socket }, }; -void NetworkHandleUDPPacket(SOCKET udp, Packet *p, struct sockaddr_in *client_addr) +void NetworkHandleUDPPacket(const SOCKET udp, Packet *p, const struct sockaddr_in *client_addr) { byte type; |