home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / toolkit / tcpiptk / sampdll / sampdll.c < prev    next >
Text File  |  1996-11-19  |  3KB  |  64 lines

  1. /********************************************************copyrite.xic********/
  2. /*                                                                          */
  3. /*   Licensed Materials - Property of IBM                                   */
  4. /*   IBM TCP/IP for OS/2                                                    */
  5. /*   (C) Copyright IBM Corporation. 1990,1996.                              */
  6. /*                                                                          */
  7. /*   All rights reserved.                                                   */
  8. /*                                                                          */
  9. /*   US Government Users Restricted Rights -                                */
  10. /*   Use, duplication or disclosure restricted by GSA ADP Schedule          */
  11. /*   Contract with IBM Corp.                                                */
  12. /*                                                                          */
  13. /*--------------------------------------------------------------------------*/
  14. /*                                                                          */
  15. /*  DISCLAIMER OF WARRANTIES.  The following [enclosed] code is             */
  16. /*  sample code created by IBM Corporation. This sample code is not         */
  17. /*  part of any standard or IBM product and is provided to you solely       */
  18. /*  for  the purpose of assisting you in the development of your            */
  19. /*  applications.  The code is provided "AS IS", without                    */
  20. /*  warranty of any kind.  IBM shall not be liable for any damages          */
  21. /*  arising out of your use of the sample code, even if they have been      */
  22. /*  advised of the possibility of such damages.                             */
  23. /*--------------------------------------------------------------------------*/
  24. /* Modification History:
  25. **  Date:    By:  Tag:    Reason:
  26. **  9/23/96  DRC  DRC01   Rearranged include files to preserve defs
  27. **  9/30/96  DRC  DRC02   removed unreferenced variable
  28. */
  29.  
  30. /*
  31.  * Include Files.
  32.  */
  33. #include <netdb.h>            /* DRC01 - rearranged order of included files*/
  34. #include <stdio.h>            /* DRC01 - rearranged order of included files*/
  35. #include <stdlib.h>           /* DRC01 - rearranged order of included files*/
  36. #include <types.h>
  37. #include <netinet\in.h>
  38. #include <sys\socket.h>
  39.  
  40. char * s_gethostbyname(char * name)
  41. {
  42.     struct hostent *hp;    /* server host name information             */
  43.     struct in_addr in;
  44.  
  45.     /*
  46.      * Initialize with sockets.
  47.      */
  48.     sock_init();
  49.  
  50.     /*
  51.      */
  52.     hp = gethostbyname(name);
  53.     if (hp) {
  54.              bcopy(hp->h_addr, (caddr_t)&in.s_addr,hp->h_length);
  55.     } else {
  56.              /* return appropriate error code to calling application */
  57.              exit(1);
  58.     }
  59.  
  60.     return(inet_ntoa(in));
  61.  
  62. }
  63.  
  64.