[net] Use designated initializers for drivers

Not that I expect anything to change any time soon, but nice to have
the initializers explicitly named.
This commit is contained in:
Bill Currie 2022-04-06 18:46:28 +09:00
parent 3f575ab025
commit 8f56f28ad7
2 changed files with 102 additions and 98 deletions

View file

@ -34,36 +34,37 @@
net_driver_t net_drivers[MAX_NET_DRIVERS] = {
{
"Loopback",
false,
Loop_Init,
Loop_Listen,
Loop_SearchForHosts,
Loop_Connect,
Loop_CheckNewConnections,
Loop_GetMessage,
Loop_SendMessage,
Loop_SendUnreliableMessage,
Loop_CanSendMessage,
Loop_CanSendUnreliableMessage,
Loop_Close,
Loop_Shutdown}
,
.name = "Loopback",
.initialized = false,
.Init = Loop_Init,
.Listen = Loop_Listen,
.SearchForHosts = Loop_SearchForHosts,
.Connect = Loop_Connect,
.CheckNewConnections = Loop_CheckNewConnections,
.QGetMessage = Loop_GetMessage,
.QSendMessage = Loop_SendMessage,
.SendUnreliableMessage = Loop_SendUnreliableMessage,
.CanSendMessage = Loop_CanSendMessage,
.CanSendUnreliableMessage = Loop_CanSendUnreliableMessage,
.Close = Loop_Close,
.Shutdown = Loop_Shutdown,
},
{
"Datagram",
false,
Datagram_Init,
Datagram_Listen,
Datagram_SearchForHosts,
Datagram_Connect,
Datagram_CheckNewConnections,
Datagram_GetMessage,
Datagram_SendMessage,
Datagram_SendUnreliableMessage,
Datagram_CanSendMessage,
Datagram_CanSendUnreliableMessage,
Datagram_Close,
Datagram_Shutdown}
.name = "Datagram",
.initialized = false,
.Init = Datagram_Init,
.Listen = Datagram_Listen,
.SearchForHosts = Datagram_SearchForHosts,
.Connect = Datagram_Connect,
.CheckNewConnections = Datagram_CheckNewConnections,
.QGetMessage = Datagram_GetMessage,
.QSendMessage = Datagram_SendMessage,
.SendUnreliableMessage = Datagram_SendUnreliableMessage,
.CanSendMessage = Datagram_CanSendMessage,
.CanSendUnreliableMessage = Datagram_CanSendUnreliableMessage,
.Close = Datagram_Close,
.Shutdown = Datagram_Shutdown,
},
};
int net_numdrivers = 2;
@ -72,26 +73,27 @@ int net_numdrivers = 2;
net_landriver_t net_landrivers[MAX_NET_DRIVERS] = {
{
"UDP",
false,
0,
UDP_Init,
UDP_Shutdown,
UDP_Listen,
UDP_OpenSocket,
UDP_CloseSocket,
UDP_Connect,
UDP_CheckNewConnections,
UDP_Read,
UDP_Write,
UDP_Broadcast,
UDP_AddrToString,
UDP_GetSocketAddr,
UDP_GetNameFromAddr,
UDP_GetAddrFromName,
UDP_AddrCompare,
UDP_GetSocketPort,
UDP_SetSocketPort}
.name = "UDP",
.initialized = false,
.controlSock = 0,
.Init = UDP_Init,
.Shutdown = UDP_Shutdown,
.Listen = UDP_Listen,
.OpenSocket = UDP_OpenSocket,
.CloseSocket = UDP_CloseSocket,
.Connect = UDP_Connect,
.CheckNewConnections = UDP_CheckNewConnections,
.Read = UDP_Read,
.Write = UDP_Write,
.Broadcast = UDP_Broadcast,
.AddrToString = UDP_AddrToString,
.GetSocketAddr = UDP_GetSocketAddr,
.GetNameFromAddr = UDP_GetNameFromAddr,
.GetAddrFromName = UDP_GetAddrFromName,
.AddrCompare = UDP_AddrCompare,
.GetSocketPort = UDP_GetSocketPort,
.SetSocketPort = UDP_SetSocketPort,
},
};
int net_numlandrivers = 1;

View file

@ -33,36 +33,37 @@
net_driver_t net_drivers[MAX_NET_DRIVERS] = {
{
"Loopback",
false,
Loop_Init,
Loop_Listen,
Loop_SearchForHosts,
Loop_Connect,
Loop_CheckNewConnections,
Loop_GetMessage,
Loop_SendMessage,
Loop_SendUnreliableMessage,
Loop_CanSendMessage,
Loop_CanSendUnreliableMessage,
Loop_Close,
Loop_Shutdown}
,
.name = "Loopback",
.initialized = false,
.Init = Loop_Init,
.Listen = Loop_Listen,
.SearchForHosts = Loop_SearchForHosts,
.Connect = Loop_Connect,
.CheckNewConnections = Loop_CheckNewConnections,
.QGetMessage = Loop_GetMessage,
.QSendMessage = Loop_SendMessage,
.SendUnreliableMessage = Loop_SendUnreliableMessage,
.CanSendMessage = Loop_CanSendMessage,
.CanSendUnreliableMessage = Loop_CanSendUnreliableMessage,
.Close = Loop_Close,
.Shutdown = Loop_Shutdown,
},
{
"Datagram",
false,
Datagram_Init,
Datagram_Listen,
Datagram_SearchForHosts,
Datagram_Connect,
Datagram_CheckNewConnections,
Datagram_GetMessage,
Datagram_SendMessage,
Datagram_SendUnreliableMessage,
Datagram_CanSendMessage,
Datagram_CanSendUnreliableMessage,
Datagram_Close,
Datagram_Shutdown}
.name = "Datagram",
.initialized = false,
.Init = Datagram_Init,
.Listen = Datagram_Listen,
.SearchForHosts = Datagram_SearchForHosts,
.Connect = Datagram_Connect,
.CheckNewConnections = Datagram_CheckNewConnections,
.QGetMessage = Datagram_GetMessage,
.QSendMessage = Datagram_SendMessage,
.SendUnreliableMessage = Datagram_SendUnreliableMessage,
.CanSendMessage = Datagram_CanSendMessage,
.CanSendUnreliableMessage = Datagram_CanSendUnreliableMessage,
.Close = Datagram_Close,
.Shutdown = Datagram_Shutdown,
},
};
int net_numdrivers = 2;
@ -72,26 +73,27 @@ int net_numdrivers = 2;
net_landriver_t net_landrivers[MAX_NET_DRIVERS] = {
{
"Winsock TCPIP",
false,
0,
WINS_Init,
WINS_Shutdown,
WINS_Listen,
WINS_OpenSocket,
WINS_CloseSocket,
WINS_Connect,
WINS_CheckNewConnections,
WINS_Read,
WINS_Write,
WINS_Broadcast,
WINS_AddrToString,
WINS_GetSocketAddr,
WINS_GetNameFromAddr,
WINS_GetAddrFromName,
WINS_AddrCompare,
WINS_GetSocketPort,
WINS_SetSocketPort},
.name = "Winsock TCPIP",
.initialized = false,
.controlSock = 0,
.Init = WINS_Init,
.Shutdown = WINS_Shutdown,
.Listen = WINS_Listen,
.OpenSocket = WINS_OpenSocket,
.CloseSocket = WINS_CloseSocket,
.Connect = WINS_Connect,
.CheckNewConnections = WINS_CheckNewConnections,
.Read = WINS_Read,
.Write = WINS_Write,
.Broadcast = WINS_Broadcast,
.AddrToString = WINS_AddrToString,
.GetSocketAddr = WINS_GetSocketAddr,
.GetNameFromAddr = WINS_GetNameFromAddr,
.GetAddrFromName = WINS_GetAddrFromName,
.AddrCompare = WINS_AddrCompare,
.GetSocketPort = WINS_GetSocketPort,
.SetSocketPort = WINS_SetSocketPort,
},
};
int net_numlandrivers = 1;