home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / bin / p205.zip / exesrc / tcpipapi.c < prev    next >
C/C++ Source or Header  |  1994-12-18  |  2KB  |  63 lines

  1. /*****************************************************************************/
  2. /*           Copyright (c) 1994 by Jyrki Salmi <jytasa@jyu.fi>             */
  3. /*        You may modify, recompile and distribute this file freely.         */
  4. /*****************************************************************************/
  5.  
  6. /*
  7.    Routines that load TCP/IP's socket library and get the address of
  8.    psock_errno() entry function that is used get information about the
  9.    error occurred in the TCP/IP API.
  10.  
  11.    Reasons for not using an import library:
  12.  
  13.    (1) People without TCP/IP can still use the program. No attempt to use 
  14.        the TCP/IP API is made if the device type is something else than
  15.        socket.
  16.  
  17.    (2) Program can be recompiled without the TCP/IP programmers toolkit.
  18. */
  19.  
  20. #include <stdio.h>
  21. #define INCL_DOSMODULEMGR
  22. #include <os2.h>
  23. #include "p.h"
  24. #include "tcpipapi.h"
  25. #include "error.h"
  26. #include "modules.h"
  27.  
  28. static HMODULE dll_handle;
  29. void (* _System psock_errno)(U8 *) = NULL;
  30.  
  31. void load_tcpip(void) {
  32.  
  33.   APIRET rc;
  34.  
  35.   rc = DosLoadModule(NULL, 0L, "SO32DLL", &dll_handle);
  36.   if (rc)
  37.     os2_error(P_ERROR_DOSLOADMODULE, rc,
  38.           MODULE_TCPIP, __LINE__,
  39.           "SO32DLL");
  40.  
  41.   /* Query the address of psock_errno() entry function */
  42.  
  43.   rc = DosQueryProcAddr(dll_handle,
  44.             0,
  45.             "PSOCK_ERRNO",
  46.             (PFN *)&psock_errno);
  47.   if (rc)
  48.     os2_error(P_ERROR_DOSQUERYPROCADDR, rc,
  49.         MODULE_TCPIP, __LINE__,
  50.         "PSOCK_ERRNO");
  51. }
  52.  
  53. void unload_tcpip(void) {
  54.  
  55.   APIRET rc;
  56.  
  57.   rc = DosFreeModule(dll_handle);
  58.   if (rc)
  59.     os2_error(P_ERROR_DOSFREEMODULE, rc,
  60.         MODULE_TCPIP, __LINE__,
  61.         "SO32DLL");
  62. }
  63.