home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / netadd.exe / NETADDR.C < prev    next >
Text File  |  1995-01-07  |  5KB  |  132 lines

  1. /****************************************************************************
  2. **      DISCLAIMER  
  3. **  
  4. **   Novell, Inc. makes no representations or warranties with respect to
  5. **   any NetWare software, and specifically disclaims any express or
  6. **   implied warranties of merchantability, title, or fitness for a
  7. **   particular purpose.  
  8. **
  9. **   Distribution of any NetWare software is forbidden without the
  10. **   express written consent of Novell, Inc.  Further, Novell reserves
  11. **   the right to discontinue distribution of any NetWare software.
  12. **   
  13. **   Novell is not responsible for lost profits or revenue, loss of use
  14. **   of the software, loss of data, costs of re-creating lost data, the
  15. **   cost of any substitute equipment or program, or claims by any party
  16. **   other than you.  Novell strongly recommends a backup be made before
  17. **   any software is installed.   Technical support for this software
  18. **   may be provided at the discretion of Novell.
  19. ****************************************************************************
  20. **
  21. **   File:   NETADDR.C
  22. **
  23. **   Desc: Program that allows a user to get the internet address i.e. 
  24. **         network and node address of the workstation the program is run on.
  25. **        
  26. **
  27. **   Parameter descriptions:    > input
  28. **                              < output
  29. **
  30. **   Programmers:
  31. **   Ini   Who         Firm
  32. **   ------------------------------------------------------------------
  33. **   ARM   A. Ray Maxwell     Novell Developer Support.
  34. **
  35. **   History:
  36. **       
  37. **   ------------------------------------------------------------------
  38. **   10-07-94   ARM   First code.
  39. */
  40.  
  41. /****************************************************************************
  42. ** Include Headers, Macros & function Prototypes.
  43. */
  44.    /*-------------------------------------------------------------------
  45.    ** Borland C.
  46.    */
  47.    #include <stdio.h>
  48.    #include <stdlib.h>
  49.    #include <string.h>
  50.    #include <conio.h>
  51.  
  52.    #define RETURN '\r'
  53.  
  54.    /*-------------------------------------------------------------------
  55.    ** NetWare API's
  56.    */
  57.    #define NWDOS
  58.    #include <nwcalls.h>
  59.  
  60.  
  61.    typedef struct{
  62.       BYTE network[4];
  63.       BYTE node[6];
  64.       WORD socket;
  65.    }NETWORK_ADDRESS;
  66.  
  67.  
  68. /****************************************************************************
  69. ** Program start.
  70. */
  71. void main(void)
  72. {
  73.    NWCONN_HANDLE   connHandle;
  74.    CONNECT_INFO    connInfo;
  75.    NWCONN_NUM      connNumber;
  76.    NWCCODE         ccode;
  77.    NETWORK_ADDRESS netAdd;
  78.    char            server[50];
  79.  
  80.  
  81.  
  82.  
  83.    ccode = NWCallsInit(NULL, NULL);
  84.  
  85.    if(ccode){
  86.      printf("ERROR: NWCallsInit failed %X\n",ccode);
  87.       exit(1);
  88.   }
  89.  
  90.    ccode = NWGetDefaultConnectionID(
  91.            /* < connection Handle */ &connHandle);
  92.  
  93.    if(ccode){
  94.      printf("ERROR: NWGetConnectionHandle failed %X\n",ccode);
  95.       exit(1);
  96.   }
  97.  
  98.   ccode = NWGetConnectionNumber(
  99.           /* > NWCONN_HANDLE   */ connHandle,
  100.           /* < NWCONN_NUM      */ &connNumber);
  101.    if(ccode){
  102.      printf("ERROR: NWGetConnectionNumber failed %X\n",ccode);
  103.       exit(1);
  104.   }
  105.  
  106.   ccode = NWGetInternetAddress(
  107.           /* > NWCONN_HANDLE   */ connHandle,
  108.           /* > NWCONN_NUM      */ connNumber,
  109.           /* < NWNET_ADDR      */ (BYTE *) &netAdd);
  110.    if(ccode){
  111.      printf("ERROR: NWGetInternetAddress failed %X\n",ccode);
  112.       exit(1);
  113.  
  114.   }
  115.  
  116.   printf("Network Address= %02X%02X%02X%02X\n",netAdd.network[0],
  117.                                                netAdd.network[1],
  118.                                                netAdd.network[2],
  119.                                                netAdd.network[3]);
  120.  
  121.   printf("Node Address= %02X%02X%02X%02X%02X%02X\n", netAdd.node[0],
  122.                                                     netAdd.node[1],
  123.                                                     netAdd.node[2],
  124.                                                     netAdd.node[3],
  125.                                                     netAdd.node[4],
  126.                                                     netAdd.node[5]);
  127.  
  128.  
  129. }
  130.                                                                                                                                                                                                                                                
  131.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  132.