File: portparse.c

package info (click to toggle)
dq 20250201-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,408 kB
  • sloc: ansic: 13,644; python: 651; makefile: 382; sh: 336
file content (16 lines) | stat: -rw-r--r-- 328 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "portparse.h"

int portparse(unsigned char *y,const char *x)
{
  long long d = 0;
  long long j;
  if (!x) return 0; 
  for (j = 0;j < 5 && x[j] >= '0' && x[j] <= '9';++j)
    d = d * 10 + (x[j] - '0');
  if (j == 0) return 0;
  if (x[j]) return 0;
  if (d > 65535) return 0;
  y[0] = d >> 8;
  y[1] = d;
  return 1;
}