_sock_ipattr.c 577 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* posix */
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #include <ctype.h>
  5. /* bsd extensions */
  6. #include <sys/uio.h>
  7. #include <sys/socket.h>
  8. #include <netinet/in.h>
  9. #include "priv.h"
  10. /*
  11. * return ndb attribute type of an ip name
  12. */
  13. int
  14. _sock_ipattr(char *name)
  15. {
  16. char *p;
  17. int dot = 0;
  18. int alpha = 0;
  19. for(p = name; *p; p++){
  20. if(isdigit(*p))
  21. ;
  22. else if(isalpha(*p) || *p == '-')
  23. alpha = 1;
  24. else if(*p == '.')
  25. dot = 1;
  26. else
  27. return Tsys;
  28. }
  29. if(alpha){
  30. if(dot)
  31. return Tdom;
  32. else
  33. return Tsys;
  34. }
  35. if(dot)
  36. return Tip;
  37. else
  38. return Tsys;
  39. }