home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / netlib / Net_StringToAddr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.9 KB  |  77 lines

  1. /* 
  2.  * Net_StringToAddr.c --
  3.  *
  4.  *    Convert a string to an address.
  5.  *
  6.  * Copyright 1987 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/lib/c/netlib/RCS/Net_StringToAddr.c,v 1.5 92/06/09 20:53:05 jhh Exp $ SPRITE (Berkeley)";
  19. #endif not lint
  20.  
  21.  
  22. #include "sprite.h"
  23. #include "net.h"
  24.  
  25.  
  26.  
  27. /*
  28.  *----------------------------------------------------------------------
  29.  *
  30.  * Net_StringToAddr --
  31.  *
  32.  *    This routine takes a string form of a network address and
  33.  *    converts it to the Net_Address form. The string must be
  34.  *    null-terminated.
  35.  *
  36.  * Results:
  37.  *    Standard Sprite return status.
  38.  *
  39.  * Side effects:
  40.  *    None.
  41.  *
  42.  *----------------------------------------------------------------------
  43.  */
  44.  
  45. ReturnStatus
  46. Net_StringToAddr(buffer, type, addressPtr)
  47.     register char     *buffer;
  48.     Net_AddressType    type;
  49.     Net_Address     *addressPtr;
  50. {
  51.     ReturnStatus    status = SUCCESS;
  52.     int            addr[10];
  53.  
  54.     switch(type) {
  55.     case NET_ADDRESS_ETHER : {
  56.         Net_StringToEtherAddr(buffer, (Net_EtherAddress *) addr);
  57.         break;
  58.     }
  59.     case NET_ADDRESS_ULTRA: {
  60.         Net_StringToUltraAddr(buffer, (Net_UltraAddress *) addr);
  61.         break;
  62.     }
  63.     case NET_ADDRESS_FDDI: {
  64.         Net_StringToFDDIAddr(buffer, (Net_FDDIAddress *) addr);
  65.         break;
  66.     }
  67.     case NET_ADDRESS_INET : {
  68.         addr[0] = Net_StringToInetAddr(buffer);
  69.         break;
  70.     }
  71.     default:
  72.         return FAILURE;
  73.     }
  74.     status = Net_SetAddress(type, (Address) addr, addressPtr); 
  75.     return status;
  76. }
  77.