1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-11-24 21:40:43 +01:00

Remove dependency on libbsd

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-04-17 17:13:09 +02:00
parent d94bd8ff17
commit 765c836c3d
4 changed files with 54 additions and 20 deletions

View file

@ -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_LZMA], [test "x$have_lzma" == "xyes"])
AM_CONDITIONAL([HAVE_LIBBSD], [true])
PKG_CHECK_MODULES(LIBBSD, [libbsd], [],
[AC_MSG_ERROR([missing libbsd])])
##### generate output #####
AC_CONFIG_HEADERS([config.h])

View file

@ -13,10 +13,4 @@ if WITH_ZLIB
pkg2sqfs_LDADD += $(ZLIB_LIBS)
endif
if HAVE_LIBBSD
pkg2sqfs_CPPFLAGS += -DHAVE_LIBBSD
pkg2sqfs_CFLAGS += $(LIBBSD_CFLAGS)
pkg2sqfs_LDADD += $(LIBBSD_LIBS)
endif
bin_PROGRAMS += pkg2sqfs

View file

@ -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)
{
const char *errstr;
long result;
long base = 10, result = 0;
int x;
result = strtonum(str, min, max, &errstr);
if (errstr != NULL) {
fprintf(stderr, "%s '%s': %s\n", name, str, errstr);
exit(EXIT_FAILURE);
if (str[0] == '0') {
if (str[1] == 'x' || str[1] == 'X') {
base = 16;
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;
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)

View file

@ -3,19 +3,20 @@
#define PKG2SQFS_H
#include <sys/types.h>
#include <sys/stat.h>
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
#include <stdint.h>
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#ifdef HAVE_LIBBSD
#include <bsd/bsd.h>
#endif
#include <ctype.h>
#include "util/util.h"