home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_02 / 2n02048a < prev    next >
Text File  |  1990-12-30  |  2KB  |  57 lines

  1.  
  2. #include        <dos.h>
  3. #include        "netbios.h"
  4.  
  5. /************************************************************
  6. * init_netbios - test NetBIOS presence & register application
  7. * Parameters: name (in) - application name for network use
  8. * Returns: Name table number if successful, else:
  9. *           NO_NETBIOS  if NetBIOS not installed or 
  10. *                       adapter failure
  11. *          INVALID_NAME if name is already in use or 
  12. *                      invalid
  13. * Notes: The name table number is required for datagram 
  14. *        support but not for connection oriented support.
  15. *        Application names longer than 15 characters are 
  16. *        truncated. The first three characters of the name 
  17. *        should not be "IBM".
  18. * History: Original code by William H. Roetzheim
  19. ************************************************************/
  20.  
  21. unsigned int init_netbios(char *name)
  22. {
  23.    int i;
  24.    unsigned long   int_vector;
  25.    struct net_control_block    ncb;
  26.  
  27.    /***** start by testing for NetBIOS installation *****/
  28.    /* is interrupt vector initialized? */
  29.    int_vector = (unsigned long) getvect(0x5C);
  30.    if ((int_vector == 0x0000) || (int_vector == 0xF000))
  31.    {
  32.         /* no interrupt handler installed */
  33.         return NO_NETBIOS;
  34.    }
  35.    /* is NetBIOS responding? */
  36.    init_ncb(&ncb);
  37.    ncb.command = 0xFF;       /* an invalid command */
  38.    int_netbios(&ncb);
  39.    if (ncb.retcode != 0x03)  /* error, invalid command */
  40.    {
  41.       return NO_NETBIOS;
  42.    }
  43.    /* now attempt to register name on network */
  44.    init_ncb(&ncb);
  45.    for (i = 0; i < 15; i++)
  46.    {
  47.        if (name[i] == 0) break;
  48.        ncb.l_name[i] = name[i++];
  49.    }
  50.    ncb.command = NCB_ADD_NAME;
  51.    if (ncb.retcode != 00) return INVALID_NAME;
  52.    else return ncb.number;
  53. }
  54.  
  55.  
  56.  
  57.