portparse.c 280 B

1234567891011121314
  1. #include "portparse.h"
  2. int portparse(unsigned char *y,const char *x)
  3. {
  4. long long d = 0;
  5. long long j;
  6. for (j = 0;j < 5 && x[j] >= '0' && x[j] <= '9';++j)
  7. d = d * 10 + (x[j] - '0');
  8. if (j == 0) return 0;
  9. if (x[j]) return 0;
  10. y[0] = d >> 8;
  11. y[1] = d;
  12. return 1;
  13. }