mirror of
https://github.com/msantos/xmppipe
synced 2024-11-13 13:10:32 +00:00
Merge branch 'pasis-uuid'
This commit is contained in:
commit
a6b81e9fbb
7
Makefile
7
Makefile
@ -5,7 +5,7 @@ RM=rm
|
||||
|
||||
UNAME_SYS := $(shell uname -s)
|
||||
ifeq ($(UNAME_SYS), Linux)
|
||||
LDFLAGS += -luuid -lresolv -Wl,-Bsymbolic-functions -Wl,-z,relro
|
||||
LDFLAGS += -lresolv -Wl,-Bsymbolic-functions -Wl,-z,relro
|
||||
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O2 -fstack-protector \
|
||||
--param=ssp-buffer-size=4 -Wformat -Werror=format-security \
|
||||
-fno-strict-aliasing
|
||||
@ -24,7 +24,7 @@ else ifeq ($(UNAME_SYS), OpenBSD)
|
||||
--param=ssp-buffer-size=4 -Wformat -Werror=format-security \
|
||||
-fno-strict-aliasing
|
||||
else ifeq ($(UNAME_SYS), SunOS)
|
||||
LDFLAGS += -luuid -lresolv
|
||||
LDFLAGS += -lresolv
|
||||
else ifeq ($(UNAME_SYS), Darwin)
|
||||
LDFLAGS += -lresolv
|
||||
endif
|
||||
@ -50,8 +50,7 @@ static:
|
||||
/usr/local/lib/libstrophe.a \
|
||||
/usr/lib/*/libssl.a \
|
||||
/usr/lib/*/libcrypto.a \
|
||||
/usr/lib/*/libexpat.a \
|
||||
/usr/lib/*/libuuid.a
|
||||
/usr/lib/*/libexpat.a
|
||||
|
||||
clean:
|
||||
-@$(RM) $(PROG)
|
||||
|
@ -27,12 +27,6 @@ Requirements
|
||||
|
||||
* [libstrophe](https://github.com/strophe/libstrophe)
|
||||
|
||||
* Linux: libuuid
|
||||
|
||||
~~~
|
||||
apt-get install uuid-dev
|
||||
~~~
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ xmppipe_send_message(xmppipe_state_t *state, char *to, char *type, char *buf,
|
||||
xmpp_stanza_t *text = NULL;
|
||||
char *id = NULL;
|
||||
|
||||
id = xmppipe_id_alloc();
|
||||
id = xmpp_uuid_gen(state->ctx);
|
||||
|
||||
if (id == NULL) {
|
||||
errx(EXIT_FAILURE, "unable to allocate message id");
|
||||
@ -1168,7 +1168,7 @@ xmppipe_send_message(xmppipe_state_t *state, char *to, char *type, char *buf,
|
||||
|
||||
xmppipe_send(state, message);
|
||||
(void)xmpp_stanza_release(message);
|
||||
free(id);
|
||||
xmpp_free(state->ctx, id);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -96,7 +96,6 @@ typedef struct {
|
||||
int xmppipe_fmt_init();
|
||||
char *xmppipe_fmt(const char *);
|
||||
char *xmppipe_nfmt(const char *, size_t);
|
||||
char *xmppipe_id_alloc();
|
||||
int xmppipe_set_nonblock(int fd);
|
||||
|
||||
char *xmppipe_servername(char *);
|
||||
|
@ -1,46 +0,0 @@
|
||||
/* Copyright (c) 2015, Michael Santos <michael.santos@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "xmppipe.h"
|
||||
|
||||
#if defined(__linux__) || defined(__sunos__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#include <uuid/uuid.h>
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
#include <uuid.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
xmppipe_id_alloc()
|
||||
{
|
||||
uuid_t uuid = {0};
|
||||
char *out = NULL;
|
||||
|
||||
#if defined(__linux__) || defined(__sunos__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
out = xmppipe_calloc(37,1);
|
||||
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…
Reference in New Issue
Block a user