MCPcopy Create free account
hub / github.com/Kitware/CMake / Check_IPV4_Field

Function Check_IPV4_Field

Source/CursesDialog/form/fty_ipv4.c:29–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27| FALSE - field is invalid
28+--------------------------------------------------------------------------*/
29static bool Check_IPV4_Field(FIELD * field, const void * argp)
30{
31 char *bp = field_buffer(field,0);
32 int num = 0, len;
33 unsigned int d1=256, d2=256, d3=256, d4=256;
34
35 argp=0; /* Silence unused parameter warning. */
36
37 if(isdigit((int)(*bp))) /* Must start with digit */
38 {
39 num = sscanf(bp, "%u.%u.%u.%u%n", &d1, &d2, &d3, &d4, &len);
40 if (num == 4)
41 {
42 bp += len; /* Make bp point to what sscanf() left */
43 while (*bp && isspace((int)(*bp)))
44 bp++; /* Allow trailing whitespace */
45 }
46 }
47 return ((num != 4 || *bp || d1 > 255 || d2 > 255
48 || d3 > 255 || d4 > 255) ? FALSE : TRUE);
49}
50
51/*---------------------------------------------------------------------------
52| Facility : libnform

Callers

nothing calls this directly

Calls 1

field_bufferFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…