Compile on BSDs

Use uuid_create(3) and uuid_to_string(3) to create the message id on
BSDs. Only tested on FreeBSD but should work on OpenBSD and NetBSD.

Add untested support for compiling on Solaris and Mac OS X:

* SmartOS has libuuid installed by default with rsyslog via pkgsrc

* Mac OS X has libuuid as part of libSystem:

http://lists.apple.com/archives/unix-porting/2009/Aug/msg00006.html
pull/1/head
Michael Santos 9 years ago
parent c814208bad
commit a392e836a0

@ -1,7 +1,16 @@
RM=rm
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Linux)
LDFLAGS += -luuid -lresolv
else ifeq ($(UNAME_SYS), SunOS)
LDFLAGS += -luuid -lresolv
else ifeq ($(UNAME_SYS), Darwin)
LDFLAGS += -lresolv
endif
all:
$(CC) -g -Wall $(CFLAGS) -o xmppipe src/*.c $(LDFLAGS) -lstrophe -luuid -lresolv
$(CC) -g -Wall $(CFLAGS) -o xmppipe src/*.c $(LDFLAGS) -lstrophe
static:
$(CC) -g -Wall -o xmppipe src/*.c -Wl,--no-as-needed -ldl -lz \

@ -14,9 +14,10 @@
*/
#include "xmppipe.h"
#include <resolv.h>
#include <sys/select.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <resolv.h>
extern char *__progname;

@ -21,7 +21,7 @@
#include <strophe.h>
#define XMPPIPE_VERSION "0.7.0"
#define XMPPIPE_VERSION "0.7.1"
#define XMPPIPE_STREQ(a,b) !strcmp((a),(b))
#define XMPPIPE_STRNEQ(a,b) strcmp((a),(b))

@ -14,17 +14,33 @@
*/
#include "xmppipe.h"
#if defined(__linux__)
#include <uuid/uuid.h>
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#include <uuid.h>
#endif
char *
xmppipe_id_alloc()
{
uuid_t uu = {0};
uuid_t uuid = {0};
char *out = NULL;
#if defined(__linux__) || defined(__sunos__) || (defined(__APPLE__) && defined(__MACH__))
out = xmppipe_calloc(37,1);
uuid_generate(uu);
uuid_unparse(uu, out);
uuid_generate(uuid);
uuid_unparse(uuid, out);
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
uint32_t status = 0;
uuid_create(&uuid, &status);
if (status != uuid_s_ok)
return NULL;
uuid_to_string(&uuid, &out, &status);
if (status != uuid_s_ok)
return NULL;
#endif
return out;
}

Loading…
Cancel
Save