Пример #1
0
static int ip4mbits(const char *s, char **np) {
    /* helper routine for ip4cidr() and ip4range() */
    int bits;
    if (!digit(*s))
        return eret(np, s - 1);
    bits = d2n(*s++);
    while(digit(*s))
        if ((bits = bits * 10 + d2n(*s++)) > 32)
            return eret(np, s - 1);
    /*if (!bits) return eret(np, s - 1); allow /0 mask too */
    return cret(bits, np, s);
}
Пример #2
0
static char *parse_uint32_s(char *s, unsigned *np) {
  unsigned char *t = (unsigned char*)s;
  unsigned n = 0;
  if (!digit(*t))
    return NULL;
  do {
    if (n > 0xffffffffu / 10) return 0;
    if (n * 10 > 0xffffffffu - d2n(*t)) return 0;
    n = n * 10 + d2n(*t++);
  } while(digit(*t));
  *np = n;
  return (char*)t;
}
Пример #3
0
static char *
parse_tsp(char *s, unsigned *np, unsigned min, unsigned max, unsigned w) {
  unsigned n = 0;
  if (!digit(*s)) return NULL;
  do n = n * 10 + d2n(*s++);
  while(digit(*s) && --w);
  if (n < min || n > max) return NULL;
  if (*s == ':' || *s == '-') ++s;
  *np = n;
  return s;
}
Пример #4
0
void Node::parseAll()
{
    n();
    dn();
    d2n();
    i();
    Omega();
    omega();
    M();
    e();
    bstar();
    satelliteNumber();
    satelliteName();
    designator();
    classification();
    ephemerisType();
    elementNumber();
    revolutionNumber();
    preciseEpoch();
}
Пример #5
0
std::string Node::secondString() const
{
    std::string res = "1 ";
    res += string2string(satelliteNumber(), 5);
    const char cl = classification();
    res += (isprint(cl) ? std::string(1, cl) : " ") + " ";
    res += string2string(designator(), 8) + " ";
    res += date2string(preciseEpoch(), 14) + " ";
    res += double2string(dn(), 10, 8, false, false, false) + " ";
    res += double2string(d2n(), 8, 3, true, true, false) + " ";
    res += double2string(bstar(), 8, 3, true, true, false) + " ";
    const char eph = ephemerisType();
    res += (isprint(eph) ? std::string(1, eph) : " ") + " ";
    res += int2string(elementNumber(), 4, false);

    // Checksum
    int sum = checksum(res);
    res += int2string(sum, 1);

    return res;
}