Realize the remaining bits of direct rpmdb interface are dead too
[platform/upstream/rpm.git] / build / misc.c
1 /** \ingroup rpmbuild
2  * \file build/misc.c
3  */
4 #include "system.h"
5
6 #include <rpm/rpmbuild.h>
7 #include "debug.h"
8
9 uint32_t parseUnsignedNum(const char * line, uint32_t * res)
10 {
11     char * s1 = NULL;
12     unsigned long rc;
13     uint32_t result;
14
15     if (line == NULL) return 1;
16
17     while (isspace(*line)) line++;
18     if (!isdigit(*line)) return 1;
19
20     rc = strtoul(line, &s1, 10);
21
22     if (*s1 || s1 == line || rc == ULONG_MAX || rc > UINT_MAX)
23         return 1;
24
25     result = (uint32_t)rc;
26     if (res) *res = result;
27
28     return 0;
29 }