You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bq...@apache.org on 2017/11/16 21:15:35 UTC

[05/42] nifi-minifi-cpp git commit: MINIFICPP-274: PutKafka Processor

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdposix.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdposix.h b/thirdparty/librdkafka-0.11.1/src/rdposix.h
new file mode 100644
index 0000000..72f9814
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdposix.h
@@ -0,0 +1,182 @@
+#pragma once
+/*
+* librdkafka - Apache Kafka C library
+*
+* Copyright (c) 2012-2015 Magnus Edenhill
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice,
+*    this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+*    this list of conditions and the following disclaimer in the documentation
+*    and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * POSIX system support
+ */
+#pragma once
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <inttypes.h>
+#include <fcntl.h>
+#include <errno.h>
+
+/**
+* Types
+*/
+
+
+/**
+ * Annotations, attributes, optimizers
+ */
+#ifndef likely
+#define likely(x)   __builtin_expect((x),1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect((x),0)
+#endif
+
+#define RD_UNUSED   __attribute__((unused))
+#define RD_INLINE   inline
+#define RD_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#define RD_NORETURN __attribute__((noreturn))
+#define RD_IS_CONSTANT(p)  __builtin_constant_p((p))
+#define RD_TLS      __thread
+
+/**
+* Allocation
+*/
+#if !defined(__FreeBSD__)
+/* alloca(3) is in stdlib on FreeBSD */
+#include <alloca.h>
+#endif
+
+#define rd_alloca(N)  alloca(N)
+
+
+/**
+* Strings, formatting, printf, ..
+*/
+
+/* size_t and ssize_t format strings */
+#define PRIusz  "zu"
+#define PRIdsz  "zd"
+
+#define RD_FORMAT(...) __attribute__((format (__VA_ARGS__)))
+#define rd_snprintf(...)  snprintf(__VA_ARGS__)
+#define rd_vsnprintf(...) vsnprintf(__VA_ARGS__)
+
+#define rd_strcasecmp(A,B) strcasecmp(A,B)
+#define rd_strncasecmp(A,B,N) strncasecmp(A,B,N)
+
+/**
+ * Errors
+ */
+#if HAVE_STRERROR_R
+static RD_INLINE RD_UNUSED const char *rd_strerror(int err) {
+        static RD_TLS char ret[128];
+
+#if defined(__linux__) && defined(_GNU_SOURCE)
+        return strerror_r(err, ret, sizeof(ret));
+#else /* XSI version */
+        int r;
+        /* The r assignment is to catch the case where
+         * _GNU_SOURCE is not defined but the GNU version is
+         * picked up anyway. */
+        r = strerror_r(err, ret, sizeof(ret));
+        if (unlikely(r))
+                rd_snprintf(ret, sizeof(ret),
+                            "strerror_r(%d) failed (ret %d)", err, r);
+        return ret;
+#endif
+}
+#else
+#define rd_strerror(err) strerror(err)
+#endif
+
+
+/**
+ * Atomics
+ */
+#include "rdatomic.h"
+
+/**
+* Misc
+*/
+
+/**
+ * Microsecond sleep.
+ * Will retry on signal interrupt unless *terminate is true.
+ */
+static RD_INLINE RD_UNUSED
+void rd_usleep (int usec, rd_atomic32_t *terminate) {
+        struct timespec req = {usec / 1000000, (long)(usec % 1000000) * 1000};
+
+        /* Retry until complete (issue #272), unless terminating. */
+        while (nanosleep(&req, &req) == -1 &&
+               (errno == EINTR && (!terminate || !rd_atomic32_get(terminate))))
+                ;
+}
+
+
+
+
+#define rd_gettimeofday(tv,tz)  gettimeofday(tv,tz)
+
+
+#define rd_assert(EXPR)  assert(EXPR)
+
+/**
+ * Empty struct initializer
+ */
+#define RD_ZERO_INIT  {}
+
+/**
+ * Sockets, IO
+ */
+
+/**
+ * @brief Set socket to non-blocking
+ * @returns 0 on success or errno on failure.
+ */
+static RD_UNUSED int rd_fd_set_nonblocking (int fd) {
+        int fl = fcntl(fd, F_GETFL, 0);
+        if (fl == -1 ||
+            fcntl(fd, F_SETFL, fl | O_NONBLOCK) == -1)
+                return errno;
+        return 0;
+}
+
+/**
+ * @brief Create non-blocking pipe
+ * @returns 0 on success or errno on failure
+ */
+static RD_UNUSED int rd_pipe_nonblocking (int *fds) {
+        if (pipe(fds) == -1 ||
+            rd_fd_set_nonblocking(fds[0]) == -1 ||
+            rd_fd_set_nonblocking(fds[1]))
+                return errno;
+        return 0;
+}
+#define rd_pipe(fds) pipe(fds)
+#define rd_read(fd,buf,sz) read(fd,buf,sz)
+#define rd_write(fd,buf,sz) write(fd,buf,sz)
+#define rd_close(fd) close(fd)

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdrand.c
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdrand.c b/thirdparty/librdkafka-0.11.1/src/rdrand.c
new file mode 100644
index 0000000..31c087d
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdrand.c
@@ -0,0 +1,50 @@
+/*
+ * librd - Rapid Development C library
+ *
+ * Copyright (c) 2012, Magnus Edenhill
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "rd.h"
+#include "rdrand.h"
+
+
+
+void rd_array_shuffle (void *base, size_t nmemb, size_t entry_size) {
+	int i;
+	void *tmp = rd_alloca(entry_size);
+
+	/* FIXME: Optimized version for word-sized entries. */
+
+	for (i = (int) nmemb - 1 ; i > 0 ; i--) {
+		int j = rd_jitter(0, i);
+		if (unlikely(i == j))
+			continue;
+
+		memcpy(tmp, (char *)base + (i*entry_size), entry_size);
+		memcpy((char *)base+(i*entry_size),
+		       (char *)base+(j*entry_size), entry_size);
+		memcpy((char *)base+(j*entry_size), tmp, entry_size);
+	}
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdrand.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdrand.h b/thirdparty/librdkafka-0.11.1/src/rdrand.h
new file mode 100644
index 0000000..21b1e21
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdrand.h
@@ -0,0 +1,45 @@
+/*
+ * librd - Rapid Development C library
+ *
+ * Copyright (c) 2012, Magnus Edenhill
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+
+/**
+ * Returns a random (using rand(3)) number between 'low'..'high' (inclusive).
+ */
+static RD_INLINE int rd_jitter (int low, int high) RD_UNUSED;
+static RD_INLINE int rd_jitter (int low, int high) {
+	return (low + (rand() % ((high-low)+1)));
+	
+}
+
+
+/**
+ * Shuffles (randomizes) an array using the modern Fisher-Yates algorithm.
+ */
+void rd_array_shuffle (void *base, size_t nmemb, size_t entry_size);

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdregex.c
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdregex.c b/thirdparty/librdkafka-0.11.1/src/rdregex.c
new file mode 100644
index 0000000..f9b2bac
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdregex.c
@@ -0,0 +1,157 @@
+/*
+ * librdkafka - The Apache Kafka C/C++ library
+ *
+ * Copyright (c) 2016 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "rd.h"
+#include "rdregex.h"
+
+#if HAVE_REGEX
+#include <regex.h>
+struct rd_regex_s {
+	regex_t re;
+};
+
+#else
+
+#include "regexp.h"
+struct rd_regex_s {
+	Reprog *re;
+};
+#endif
+
+
+/**
+ * @brief Destroy compiled regex
+ */
+void rd_regex_destroy (rd_regex_t *re) {
+#if HAVE_REGEX
+	regfree(&re->re);
+#else
+	re_regfree(re->re);
+#endif
+	rd_free(re);
+}
+
+
+/**
+ * @brief Compile regex \p pattern
+ * @returns Compiled regex object on success on error.
+ */
+rd_regex_t *
+rd_regex_comp (const char *pattern, char *errstr, size_t errstr_size) {
+	rd_regex_t *re = rd_calloc(1, sizeof(*re));
+#if HAVE_REGEX
+	int r;
+
+	r = regcomp(&re->re, pattern, REG_EXTENDED|REG_NOSUB);
+	if (r) {
+		if (errstr)
+			regerror(r, &re->re, errstr, errstr_size);
+		rd_free(re);
+		return NULL;
+	}
+#else
+	const char *errstr2;
+
+	re->re = re_regcomp(pattern, 0, &errstr2);
+	if (!re->re) {
+		if (errstr) {
+			strncpy(errstr, errstr2, errstr_size-1);
+			errstr[errstr_size-1] = '\0';
+		}
+		rd_free(re);
+		return NULL;
+	}
+#endif
+
+	return re;
+}
+
+
+/**
+ * @brief Match \p str to pre-compiled regex \p re
+ * @returns 1 on match, else 0
+ */
+int rd_regex_exec (rd_regex_t *re, const char *str) {
+#if HAVE_REGEX
+	return regexec(&re->re, str, 0, NULL, 0) != REG_NOMATCH;
+#else
+	return !re_regexec(re->re, str, NULL, 0);	
+#endif
+}
+
+
+/**
+ * @brief Perform regex match of \p str using regex \p pattern.
+ *
+ * @returns 1 on match, 0 on non-match or -1 on regex compilation error
+ *          in which case a human readable error string is written to
+ *          \p errstr (if not NULL).
+ */
+int rd_regex_match (const char *pattern, const char *str,
+		    char *errstr, size_t errstr_size) {
+#if HAVE_REGEX  /* use libc regex */
+	regex_t re;
+	int r;
+
+	/* FIXME: cache compiled regex */
+	r = regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB);
+	if (r) {
+		if (errstr)
+			regerror(r, &re, errstr, errstr_size);
+		return 0;
+	}
+
+	r = regexec(&re, str, 0, NULL, 0) != REG_NOMATCH;
+
+	regfree(&re);
+
+	return r;
+
+#else /* Using regexp.h from minilibs (included) */
+	Reprog *re;
+	int r;
+	const char *errstr2;
+
+	/* FIXME: cache compiled regex */
+	re = re_regcomp(pattern, 0, &errstr2);
+	if (!re) {
+		if (errstr) {
+			strncpy(errstr, errstr2, errstr_size-1);
+			errstr[errstr_size-1] = '\0';
+		}
+		return -1;
+	}
+
+	r = !re_regexec(re, str, NULL, 0);
+
+	re_regfree(re);
+
+	return r;
+#endif
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdregex.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdregex.h b/thirdparty/librdkafka-0.11.1/src/rdregex.h
new file mode 100644
index 0000000..9569af3
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdregex.h
@@ -0,0 +1,37 @@
+/*
+ * librdkafka - The Apache Kafka C/C++ library
+ *
+ * Copyright (c) 2016 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#pragma once
+
+typedef struct rd_regex_s rd_regex_t;
+
+void rd_regex_destroy (rd_regex_t *re);
+rd_regex_t *rd_regex_comp (const char *pattern, char *errstr, size_t errstr_size);
+int rd_regex_exec (rd_regex_t *re, const char *str);
+
+int rd_regex_match (const char *pattern, const char *str,
+		    char *errstr, size_t errstr_size);

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdsignal.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdsignal.h b/thirdparty/librdkafka-0.11.1/src/rdsignal.h
new file mode 100644
index 0000000..f816855
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdsignal.h
@@ -0,0 +1,54 @@
+/*
+ * librd - Rapid Development C library
+ *
+ * Copyright (c) 2012-2013, Magnus Edenhill
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <signal.h>
+
+#define RD_SIG_ALL  -1
+#define RD_SIG_END  -2
+
+extern sigset_t rd_intr_sigset;
+extern int      rd_intr_blocked;
+
+static __inline void rd_intr_block (void) RD_UNUSED;
+static __inline void rd_intr_block (void) {
+	if (rd_intr_blocked++)
+		return;
+
+	sigprocmask(SIG_BLOCK, &rd_intr_sigset, NULL);
+}
+
+static __inline void rd_intr_unblock (void) RD_UNUSED;
+static __inline void rd_intr_unblock (void) {
+	assert(rd_intr_blocked > 0);
+	if (--rd_intr_blocked)
+		return;
+
+	sigprocmask(SIG_UNBLOCK, &rd_intr_sigset, NULL);
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdstring.c
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdstring.c b/thirdparty/librdkafka-0.11.1/src/rdstring.c
new file mode 100644
index 0000000..89e9b3c
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdstring.c
@@ -0,0 +1,162 @@
+/*
+ * librdkafka - The Apache Kafka C/C++ library
+ *
+ * Copyright (c) 2016 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "rd.h"
+#include "rdstring.h"
+
+/**
+ * @brief Render string \p template using \p callback for key lookups.
+ *
+ * Keys in template follow the %{keyname} syntax.
+ *
+ * The \p callback must not write more than \p size bytes to \p buf, must
+ * should return the number of bytes it wanted to write (which will indicate
+ * a truncated write).
+ * If the key is not found -1 should be returned (which fails the rendering).
+ *
+ * @returns number of written bytes to \p dest,
+ *          or -1 on failure (errstr is written)
+ */
+char *rd_string_render (const char *template,
+			char *errstr, size_t errstr_size,
+			ssize_t (*callback) (const char *key,
+					     char *buf, size_t size,
+					     void *opaque),
+			 void *opaque) {
+	const char *s = template;
+	const char *tend = template + strlen(template);
+	size_t size = 256;
+	char *buf;
+	size_t of = 0;
+
+	buf = rd_malloc(size);
+
+#define _remain() (size - of - 1)
+#define _assure_space(SZ) do {				\
+		if (of + (SZ) + 1 >= size) {		\
+			size = (size + (SZ) + 1) * 2;	\
+			buf = realloc(buf, size);	\
+		}					\
+	} while (0)
+	
+#define _do_write(PTR,SZ) do {				\
+		_assure_space(SZ);			\
+		memcpy(buf+of, (PTR), (SZ));		\
+		of += (SZ);				\
+	} while (0)
+
+
+
+	while (*s) {
+		const char *t;
+		size_t tof = (size_t)(s-template);
+
+		t = strstr(s, "%{");
+		if (t != s) {
+			/* Write "abc%{" 
+			 *        ^^^ */
+			size_t len = (size_t)((t ? t : tend)-s);
+			if (len)
+				_do_write(s, len);
+		}
+
+		if (t) {
+			const char *te;
+			ssize_t r;
+			char *tmpkey;
+
+			/* Find "abc%{key}"
+			 *               ^ */
+			te = strchr(t+2, '}');
+			if (!te) {
+				rd_snprintf(errstr, errstr_size,
+					    "Missing close-brace } for "
+					    "%.*s at %"PRIusz,
+					    15, t, tof);
+				rd_free(buf);
+				return NULL;
+			}
+
+			rd_strndupa(&tmpkey, t+2, (int)(te-t-2));
+
+			/* Query callback for length of key's value. */
+			r = callback(tmpkey, NULL, 0, opaque);
+			if (r == -1) {
+				rd_snprintf(errstr, errstr_size,
+					    "Property not available: \"%s\"",
+					    tmpkey);
+				rd_free(buf);
+				return NULL;
+			}
+
+			_assure_space(r);
+
+			/* Call again now providing a large enough buffer. */
+			r = callback(tmpkey, buf+of, _remain(), opaque);
+			if (r == -1) {
+				rd_snprintf(errstr, errstr_size,
+					    "Property not available: "
+					    "\"%s\"", tmpkey);
+				rd_free(buf);
+				return NULL;
+			}
+
+			assert(r < (ssize_t)_remain());
+			of += r;
+			s = te+1;
+
+		} else {
+			s = tend;
+		}
+	}
+
+	buf[of] = '\0';
+	return buf;
+}
+
+
+
+
+void rd_strtup_destroy (rd_strtup_t *strtup) {
+        rd_free(strtup);
+}
+
+rd_strtup_t *rd_strtup_new (const char *name, const char *value) {
+        size_t name_sz = strlen(name) + 1;
+        size_t value_sz = strlen(value) + 1;
+        rd_strtup_t *strtup;
+
+        strtup = rd_malloc(sizeof(*strtup) +
+                           name_sz + value_sz - 1/*name[1]*/);
+        memcpy(strtup->name, name, name_sz);
+        strtup->value = &strtup->name[name_sz];
+        memcpy(strtup->value, value, value_sz);
+
+        return strtup;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdstring.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdstring.h b/thirdparty/librdkafka-0.11.1/src/rdstring.h
new file mode 100644
index 0000000..154bc3d
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdstring.h
@@ -0,0 +1,52 @@
+/*
+ * librdkafka - The Apache Kafka C/C++ library
+ *
+ * Copyright (c) 2017 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#pragma once
+
+
+
+char *rd_string_render (const char *templ,
+                        char *errstr, size_t errstr_size,
+                        ssize_t (*callback) (const char *key,
+                                             char *buf, size_t size,
+                                             void *opaque),
+                        void *opaque);
+
+
+
+/**
+ * @brief An immutable string tuple (name, value) in a single allocation.
+ */
+typedef struct rd_strtup_s {
+        char *value;
+        char  name[1];  /* Actual allocation of name + val here */
+} rd_strtup_t;
+
+void rd_strtup_destroy (rd_strtup_t *strtup);
+rd_strtup_t *rd_strtup_new (const char *name, const char *value);

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdsysqueue.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdsysqueue.h b/thirdparty/librdkafka-0.11.1/src/rdsysqueue.h
new file mode 100644
index 0000000..9acfdfd
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdsysqueue.h
@@ -0,0 +1,330 @@
+/*
+ * librd - Rapid Development C library
+ *
+ * Copyright (c) 2012-2013, Magnus Edenhill
+ * Copyright (c) 2012-2013, Andreas Ă–man
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*
+
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "queue.h"
+
+/*
+ * Complete missing LIST-ops
+ */
+
+#ifndef LIST_FOREACH
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+#endif
+
+#ifndef LIST_EMPTY
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#endif
+
+#ifndef LIST_FIRST
+#define	LIST_FIRST(head)		((head)->lh_first)
+#endif
+
+#ifndef LIST_NEXT
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+#endif
+
+#ifndef LIST_INSERT_BEFORE
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+#endif
+
+/*
+ * Complete missing TAILQ-ops
+ */
+
+#ifndef	TAILQ_HEAD_INITIALIZER
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+#endif
+
+#ifndef TAILQ_INSERT_BEFORE
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (0)
+#endif
+
+#ifndef TAILQ_FOREACH
+#define TAILQ_FOREACH(var, head, field)                                     \
+ for ((var) = ((head)->tqh_first); (var); (var) = ((var)->field.tqe_next))
+#endif
+
+#ifndef TAILQ_EMPTY
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#endif
+
+#ifndef TAILQ_FIRST
+#define TAILQ_FIRST(head)               ((head)->tqh_first)
+#endif
+
+#ifndef TAILQ_NEXT
+#define TAILQ_NEXT(elm, field)          ((elm)->field.tqe_next)
+#endif
+
+#ifndef TAILQ_LAST
+#define TAILQ_LAST(head, headname) \
+        (*(((struct headname *)((head)->tqh_last))->tqh_last))
+#endif
+
+#ifndef TAILQ_PREV
+#define TAILQ_PREV(elm, headname, field) \
+        (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+#endif
+
+#ifndef TAILQ_FOREACH_SAFE
+/*
+ * TAILQ_FOREACH_SAFE() provides a traversal where the current iterated element
+ * may be freed or unlinked.
+ * It does not allow freeing or modifying any other element in the list,
+ * at least not the next element.
+ */
+#define TAILQ_FOREACH_SAFE(elm,head,field,tmpelm)			\
+	for ((elm) = TAILQ_FIRST(head) ;				\
+	     (elm) && ((tmpelm) = TAILQ_NEXT((elm), field), 1) ;	\
+	     (elm) = (tmpelm))
+#endif
+
+/* 
+ * In Mac OS 10.4 and earlier TAILQ_FOREACH_REVERSE was defined
+ * differently, redefined it.
+ */
+#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
+#undef TAILQ_FOREACH_REVERSE
+#endif
+#endif
+
+#ifndef TAILQ_FOREACH_REVERSE
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+#endif
+
+
+/**
+ * Treat the TAILQ as a circular list and return the previous/next entry,
+ * possibly wrapping to the end/beginning.
+ */
+#define TAILQ_CIRC_PREV(var, head, headname, field)	\
+	((var) != TAILQ_FIRST(head) ?			\
+	 TAILQ_PREV(var, headname, field) :		\
+	 TAILQ_LAST(head, headname))
+
+#define TAILQ_CIRC_NEXT(var, head, headname, field)	\
+	((var) != TAILQ_LAST(head, headname) ?		\
+	 TAILQ_NEXT(var, field) :			\
+	 TAILQ_FIRST(head))
+
+/*
+ * Some extra functions for LIST manipulation
+ */
+
+#define LIST_INSERT_SORTED(head, elm, elmtype, field, cmpfunc) do {	\
+        if(LIST_EMPTY(head)) {					\
+           LIST_INSERT_HEAD(head, elm, field);			\
+        } else {						\
+           elmtype _tmp;					\
+           LIST_FOREACH(_tmp,head,field) {			\
+              if(cmpfunc(elm,_tmp) < 0) {			\
+                LIST_INSERT_BEFORE(_tmp,elm,field);		\
+                break;						\
+              }							\
+              if(!LIST_NEXT(_tmp,field)) {			\
+                 LIST_INSERT_AFTER(_tmp,elm,field);		\
+                 break;						\
+              }							\
+           }							\
+        }							\
+} while(0)
+
+#ifndef TAILQ_INSERT_SORTED
+#define TAILQ_INSERT_SORTED(head, elm, elmtype, field, cmpfunc) do {	\
+        if(TAILQ_FIRST(head) == NULL) {				\
+           TAILQ_INSERT_HEAD(head, elm, field);			\
+        } else {						\
+           elmtype _tmp;					\
+           TAILQ_FOREACH(_tmp,head,field) {			\
+              if(cmpfunc(elm,_tmp) < 0) {			\
+                TAILQ_INSERT_BEFORE(_tmp,elm,field);		\
+                break;						\
+              }							\
+              if(!TAILQ_NEXT(_tmp,field)) {			\
+                 TAILQ_INSERT_AFTER(head,_tmp,elm,field);	\
+                 break;						\
+              }							\
+           }							\
+        }							\
+} while(0)
+#endif
+
+#define TAILQ_MOVE(newhead, oldhead, field) do { \
+        if(TAILQ_FIRST(oldhead)) { \
+           TAILQ_FIRST(oldhead)->field.tqe_prev = &(newhead)->tqh_first;  \
+	   (newhead)->tqh_first = (oldhead)->tqh_first;			\
+	   (newhead)->tqh_last = (oldhead)->tqh_last;			\
+	   TAILQ_INIT(oldhead);						\
+	} else								\
+		TAILQ_INIT(newhead);					\
+	} while (/*CONSTCOND*/0) 
+
+#ifndef TAILQ_CONCAT
+#define TAILQ_CONCAT(dhead, shead, field) do {                          \
+		if (!TAILQ_EMPTY(shead)) {				\
+			*(dhead)->tqh_last = (shead)->tqh_first;	\
+			(shead)->tqh_first->field.tqe_prev =		\
+				(dhead)->tqh_last;			\
+			(dhead)->tqh_last = (shead)->tqh_last;		\
+			TAILQ_INIT((shead));				\
+		}							\
+	} while (0)
+#endif
+
+#ifndef SIMPLEQ_HEAD
+#define SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+struct type *sqh_first;                                                 \
+struct type **sqh_last;                                                 \
+}
+#endif
+
+#ifndef SIMPLEQ_ENTRY
+#define SIMPLEQ_ENTRY(type)						\
+struct {								\
+struct type *sqe_next;                                                  \
+}
+#endif
+
+#ifndef SIMPLEQ_FIRST
+#define	SIMPLEQ_FIRST(head)	    ((head)->sqh_first)
+#endif
+
+#ifndef SIMPLEQ_REMOVE_HEAD
+#define SIMPLEQ_REMOVE_HEAD(head, field) do {			        \
+if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)    \
+(head)->sqh_last = &(head)->sqh_first;			                \
+} while (0)
+#endif
+
+#ifndef SIMPLEQ_INSERT_TAIL
+#define SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+(elm)->field.sqe_next = NULL;					        \
+*(head)->sqh_last = (elm);					        \
+(head)->sqh_last = &(elm)->field.sqe_next;			        \
+} while (0)
+#endif
+
+#ifndef SIMPLEQ_INIT
+#define	SIMPLEQ_INIT(head) do {						\
+(head)->sqh_first = NULL;					        \
+(head)->sqh_last = &(head)->sqh_first;				        \
+} while (0)
+#endif
+
+#ifndef SIMPLEQ_INSERT_HEAD
+#define SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	        \
+(head)->sqh_last = &(elm)->field.sqe_next;		                \
+(head)->sqh_first = (elm);					        \
+} while (0)
+#endif
+
+#ifndef SIMPLEQ_FOREACH
+#define SIMPLEQ_FOREACH(var, head, field)				\
+for((var) = SIMPLEQ_FIRST(head);				        \
+(var) != SIMPLEQ_END(head);					        \
+(var) = SIMPLEQ_NEXT(var, field))
+#endif
+
+#ifndef SIMPLEQ_INSERT_AFTER
+#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)        \
+(head)->sqh_last = &(elm)->field.sqe_next;		                \
+(listelm)->field.sqe_next = (elm);				        \
+} while (0)
+#endif
+
+#ifndef SIMPLEQ_END
+#define	SIMPLEQ_END(head)	    NULL
+#endif
+
+#ifndef SIMPLEQ_NEXT
+#define	SIMPLEQ_NEXT(elm, field)    ((elm)->field.sqe_next)
+#endif
+
+#ifndef SIMPLEQ_HEAD_INITIALIZER
+#define SIMPLEQ_HEAD_INITIALIZER(head)					\
+{ NULL, &(head).sqh_first }
+#endif
+
+#ifndef SIMPLEQ_EMPTY
+#define	SIMPLEQ_EMPTY(head)	    (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
+#endif
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdtime.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdtime.h b/thirdparty/librdkafka-0.11.1/src/rdtime.h
new file mode 100644
index 0000000..c770b04
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdtime.h
@@ -0,0 +1,175 @@
+/*
+ * librd - Rapid Development C library
+ *
+ * Copyright (c) 2012, Magnus Edenhill
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+
+#ifndef TIMEVAL_TO_TIMESPEC
+#define TIMEVAL_TO_TIMESPEC(tv,ts) do {		\
+    (ts)->tv_sec = (tv)->tv_sec;		\
+    (ts)->tv_nsec = (tv)->tv_usec * 1000;	\
+  } while (0)
+
+#define TIMESPEC_TO_TIMEVAL(tv, ts) do {  \
+    (tv)->tv_sec = (ts)->tv_sec;	  \
+    (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+  } while (0)
+#endif
+
+#define TIMESPEC_TO_TS(ts) \
+	(((rd_ts_t)(ts)->tv_sec * 1000000LLU) + ((ts)->tv_nsec / 1000))
+
+#define TS_TO_TIMESPEC(ts,tsx) do {			\
+	(ts)->tv_sec  = (tsx) / 1000000;		\
+        (ts)->tv_nsec = ((tsx) % 1000000) * 1000;	\
+	if ((ts)->tv_nsec >= 1000000000LLU) {		\
+	   (ts)->tv_sec++;				\
+	   (ts)->tv_nsec -= 1000000000LLU;		\
+	}						\
+       } while (0)
+
+#define TIMESPEC_CLEAR(ts) ((ts)->tv_sec = (ts)->tv_nsec = 0LLU)
+
+
+#define RD_POLL_INFINITE  -1
+#define RD_POLL_NOWAIT     0
+
+
+/**
+ * @returns a monotonically increasing clock in microseconds.
+ * @remark There is no monotonic clock on OSX, the system time
+ *         is returned instead.
+ */
+static RD_INLINE rd_ts_t rd_clock (void) RD_UNUSED;
+static RD_INLINE rd_ts_t rd_clock (void) {
+#ifdef __APPLE__
+	/* No monotonic clock on Darwin */
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return ((rd_ts_t)tv.tv_sec * 1000000LLU) + (rd_ts_t)tv.tv_usec;
+#elif defined(_MSC_VER)
+	return (rd_ts_t)GetTickCount64() * 1000LLU;
+#else
+	struct timespec ts;
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+	return ((rd_ts_t)ts.tv_sec * 1000000LLU) + 
+		((rd_ts_t)ts.tv_nsec / 1000LLU);
+#endif
+}
+
+
+/**
+ * @returns UTC wallclock time as number of microseconds since
+ *          beginning of the epoch.
+ */
+static RD_INLINE RD_UNUSED rd_ts_t rd_uclock (void) {
+	struct timeval tv;
+	rd_gettimeofday(&tv, NULL);
+	return ((rd_ts_t)tv.tv_sec * 1000000LLU) + (rd_ts_t)tv.tv_usec;
+}
+
+
+
+/**
+ * Thread-safe version of ctime() that strips the trailing newline.
+ */
+static RD_INLINE const char *rd_ctime (const time_t *t) RD_UNUSED;
+static RD_INLINE const char *rd_ctime (const time_t *t) {
+	static RD_TLS char ret[27];
+
+#ifndef _MSC_VER
+	ctime_r(t, ret);
+#else
+	ctime_s(ret, sizeof(ret), t);
+#endif
+	ret[25] = '\0';
+
+	return ret;
+}
+
+
+/**
+ * @brief Initialize an absolute timeout based on the provided \p timeout_ms
+ *
+ * To be used with rd_timeout_adjust().
+ *
+ * Honours RD_POLL_INFINITE, RD_POLL_NOWAIT.
+ *
+ * @returns the absolute timeout which should later be passed
+ *          to rd_timeout_adjust().
+ */
+static RD_INLINE rd_ts_t rd_timeout_init (int timeout_ms) {
+	if (timeout_ms == RD_POLL_INFINITE ||
+	    timeout_ms == RD_POLL_NOWAIT)
+		return timeout_ms;
+
+	return rd_clock() + (timeout_ms * 1000);
+}
+
+
+/**
+ * @returns the remaining timeout for timeout \p abs_timeout previously set
+ *          up by rd_timeout_init()
+ *
+ * Honours RD_POLL_INFINITE, RD_POLL_NOWAIT.
+ */
+static RD_INLINE int rd_timeout_remains (rd_ts_t abs_timeout) {
+	int timeout_ms;
+
+	if (abs_timeout == RD_POLL_INFINITE ||
+	    abs_timeout == RD_POLL_NOWAIT)
+		return (int)abs_timeout;
+
+	timeout_ms = (int)((abs_timeout - rd_clock()) / 1000);
+	if (timeout_ms <= 0)
+		return RD_POLL_NOWAIT;
+	else
+		return timeout_ms;
+}
+
+/**
+ * @brief Like rd_timeout_remains() but limits the maximum time to \p limit_ms
+ */
+static RD_INLINE int
+rd_timeout_remains_limit (rd_ts_t abs_timeout, int limit_ms) {
+	int timeout_ms = rd_timeout_remains(abs_timeout);
+
+	if (timeout_ms == RD_POLL_INFINITE || timeout_ms > limit_ms)
+		return limit_ms;
+	else
+		return timeout_ms;
+}
+
+
+/**
+ * @returns 1 if the **relative** timeout as returned by rd_timeout_remains()
+ *          has timed out / expired, else 0.
+ */
+static RD_INLINE int rd_timeout_expired (int timeout_ms) {
+	return timeout_ms == RD_POLL_NOWAIT;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdtypes.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdtypes.h b/thirdparty/librdkafka-0.11.1/src/rdtypes.h
new file mode 100644
index 0000000..0206079
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdtypes.h
@@ -0,0 +1,42 @@
+/*
+ * librd - Rapid Development C library
+ *
+ * Copyright (c) 2012, Magnus Edenhill
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: 
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <inttypes.h>
+
+
+/*
+ * Fundamental types
+ */
+
+
+/* Timestamp (microseconds) */
+typedef int64_t rd_ts_t;
+
+#define RD_TS_MAX  INT64_MAX

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdunittest.c
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdunittest.c b/thirdparty/librdkafka-0.11.1/src/rdunittest.c
new file mode 100644
index 0000000..b1c802e
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdunittest.c
@@ -0,0 +1,43 @@
+/*
+ * librdkafka - Apache Kafka C library
+ *
+ * Copyright (c) 2017 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "rd.h"
+#include "rdunittest.h"
+
+#include "rdvarint.h"
+#include "rdbuf.h"
+#include "crc32c.h"
+
+
+int rd_unittest (void) {
+        int fails = 0;
+        fails += unittest_rdbuf();
+        fails += unittest_rdvarint();
+        fails += unittest_crc32c();
+        return fails;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdunittest.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdunittest.h b/thirdparty/librdkafka-0.11.1/src/rdunittest.h
new file mode 100644
index 0000000..a8d29da
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdunittest.h
@@ -0,0 +1,83 @@
+/*
+ * librdkafka - Apache Kafka C library
+ *
+ * Copyright (c) 2017 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RD_UNITTEST_H
+#define _RD_UNITTEST_H
+
+#include <stdio.h>
+
+
+/**
+ * @brief Fail the current unit-test function.
+ */
+#define RD_UT_FAIL(...) do {                                            \
+                fprintf(stderr, "\033[31mRDUT: FAIL: %s:%d: %s: ",      \
+                        __FILE__, __LINE__, __FUNCTION__);              \
+                fprintf(stderr, __VA_ARGS__);                           \
+                fprintf(stderr, "\033[0m\n");                           \
+                return 1;                                               \
+        } while (0)
+
+/**
+ * @brief Pass the current unit-test function
+ */
+#define RD_UT_PASS() do {                                               \
+                fprintf(stderr, "\033[32mRDUT: PASS: %s:%d: %s\033[0m\n", \
+                        __FILE__, __LINE__, __FUNCTION__);              \
+                return 0;                                               \
+        } while (0)
+
+/**
+ * @brief Fail unit-test if \p expr is false
+ */
+#define RD_UT_ASSERT(expr,...) do {                                     \
+        if (!(expr)) {                                                  \
+        fprintf(stderr,                                                 \
+                "\033[31mRDUT: FAIL: %s:%d: %s: assert failed: " # expr ": ", \
+                __FILE__, __LINE__, __FUNCTION__);                      \
+        fprintf(stderr, __VA_ARGS__);                                   \
+        fprintf(stderr, "\033[0m\n");                                   \
+        return 1;                                                       \
+        }                                                               \
+         } while (0)
+
+
+/**
+ * @brief Log something from a unit-test
+ */
+#define RD_UT_SAY(...) do {                                             \
+                fprintf(stderr, "RDUT: INFO: %s:%d: %s: ",              \
+                        __FILE__, __LINE__, __FUNCTION__);              \
+                fprintf(stderr, __VA_ARGS__);                           \
+                fprintf(stderr, "\n");                                  \
+        } while (0)
+
+
+int rd_unittest (void);
+
+#endif /* _RD_UNITTEST_H */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdvarint.c
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdvarint.c b/thirdparty/librdkafka-0.11.1/src/rdvarint.c
new file mode 100644
index 0000000..cd7699b
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdvarint.c
@@ -0,0 +1,126 @@
+/*
+ * librdkafka - The Apache Kafka C/C++ library
+ *
+ * Copyright (c) 2016 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "rdvarint.h"
+#include "rdunittest.h"
+
+
+/**
+ * @brief Read a varint-encoded signed integer from \p slice.
+ */
+size_t rd_varint_dec_slice (rd_slice_t *slice, int64_t *nump) {
+        size_t num = 0;
+        int shift = 0;
+        unsigned char oct;
+
+        /* FIXME: Optimize to use something better than read() */
+        do {
+                size_t r = rd_slice_read(slice, &oct, sizeof(oct));
+                if (unlikely(r == 0))
+                        return 0; /* Underflow */
+                num |= (uint64_t)(oct & 0x7f) << shift;
+                shift += 7;
+        } while (oct & 0x80);
+
+        *nump = (int64_t)((num >> 1) ^ -(int64_t)(num & 1));
+
+        return shift / 7;
+}
+
+
+
+
+
+static int do_test_rd_uvarint_enc_i64 (const char *file, int line,
+                                       int64_t num, const char *exp,
+                                       size_t exp_size) {
+        char buf[16] = { 0xff, 0xff, 0xff, 0xff,
+                         0xff, 0xff, 0xff, 0xff,
+                         0xff, 0xff, 0xff, 0xff,
+                         0xff, 0xff, 0xff, 0xff };
+        size_t sz = rd_uvarint_enc_i64(buf, sizeof(buf), num);
+        size_t r;
+        int ir;
+        rd_buf_t b;
+        rd_slice_t slice, bad_slice;
+        int64_t ret_num;
+
+        if (sz != exp_size || memcmp(buf, exp, exp_size))
+                RD_UT_FAIL("i64 encode of %"PRId64": "
+                           "expected size %"PRIusz" (got %"PRIusz")\n",
+                           num, exp_size, sz);
+
+        /* Verify with standard decoder */
+        r = rd_varint_dec_i64(buf, sz, &ret_num);
+        RD_UT_ASSERT(!RD_UVARINT_DEC_FAILED(r),
+                     "varint decode failed: %"PRIusz, r);
+        RD_UT_ASSERT(ret_num == num,
+                     "varint decode returned wrong number: "
+                     "%"PRId64" != %"PRId64, ret_num, num);
+
+        /* Verify with slice decoder */
+        rd_buf_init(&b, 1, 0);
+        rd_buf_push(&b, buf, sz, NULL);
+        rd_slice_init_full(&slice, &b);
+
+        /* Should fail for incomplete reads */
+        ir = rd_slice_narrow_copy(&slice, &bad_slice,
+                                  rd_slice_remains(&slice)-1);
+        RD_UT_ASSERT(ir, "narrow_copy failed");
+        ret_num = -1;
+        r = rd_varint_dec_slice(&bad_slice, &ret_num);
+        RD_UT_ASSERT(RD_UVARINT_DEC_FAILED(r),
+                     "varint decode failed should have failed, returned %"PRIusz,
+                     r);
+
+        /* Verify proper slice */
+        ret_num = -1;
+        r = rd_varint_dec_slice(&slice, &ret_num);
+        RD_UT_ASSERT(!RD_UVARINT_DEC_FAILED(r),
+                     "varint decode failed: %"PRIusz, r);
+        RD_UT_ASSERT(ret_num == num,
+                     "varint decode returned wrong number: "
+                     "%"PRId64" != %"PRId64, ret_num, num);
+
+        rd_buf_destroy(&b);
+
+        RD_UT_PASS();
+}
+
+
+int unittest_rdvarint (void) {
+        int fails = 0;
+
+        fails += do_test_rd_uvarint_enc_i64(__FILE__, __LINE__, 23,
+                                            (const char[]){ 23<<1 }, 1);
+        fails += do_test_rd_uvarint_enc_i64(__FILE__, __LINE__, 253,
+                                            (const char[]){ 0xfa,  3 }, 2);
+
+        return fails;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdvarint.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdvarint.h b/thirdparty/librdkafka-0.11.1/src/rdvarint.h
new file mode 100644
index 0000000..407bfb0
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdvarint.h
@@ -0,0 +1,169 @@
+/*
+ * librdkafka - The Apache Kafka C/C++ library
+ *
+ * Copyright (c) 2016 Magnus Edenhill
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef _RDVARINT_H
+#define _RDVARINT_H
+
+#include "rd.h"
+#include "rdbuf.h"
+
+/**
+ * @name signed varint zig-zag encoder/decoder
+ * @{
+ *
+ */
+
+/**
+ * @brief unsigned-varint encodes unsigned integer \p num into buffer
+ *        at \p dst of size \p dstsize.
+ * @returns the number of bytes written to \p dst, or 0 if not enough space.
+ */
+
+static RD_INLINE RD_UNUSED
+size_t rd_uvarint_enc_u64 (char *dst, size_t dstsize, uint64_t num) {
+        size_t of = 0;
+
+        do {
+                if (unlikely(of >= dstsize))
+                        return 0; /* Not enough space */
+
+                dst[of++] = (num & 0x7f) | (num > 0x7f ? 0x80 : 0);
+                num >>= 7;
+        } while (num);
+
+        return of;
+}
+
+/**
+ * @brief encodes a signed integer using zig-zag encoding.
+ * @sa rd_uvarint_enc_u64
+ */
+static RD_INLINE RD_UNUSED
+size_t rd_uvarint_enc_i64 (char *dst, size_t dstsize, int64_t num) {
+        return rd_uvarint_enc_u64(dst, dstsize, (num << 1) ^ (num >> 63));
+}
+
+
+static RD_INLINE RD_UNUSED
+size_t rd_uvarint_enc_i32 (char *dst, size_t dstsize, int32_t num) {
+        return rd_uvarint_enc_i64(dst, dstsize, num);
+}
+
+
+
+/**
+ * @brief Use on return value from rd_uvarint_dec() to check if
+ *        decoded varint fit the size_t.
+ *
+ * @returns 1 on overflow, else 0.
+ */
+#define RD_UVARINT_OVERFLOW(DEC_RETVAL) (DEC_RETVAL > SIZE_MAX)
+
+/**
+ * @returns 1 if there were not enough bytes to decode the varint, else 0.
+ */
+#define RD_UVARINT_UNDERFLOW(DEC_RETVAL) (DEC_RETVAL == 0)
+
+
+/**
+ * @param DEC_RETVAL the return value from \c rd_uvarint_dec()
+ * @returns 1 if varint decoding failed, else 0.
+ * @warning \p DEC_RETVAL will be evaluated twice.
+ */
+#define RD_UVARINT_DEC_FAILED(DEC_RETVAL) \
+        (RD_UVARINT_UNDERFLOW(DEC_RETVAL) || RD_UVARINT_OVERFLOW(DEC_RETVAL))
+
+
+/**
+ * @brief Decodes the unsigned-varint in buffer \p src of size \p srcsize
+ *        and stores the decoded unsigned integer in \p nump.
+ *
+ * @remark Use RD_UVARINT_OVERFLOW(returnvalue) to check if the varint
+ *         could not fit \p nump, and RD_UVARINT_UNDERFLOW(returnvalue) to
+ *         check if there were not enough bytes available in \p src to
+ *         decode the full varint.
+ *
+ * @returns the number of bytes read from \p src.
+ */
+static RD_INLINE RD_UNUSED
+size_t rd_uvarint_dec (const char *src, size_t srcsize, size_t *nump) {
+        size_t of = 0;
+        size_t num = 0;
+        int shift = 0;
+
+        do {
+                if (unlikely(srcsize-- == 0))
+                        return 0; /* Underflow */
+                num |= (uint64_t)(src[(int)of] & 0x7f) << shift;
+                shift += 7;
+        } while (src[(int)of++] & 0x80);
+
+        *nump = num;
+        return of;
+}
+
+static RD_INLINE RD_UNUSED
+size_t rd_varint_dec_i64 (const char *src, size_t srcsize, int64_t *nump) {
+        size_t n;
+        size_t r;
+
+        r = rd_uvarint_dec(src, srcsize, &n);
+        if (likely(!RD_UVARINT_DEC_FAILED(r)))
+                *nump = (int64_t)(n >> 1) ^ -(int64_t)(n & 1);
+
+        return r;
+}
+
+
+/**
+ * @brief Read a varint-encoded signed integer from \p slice.
+ *
+ * @sa rd_uvarint_dec()
+ */
+size_t rd_varint_dec_slice (rd_slice_t *slice, int64_t *nump);
+
+
+/**
+ * @returns the maximum encoded size for a type
+ */
+#define RD_UVARINT_ENC_SIZEOF(TYPE) \
+        (sizeof(TYPE) + 1 + (sizeof(TYPE)/7))
+
+/**
+ * @returns the encoding size of the value 0
+ */
+#define RD_UVARINT_ENC_SIZE_0() 1
+
+
+int unittest_rdvarint (void);
+
+/**@}*/
+
+
+#endif /* _RDVARINT_H */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/9f66960e/thirdparty/librdkafka-0.11.1/src/rdwin32.h
----------------------------------------------------------------------
diff --git a/thirdparty/librdkafka-0.11.1/src/rdwin32.h b/thirdparty/librdkafka-0.11.1/src/rdwin32.h
new file mode 100644
index 0000000..dfd16d1
--- /dev/null
+++ b/thirdparty/librdkafka-0.11.1/src/rdwin32.h
@@ -0,0 +1,262 @@
+/*
+* librdkafka - Apache Kafka C library
+*
+* Copyright (c) 2012-2015 Magnus Edenhill
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice,
+*    this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+*    this list of conditions and the following disclaimer in the documentation
+*    and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * Win32 (Visual Studio) support
+ */
+#pragma once
+
+
+#include <stdlib.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <time.h>
+#include <assert.h>
+#define WIN32_MEAN_AND_LEAN
+#include <Winsock2.h>  /* for struct timeval */
+#include <io.h>
+#include <fcntl.h>
+
+
+/**
+ * Types
+ */
+typedef SSIZE_T ssize_t;
+typedef int socklen_t;
+
+struct iovec {
+	void *iov_base;
+	size_t iov_len;
+};
+
+struct msghdr {
+	struct iovec  *msg_iov;
+	int            msg_iovlen;
+};
+
+#define LOG_EMERG   0
+#define LOG_ALERT   1
+#define LOG_CRIT    2
+#define LOG_ERR     3
+#define LOG_WARNING 4
+#define LOG_NOTICE  5
+#define LOG_INFO    6
+#define LOG_DEBUG   7
+
+
+
+/**
+* Annotations, attributes, optimizers
+*/
+#ifndef likely
+#define likely(x)   x
+#endif
+#ifndef unlikely
+#define unlikely(x) x
+#endif
+
+#define RD_UNUSED
+#define RD_INLINE  __inline
+#define RD_WARN_UNUSED_RESULT
+#define RD_NORETURN __declspec(noreturn)
+#define RD_IS_CONSTANT(p)  (0)
+#define RD_TLS __declspec(thread)
+
+
+/**
+ * Allocation
+ */
+#define rd_alloca(N) _alloca(N)
+
+
+/**
+ * Strings, formatting, printf, ..
+ */
+
+/* size_t and ssize_t format strings */
+#define PRIusz  "Iu"
+#define PRIdsz  "Id"
+
+#define RD_FORMAT(...)
+
+static RD_UNUSED RD_INLINE
+int rd_vsnprintf (char *str, size_t size, const char *format, va_list ap) {
+        int cnt = -1;
+
+        if (size != 0)
+                cnt = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
+        if (cnt == -1)
+                cnt = _vscprintf(format, ap);
+
+        return cnt;
+}
+
+static RD_UNUSED RD_INLINE
+int rd_snprintf (char *str, size_t size, const char *format, ...) {
+        int cnt;
+        va_list ap;
+
+        va_start(ap, format);
+        cnt = rd_vsnprintf(str, size, format, ap);
+        va_end(ap);
+
+        return cnt;
+}
+
+
+#define rd_strcasecmp(A,B) _stricmp(A,B)
+#define rd_strncasecmp(A,B,N) _strnicmp(A,B,N)
+
+
+/**
+ * Errors
+ */
+static RD_INLINE RD_UNUSED const char *rd_strerror(int err) {
+	static RD_TLS char ret[128];
+
+	strerror_s(ret, sizeof(ret) - 1, err);
+	return ret;
+}
+
+
+/**
+ * Atomics
+ */
+#ifndef __cplusplus
+#include "rdatomic.h"
+#endif
+
+
+/**
+ * Misc
+ */
+
+/**
+ * Microsecond sleep.
+ * 'retry': if true, retry if sleep is interrupted (because of signal)
+ */
+#define rd_usleep(usec,terminate)  Sleep((usec) / 1000)
+
+
+/**
+ * @brief gettimeofday() for win32
+ */
+static RD_UNUSED
+int rd_gettimeofday (struct timeval *tv, struct timezone *tz) {
+	SYSTEMTIME st;
+	FILETIME   ft;
+	ULARGE_INTEGER d;
+
+	GetSystemTime(&st);
+	SystemTimeToFileTime(&st, &ft);
+	d.HighPart = ft.dwHighDateTime;
+	d.LowPart  = ft.dwLowDateTime;
+	tv->tv_sec  = (long)((d.QuadPart - 116444736000000000llu) / 10000000L);
+	tv->tv_usec = (long)(st.wMilliseconds * 1000);
+
+	return 0;
+}
+
+
+#define rd_assert(EXPR)  assert(EXPR)
+
+
+/**
+ * Empty struct initializer
+ */
+#define RD_ZERO_INIT  {0}
+
+#ifndef __cplusplus
+/**
+ * Sockets, IO
+ */
+
+/**
+ * @brief Set socket to non-blocking
+ * @returns 0 on success or -1 on failure (see rd_kafka_socket_errno)
+ */
+static RD_UNUSED int rd_fd_set_nonblocking (int fd) {
+        int on = 1;
+        if (ioctlsocket(fd, FIONBIO, &on) == SOCKET_ERROR)
+                return (int)WSAGetLastError();
+        return 0;
+}
+
+/**
+ * @brief Create non-blocking pipe
+ * @returns 0 on success or errno on failure
+ */
+static RD_UNUSED int rd_pipe_nonblocking (int *fds) {
+        HANDLE h[2];
+        int i;
+
+        if (!CreatePipe(&h[0], &h[1], NULL, 0))
+                return (int)GetLastError();
+        for (i = 0 ; i < 2 ; i++) {
+                DWORD mode = PIPE_NOWAIT;
+                /* Set non-blocking */
+                if (!SetNamedPipeHandleState(h[i], &mode, NULL, NULL)) {
+                        CloseHandle(h[0]);
+                        CloseHandle(h[1]);
+                        return (int)GetLastError();
+                }
+
+                /* Open file descriptor for handle */
+                fds[i] = _open_osfhandle((intptr_t)h[i],
+                                         i == 0 ?
+                                         O_RDONLY | O_BINARY :
+                                         O_WRONLY | O_BINARY);
+
+                if (fds[i] == -1) {
+                        CloseHandle(h[0]);
+                        CloseHandle(h[1]);
+                        return (int)GetLastError();
+                }
+        }
+        return 0;
+}
+
+#define rd_read(fd,buf,sz) _read(fd,buf,sz)
+#define rd_write(fd,buf,sz) _write(fd,buf,sz)
+#define rd_close(fd) closesocket(fd)
+
+static RD_UNUSED char *
+rd_strerror_w32 (DWORD errcode, char *dst, size_t dstsize) {
+        char *t;
+        FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+                       FORMAT_MESSAGE_IGNORE_INSERTS,
+                       NULL, errcode,
+                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                       (LPSTR)dst, (DWORD)dstsize - 1, NULL);
+        /* Remove newlines */
+        while ((t = strchr(dst, (int)'\r')) || (t = strchr(dst, (int)'\n')))
+                *t = (char)'.';
+        return dst;
+}
+
+#endif /* !__cplusplus*/