IPX95.CPP 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***************************************************************************
  19. ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * File Name : IPX95PP *
  25. * *
  26. * Programmer : Steve Tall *
  27. * *
  28. * Start Date : January 22nd, 1996 *
  29. * *
  30. * Last Update : July 10th, 1996 [ST] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Overview: *
  34. * *
  35. * Windows 95 equivelent functions from IPX.CPP *
  36. * *
  37. *-------------------------------------------------------------------------*
  38. * Functions: *
  39. * *
  40. * *
  41. * *
  42. * *
  43. * *
  44. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  45. #include "function.h"
  46. #ifdef WIN32
  47. #include "ipx95.h"
  48. /*
  49. ** Instance handle for the THIPX32 .DLL
  50. */
  51. HINSTANCE IpxDllInstance = NULL;
  52. /*
  53. ** Function pointers
  54. */
  55. //extern "C" {
  56. IPXInitialiseType IPX_Initialise = NULL;
  57. IPXGetOutstandingBuffer95Type IPX_Get_Outstanding_Buffer95 = NULL;
  58. IPXShutDown95Type IPX_Shut_Down95 = NULL;
  59. IPXSendPacket95Type IPX_Send_Packet95 = NULL;
  60. IPXBroadcastPacket95Type IPX_Broadcast_Packet95 = NULL;
  61. IPXStartListening95Type IPX_Start_Listening95 = NULL;
  62. IPXOpenSocket95Type IPX_Open_Socket95 = NULL;
  63. IPXCloseSocket95Type IPX_Close_Socket95 = NULL;
  64. IPXGetConnectionNumber95Type IPX_Get_Connection_Number95 = NULL;
  65. IPXGetLocalTarget95 IPX_Get_Local_Target95 = NULL;
  66. //}
  67. char const *FunctionNames[] = {
  68. "_IPX_Initialise",
  69. "_IPX_Get_Outstanding_Buffer95",
  70. "_IPX_Shut_Down95",
  71. "_IPX_Send_Packet95",
  72. "_IPX_Broadcast_Packet95",
  73. "_IPX_Start_Listening95",
  74. "_IPX_Open_Socket95",
  75. "_IPX_Close_Socket95",
  76. "_IPX_Get_Connection_Number95",
  77. "_IPX_Get_Local_Target95",
  78. NULL
  79. };
  80. extern void Get_OS_Version (void);
  81. bool WindowsNT = false;
  82. /***********************************************************************************************
  83. * Load_IPX_Dll -- Loads the THIPX32 DLL *
  84. * *
  85. * *
  86. * *
  87. * INPUT: Nothing *
  88. * *
  89. * OUTPUT: true if DLL loaded *
  90. * *
  91. * WARNINGS: This call will fail under NT due to a side effect of loading the THIPX32.DLL *
  92. * which causes the 16 bit DLL THIPX16.DLL to load. *
  93. * *
  94. * HISTORY: *
  95. * 4/1/97 11:40AM ST : Created *
  96. *=============================================================================================*/
  97. bool Load_IPX_Dll (void)
  98. {
  99. Get_OS_Version();
  100. if (WindowsNT) return (false);
  101. SetErrorMode( SEM_NOOPENFILEERRORBOX );
  102. IpxDllInstance = LoadLibrary ( "THIPX32.DLL" );
  103. SetErrorMode ( 0 );
  104. if ( IpxDllInstance ){
  105. const char *function_name;
  106. unsigned long *fptr = (unsigned long *) &IPX_Initialise;
  107. int count = 0;
  108. do {
  109. function_name = FunctionNames[count];
  110. if (function_name){
  111. *fptr = (unsigned long) GetProcAddress (IpxDllInstance, function_name);
  112. assert (*fptr != NULL);
  113. fptr++;
  114. count++;
  115. }
  116. } while ( function_name );
  117. return (true);
  118. }else{
  119. return (false);
  120. }
  121. }
  122. /***********************************************************************************************
  123. * Unload_IPX_Dll -- Frees the THIPX32 library *
  124. * *
  125. * *
  126. * *
  127. * INPUT: Nothing *
  128. * *
  129. * OUTPUT: Nothing *
  130. * *
  131. * WARNINGS: None *
  132. * *
  133. * HISTORY: *
  134. * 4/1/97 2:37PM ST : Created *
  135. *=============================================================================================*/
  136. void Unload_IPX_Dll (void)
  137. {
  138. if (IpxDllInstance){
  139. FreeLibrary (IpxDllInstance);
  140. IpxDllInstance = NULL;
  141. }
  142. }
  143. int IPX_Open_Socket(unsigned short socket)
  144. {
  145. return ( IPX_Open_Socket95((int)socket));
  146. }
  147. int IPX_Close_Socket(unsigned short socket)
  148. {
  149. IPX_Close_Socket95((int)socket);
  150. return (0);
  151. }
  152. int IPX_Get_Connection_Number(void)
  153. {
  154. return (IPX_Get_Connection_Number95());
  155. }
  156. int IPX_Broadcast_Packet(unsigned char * buf, int buflen)
  157. {
  158. return(IPX_Broadcast_Packet95(buf, buflen));
  159. }
  160. extern "C"{
  161. extern void __cdecl Int3(void);
  162. }
  163. int IPX_Get_Local_Target(unsigned char * dest_network, unsigned char * dest_node,
  164. unsigned short dest_socket, unsigned char * bridge_address)
  165. {
  166. //Int3();
  167. return (IPX_Get_Local_Target95(dest_network, dest_node, dest_socket, bridge_address));
  168. }
  169. #endif //WIN32