--------------------------------------------------------------------------- | Facility : libnform | Function : static bool Check_Integer_Field( | FIELD * field, | const void * argp) | | Description : Validate buffer content to be a valid integer value | | Return Values
| 90 | | FALSE - field is invalid |
| 91 | +--------------------------------------------------------------------------*/ |
| 92 | static bool Check_Integer_Field(FIELD * field, const void * argp) |
| 93 | { |
| 94 | const integerARG *argi = (const integerARG *)argp; |
| 95 | long low = argi->low; |
| 96 | long high = argi->high; |
| 97 | int prec = argi->precision; |
| 98 | unsigned char *bp = (unsigned char *)field_buffer(field,0); |
| 99 | char *s = (char *)bp; |
| 100 | long val; |
| 101 | char buf[100]; |
| 102 | |
| 103 | while( *bp && *bp==' ') bp++; |
| 104 | if (*bp) |
| 105 | { |
| 106 | if (*bp=='-') bp++; |
| 107 | while (*bp) |
| 108 | { |
| 109 | if (!isdigit(*bp)) break; |
| 110 | bp++; |
| 111 | } |
| 112 | while(*bp && *bp==' ') bp++; |
| 113 | if (*bp=='\0') |
| 114 | { |
| 115 | val = atol(s); |
| 116 | if (low<high) |
| 117 | { |
| 118 | if (val<low || val>high) return FALSE; |
| 119 | } |
| 120 | snprintf(buf,sizeof(buf),"%.*ld",(prec>0?prec:0),val); |
| 121 | set_field_buffer(field,0,buf); |
| 122 | return TRUE; |
| 123 | } |
| 124 | } |
| 125 | return FALSE; |
| 126 | } |
| 127 | |
| 128 | /*--------------------------------------------------------------------------- |
| 129 | | Facility : libnform |
nothing calls this directly
no test coverage detected
searching dependent graphs…