mirror of
https://github.com/pygos/pkg-utils.git
synced 2024-11-14 01:17:10 +01:00
Remove dependency on libbsd
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
parent
d94bd8ff17
commit
765c836c3d
4 changed files with 54 additions and 20 deletions
|
@ -50,10 +50,6 @@ PKG_CHECK_MODULES(XZ, [liblzma >= 5.0.0], [have_lzma="yes"], [])
|
||||||
AM_CONDITIONAL([WITH_ZLIB], [test "x$have_zlib" == "xyes"])
|
AM_CONDITIONAL([WITH_ZLIB], [test "x$have_zlib" == "xyes"])
|
||||||
AM_CONDITIONAL([WITH_LZMA], [test "x$have_lzma" == "xyes"])
|
AM_CONDITIONAL([WITH_LZMA], [test "x$have_lzma" == "xyes"])
|
||||||
|
|
||||||
AM_CONDITIONAL([HAVE_LIBBSD], [true])
|
|
||||||
PKG_CHECK_MODULES(LIBBSD, [libbsd], [],
|
|
||||||
[AC_MSG_ERROR([missing libbsd])])
|
|
||||||
|
|
||||||
##### generate output #####
|
##### generate output #####
|
||||||
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
|
@ -13,10 +13,4 @@ if WITH_ZLIB
|
||||||
pkg2sqfs_LDADD += $(ZLIB_LIBS)
|
pkg2sqfs_LDADD += $(ZLIB_LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HAVE_LIBBSD
|
|
||||||
pkg2sqfs_CPPFLAGS += -DHAVE_LIBBSD
|
|
||||||
pkg2sqfs_CFLAGS += $(LIBBSD_CFLAGS)
|
|
||||||
pkg2sqfs_LDADD += $(LIBBSD_LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
bin_PROGRAMS += pkg2sqfs
|
bin_PROGRAMS += pkg2sqfs
|
||||||
|
|
|
@ -87,16 +87,59 @@ static void print_tree(int level, node_t *n)
|
||||||
|
|
||||||
static long read_number(const char *name, const char *str, long min, long max)
|
static long read_number(const char *name, const char *str, long min, long max)
|
||||||
{
|
{
|
||||||
const char *errstr;
|
long base = 10, result = 0;
|
||||||
long result;
|
int x;
|
||||||
|
|
||||||
result = strtonum(str, min, max, &errstr);
|
if (str[0] == '0') {
|
||||||
if (errstr != NULL) {
|
if (str[1] == 'x' || str[1] == 'X') {
|
||||||
fprintf(stderr, "%s '%s': %s\n", name, str, errstr);
|
base = 16;
|
||||||
exit(EXIT_FAILURE);
|
str += 2;
|
||||||
|
} else {
|
||||||
|
base = 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isxdigit(*str))
|
||||||
|
goto fail_num;
|
||||||
|
|
||||||
|
while (isxdigit(*str)) {
|
||||||
|
x = *(str++);
|
||||||
|
|
||||||
|
if (isupper(x)) {
|
||||||
|
x = x - 'A' + 10;
|
||||||
|
} else if (islower(x)) {
|
||||||
|
x = x - 'a' + 10;
|
||||||
|
} else {
|
||||||
|
x -= '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x >= base)
|
||||||
|
goto fail_num;
|
||||||
|
|
||||||
|
if (result > (LONG_MAX - x) / base)
|
||||||
|
goto fail_ov;
|
||||||
|
|
||||||
|
result = result * base + x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result < min)
|
||||||
|
goto fail_uf;
|
||||||
|
|
||||||
|
if (result > max)
|
||||||
|
goto fail_ov;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
fail_num:
|
||||||
|
fprintf(stderr, "%s: expected numeric value > 0\n", name);
|
||||||
|
goto fail;
|
||||||
|
fail_uf:
|
||||||
|
fprintf(stderr, "%s: number to small\n", name);
|
||||||
|
goto fail;
|
||||||
|
fail_ov:
|
||||||
|
fprintf(stderr, "%s: number to large\n", name);
|
||||||
|
goto fail;
|
||||||
|
fail:
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sqfs_padd_file(sqfs_info_t *info)
|
static int sqfs_padd_file(sqfs_info_t *info)
|
||||||
|
|
|
@ -3,19 +3,20 @@
|
||||||
#define PKG2SQFS_H
|
#define PKG2SQFS_H
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <ctype.h>
|
||||||
#ifdef HAVE_LIBBSD
|
|
||||||
#include <bsd/bsd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue