Skip to content

Commit

Permalink
Compatibility with Ubuntu 14.04
Browse files Browse the repository at this point in the history
Added some configure checks, lifted some declarations, fixed Cython, and updated
the README to reflect the newest instructions.
  • Loading branch information
rescrv committed Aug 1, 2016
1 parent 9345e9d commit 23e1232
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ This library makes it easy to get started with using macaroons in your
service. To use the library you must first install it. You'll need to
somehow install libbsd[2]. It's packaged in some Linux distributions, and can
be installed from source on most *NIX platforms. Once you have libbsd
installed, installing macaroons is straight forward:
installed, installing macaroons is straight forward. If you're installing
from git you'll need to install autoconf, automake, libtool, and
autoconf-archive and execute the first command. if you're installing from a
release tarball, you should skip the first command and start with configure.

$ autoreconf -i # only when installing from Git
$ ./configure --enable-python-bindings
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/macaroons.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ cdef extern from "macaroons.h":
MACAROON_V2J
cdef macaroon_format MACAROON_LATEST
cdef macaroon_format MACAROON_LATEST_JSON
size_t macaroon_serialize_size_hint(const macaroon* M, macaroon_format f);
size_t macaroon_serialize_size_hint(const macaroon* M, macaroon_format f)
size_t macaroon_serialize(const macaroon* M, macaroon_format f,
char* buf, size_t buf_sz,
macaroon_returncode* err);
macaroon_returncode* err)
macaroon* macaroon_deserialize(unsigned char* data, size_t data_sz, macaroon_returncode* err)


Expand Down
12 changes: 10 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ AC_CHECK_FUNC([strlcpy],[BSDLIB=],[BSDLIB=-lbsd])
AC_SUBST([BSDLIBS], [$BSDLIB])

# Checks for header files.
AC_CHECK_HEADER([libutil.h],[AC_DEFINE([HAVE_LIBUTIL_H],[1],[Define to 1 if you have the <libutil.h> header file.])],,)
need_libbsd=yes
AC_CHECK_HEADER([libutil.h],[need_libbsd=no; AC_DEFINE([HAVE_LIBUTIL_H],[1],[Define to 1 if you have the <libutil.h> header file.])],,)
AC_CHECK_HEADER([bsd/stdlib.h],[AC_DEFINE([HAVE_BSD_STDLIB_H],[1],[Define to 1 if you have the <bsd/stdlib.h> header file.])],,)
AC_CHECK_HEADER([bsd/libutil.h],[AC_DEFINE([HAVE_BSD_LIBUTIL_H],[1],[Define to 1 if you have the <bsd/libutil.h> header file.])],,)
AC_CHECK_HEADER([util.h],[AC_DEFINE([HAVE_OSX_LIBUTIL_H],[1],[Define to 1 if you have the <util.h> header file.])],,)
AC_CHECK_HEADER([util.h],[need_libbsd=no; AC_DEFINE([HAVE_OSX_LIBUTIL_H],[1],[Define to 1 if you have the <util.h> header file.])],,)

AS_IF([test "x${need_libbsd}" = xyes],
[AC_CHECK_LIB([bsd],[strlcat],,[AC_MSG_ERROR([
-------------------------------------------------
libmacaroons relies upon the libbsd library.
Please install libbsd to continue.
-------------------------------------------------])],)],)

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
Expand Down
6 changes: 4 additions & 2 deletions macaroon-test-serialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ main(int argc, const char* argv[])
size_t line_sz = 0;
struct parsed_macaroon* macaroons = NULL;
size_t macaroons_sz = 0;
size_t i;
size_t j;

while (1)
{
Expand Down Expand Up @@ -143,9 +145,9 @@ main(int argc, const char* argv[])

int ret = EXIT_SUCCESS;

for (size_t i = 0; i < macaroons_sz; ++i)
for (i = 0; i < macaroons_sz; ++i)
{
for (size_t j = i + 1; j < macaroons_sz; ++j)
for (j = i + 1; j < macaroons_sz; ++j)
{
if (macaroon_cmp(macaroons[i].M, macaroons[j].M) != 0)
{
Expand Down
3 changes: 2 additions & 1 deletion test/varint.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ varint_verify(uint64_t value, const char* representation)
assert(sz % 2 == 0);
unsigned char buf[VARINT_MAX_SIZE];
uint64_t eulav;
unsigned int i;
assert(packvarint(value, buf) == buf + sz / 2);
assert(unpackvarint(buf, buf + VARINT_MAX_SIZE, &eulav) == buf + sz / 2);
assert(value == eulav);

for (unsigned i = 0; i < sz / 2; ++i)
for (i = 0; i < sz / 2; ++i)
{
char hex[3];
snprintf(hex, 3, "%02x", buf[i] & 0xff);
Expand Down

0 comments on commit 23e1232

Please sign in to comment.