Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27 lines
482 B

  1. #include "haveinline.h"
  2. static inline int fromhex(unsigned char c) {
  3. if (c>='0' && c<='9')
  4. return c-'0';
  5. else if (c>='A' && c<='F')
  6. return c-'A'+10;
  7. else if (c>='a' && c<='f')
  8. return c-'a'+10;
  9. return -1;
  10. }
  11. unsigned int scan_ip6_flat(const char *s,char ip[16])
  12. {
  13. int i;
  14. for (i=0; i<16; i++) {
  15. int tmp;
  16. tmp=fromhex(*s++);
  17. if (tmp<0) return 0;
  18. ip[i]=tmp << 4;
  19. tmp=fromhex(*s++);
  20. if (tmp<0) return 0;
  21. ip[i]+=tmp;
  22. }
  23. return 32;
  24. }