mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-07 02:47:20 +02:00
Fix uuid on FreeBSD
In FreeBSD, just as in DARWIN, uuid functions are in libc and no external libuuid is required. The API is quite different from Linux's though, so a different implementation of uuid () (util.cpp) is needed.
This commit is contained in:
parent
05afa911d3
commit
da7cc6eed7
3 changed files with 31 additions and 4 deletions
|
@ -90,10 +90,10 @@ check_struct_has_member ("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF)
|
||||||
check_struct_has_member ("struct stat" st_birthtime "sys/types.h;sys/stat.h" HAVE_ST_BIRTHTIME)
|
check_struct_has_member ("struct stat" st_birthtime "sys/types.h;sys/stat.h" HAVE_ST_BIRTHTIME)
|
||||||
|
|
||||||
message ("-- Looking for libuuid")
|
message ("-- Looking for libuuid")
|
||||||
if (DARWIN)
|
if (DARWIN OR FREEBSD)
|
||||||
# Apple includes the uuid functions in their libc, rather than libuuid
|
# Apple and FreeBSD include the uuid functions in their libc, rather than libuuid
|
||||||
check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
|
check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
|
||||||
else (DARWIN)
|
else (DARWIN OR FREEBSD)
|
||||||
find_path (UUID_INCLUDE_DIR uuid/uuid.h)
|
find_path (UUID_INCLUDE_DIR uuid/uuid.h)
|
||||||
find_library (UUID_LIBRARY NAMES uuid)
|
find_library (UUID_LIBRARY NAMES uuid)
|
||||||
if (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
if (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
||||||
|
@ -106,7 +106,7 @@ else (DARWIN)
|
||||||
else (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
else (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
||||||
message (FATAL_ERROR "-- libuuid not found.")
|
message (FATAL_ERROR "-- libuuid not found.")
|
||||||
endif (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
endif (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
||||||
endif (DARWIN)
|
endif (DARWIN OR FREEBSD)
|
||||||
|
|
||||||
if (HAVE_UUID_UNPARSE_LOWER)
|
if (HAVE_UUID_UNPARSE_LOWER)
|
||||||
message ("-- Found libuuid")
|
message ("-- Found libuuid")
|
||||||
|
|
23
src/util.cpp
23
src/util.cpp
|
@ -229,6 +229,28 @@ int autoComplete (
|
||||||
return matches.size ();
|
return matches.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle the generation of UUIDs on FreeBSD in a separate implementation
|
||||||
|
// of the uuid () function, since the API is quite different from Linux's.
|
||||||
|
// Also, uuid_unparse_lower is not needed on FreeBSD, because the string
|
||||||
|
// representation is always lowercase anyway.
|
||||||
|
// For the implementation details, refer to
|
||||||
|
// http://svnweb.freebsd.org/base/head/sys/kern/kern_uuid.c
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
const std::string uuid ()
|
||||||
|
{
|
||||||
|
uuid_t id;
|
||||||
|
uint32_t status;
|
||||||
|
char *buffer (0);
|
||||||
|
uuid_create (&id, &status);
|
||||||
|
uuid_to_string (&id, &buffer, &status);
|
||||||
|
|
||||||
|
std::string res (buffer);
|
||||||
|
free (buffer);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef HAVE_UUID_UNPARSE_LOWER
|
#ifndef HAVE_UUID_UNPARSE_LOWER
|
||||||
// Older versions of libuuid don't have uuid_unparse_lower(), only uuid_unparse()
|
// Older versions of libuuid don't have uuid_unparse_lower(), only uuid_unparse()
|
||||||
|
@ -253,6 +275,7 @@ const std::string uuid ()
|
||||||
|
|
||||||
return std::string (buffer);
|
return std::string (buffer);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// On Solaris no flock function exists.
|
// On Solaris no flock function exists.
|
||||||
|
|
|
@ -32,7 +32,11 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <uuid.h>
|
||||||
|
#else
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
|
#endif
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
|
|
||||||
// util.cpp
|
// util.cpp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue