You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2017/11/14 01:48:36 UTC
[22/25] nifi-minifi-cpp git commit: MINIFICPP-250: Initial
implementation fo CapturePacket Processor that uses lipcap.
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/debug-new/debug_new.cpp
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/debug-new/debug_new.cpp b/thirdparty/pcap++/3rdParty/debug-new/debug_new.cpp
new file mode 100644
index 0000000..e27ac53
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/debug-new/debug_new.cpp
@@ -0,0 +1,572 @@
+/*
+ * debug_new.cpp 1.11 2003/07/03
+ *
+ * Implementation of debug versions of new and delete to check leakage
+ *
+ * By Chen jiangbo
+ *
+ */
+
+#include <new>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+
+#ifdef _MSC_VER
+#pragma warning(disable: 4073)
+#pragma init_seg(lib)
+#include <process.h>
+typedef int pid_t;
+#define popen(cmd, mode) _popen(cmd, mode)
+#define pclose(x) _pclose(x)
+#define getpid() _getpid()
+#include <intrin.h>
+#define _DEBUG_NEW_CALLER_ADDRESS _ReturnAddress()
+#else
+#define _DEBUG_NEW_CALLER_ADDRESS __builtin_return_address(0)
+#endif
+
+#if defined(WIN32) && !defined(_MSC_VER)
+#define alloca __builtin_alloca
+#endif
+
+#ifndef DEBUG_NEW_HASHTABLESIZE
+#define DEBUG_NEW_HASHTABLESIZE 16384
+#endif
+
+#ifndef DEBUG_NEW_HASH
+#define DEBUG_NEW_HASH(p) (((unsigned long)(p) >> 8) % DEBUG_NEW_HASHTABLESIZE)
+#endif
+
+// The default behaviour now is to copy the file name, because we found
+// that the exit leakage check cannot access the address of the file
+// name sometimes (in our case, a core dump will occur when trying to
+// access the file name in a shared library after a SIGINT).
+#ifndef DEBUG_NEW_FILENAME_LEN
+#define DEBUG_NEW_FILENAME_LEN 32
+#endif
+#if DEBUG_NEW_FILENAME_LEN == 0 && !defined(DEBUG_NEW_NO_FILENAME_COPY)
+#define DEBUG_NEW_NO_FILENAME_COPY
+#endif
+#ifndef DEBUG_NEW_NO_FILENAME_COPY
+#include <string.h>
+#endif
+
+#define PATH_SIZE 128
+#define ADDR2LINE_CMD "addr2line -e %s %08lx %s"
+#define CMD_OPT "%s %08lx %s"
+
+struct new_ptr_list_t
+{
+ new_ptr_list_t* next;
+#ifdef DEBUG_NEW_NO_FILENAME_COPY
+ const char* file;
+#else
+ char file[DEBUG_NEW_FILENAME_LEN];
+#endif
+ int line;
+ size_t size;
+ char is_static;
+};
+
+typedef struct pmap_line {
+ unsigned long vm_start;
+ unsigned long vm_end;
+ char perm[5]; /* permission */
+ char path[PATH_SIZE];
+ bool absolute; /* Is the absoluted address*/
+ struct pmap_line *next;
+} pmap_line_t;
+
+static unsigned int total_size = 0;
+static pmap_line_t *pmap_line_head=NULL;
+
+static void free_pmap_line()
+{
+ pmap_line_t *line=NULL;
+ while((line=pmap_line_head) != NULL)
+ {
+ pmap_line_head=pmap_line_head->next;
+ free(line);
+ }
+}
+
+static new_ptr_list_t* new_ptr_list[DEBUG_NEW_HASHTABLESIZE];
+
+bool new_verbose_flag = false;
+bool new_autocheck_flag = true;
+bool new_start_check = false;
+int static_alloc_counter = 0;
+
+static void getpmaps(pid_t pid)
+{
+
+ FILE *f;
+ char buf[4096+100]={0};
+ pmap_line_t *pmap_line_tail=NULL;
+ pmap_line_t *line=NULL;
+ char fname [50]={0};
+ long int offset;
+ int major;
+ int minor;
+ int inode;
+
+ sprintf(fname, "/proc/%ld/maps", (long)pid);
+ //sprintf(fname, "D:\\proc\\maps");
+ f = fopen(fname, "r");
+ if(!f) {
+ printf("open file : %s failed \n", fname);
+ return;
+ }
+
+ while(!feof(f))
+ {
+ /*get the line from the file*/
+ if(fgets(buf, sizeof(buf), f) == 0) {
+ break;
+ }
+
+ /*allocate the memory for storing the VMA information*/
+ line=(pmap_line_t*)malloc(sizeof(pmap_line_t));
+ if (!line) {
+ printf("malloc failed\n");
+ return;
+ }
+
+ /*init the allocated memory*/
+ memset(line, 0, sizeof(pmap_line_t));
+
+ /*parse the line */
+ sscanf(buf, "%lx-%lx %4s %lx %02x:%02x %d %s",
+ &line->vm_start, &line->vm_end, line->perm, &offset, &major, &minor, &inode, line->path);
+ line->next=NULL;
+
+ if (line->perm[2] != 'x' || strstr(buf, "/usr/lib") || strstr(buf, "/lib/")
+ || 0 == inode || 0 != offset) {
+ free(line);
+ continue;
+ }
+
+ if (strstr(buf, ".so")) {
+ line->absolute = false;
+ } else {
+ line->absolute = true;
+ }
+ if(!pmap_line_head)
+ {
+ pmap_line_head=line;
+ }
+ if(pmap_line_tail)
+ {
+ pmap_line_tail->next=line;
+ }
+ pmap_line_tail = line;
+ }
+
+ /*print the parsed result*/
+ line=pmap_line_head;
+ while(line)
+ {
+ printf("%08lx-%08lx %s %s\n",line->vm_start,line->vm_end, line->perm, line->path);
+ line=line->next;
+ }
+
+ /*close the map file*/
+ fclose(f);
+}
+
+static char* canReadAndEexcAddr(unsigned long addr, unsigned long *pStartAddr)
+{
+ pmap_line_t *line=pmap_line_head;
+
+ if(!pmap_line_head)
+ {
+ return 0;
+ }
+
+ while(line)
+ {
+ if(line->perm[0] == 'r' && line->perm[2] == 'x' &&
+ addr >= line->vm_start && addr <=line->vm_end)
+ {
+ if (line->absolute) {
+ *pStartAddr = 0;
+ } else {
+ *pStartAddr = line->vm_start;
+ }
+ return line->path;
+ }
+ line=line->next;
+ }
+
+ printf("cannot read address %#08lx\n",addr);
+
+ return NULL;
+
+}
+
+static long last_addr = 0;
+static char last_info[256] = "";
+
+static bool get_position_from_addr(char* programe, const long addr)
+{
+ if (addr == last_addr)
+ {
+ if (last_info[0] == '\0')
+ return false;
+ return true;
+ }
+ if (programe)
+ {
+ const char addr2line_cmd[] = ADDR2LINE_CMD;
+ char ignore_err[] = " 2>/dev/null";
+ char *cmd;
+
+ cmd = (char *)alloca(sizeof(addr2line_cmd) - sizeof(CMD_OPT) +
+ strlen(programe) - 1 +
+ 8 +
+ sizeof(ignore_err));
+
+ sprintf(cmd, addr2line_cmd, programe, addr, ignore_err);
+
+ size_t len = strlen(cmd);
+
+ //printf("CMD: %s \n", cmd);
+
+ FILE* fp = popen(cmd, "r");
+ if (fp)
+ {
+ char buffer[sizeof last_info] = "";
+ len = 0;
+ if (fgets(buffer, sizeof buffer, fp))
+ {
+ len = strlen(buffer);
+ if (buffer[len - 1] == '\n')
+ buffer[--len] = '\0';
+ }
+ int res = pclose(fp);
+ // Display the file/line information only if the command
+ // is executed successfully and the output points to a
+ // valid position, but the result will be cached if only
+ // the command is executed successfully.
+ if (res == 0 && len > 0)
+ {
+ last_addr = addr;
+ if (buffer[len - 1] == '0' && buffer[len - 2] == ':') {
+ last_info[0] = '\0';
+ fprintf(stderr, "Can't locate the address at %lx\n", addr);
+ }
+ else
+ {
+ strcpy(last_info, buffer);
+ return true;
+ }
+ }
+ } else {
+ fprintf(stderr, "popen failed!\n");
+ }
+ }
+ return false;
+}
+
+bool locate_addr(char* file, int* line)
+{
+ unsigned long start_addr = 0;
+ char* program_path = NULL;
+ char* slash_index = NULL;
+ char* colon_index = NULL;
+ bool result = false;
+
+ if (!pmap_line_head) {
+ getpmaps(getpid());
+ }
+
+ program_path = canReadAndEexcAddr(((long *)file)[0], &start_addr);
+
+ if (program_path) {
+ result = get_position_from_addr(program_path, ((long *)file)[0] - start_addr);
+ if (result) {
+ colon_index = strrchr(last_info, ':');
+ if (!colon_index) {
+ printf("ERR:last_info: %s\n", last_info);
+ return false;
+ }
+ *line = atoi(colon_index + 1);
+ *colon_index = '\0';
+ slash_index = strrchr(last_info, '/');
+ if (!slash_index) {
+ printf("ERR:last_info: %s\n", last_info);
+ return false;
+ }
+ strcpy(file, slash_index + 1);
+ // restore the colon
+ *colon_index = ':';
+ } else {
+ strcpy(file, "Unknown");
+ *line = 0;
+ }
+ } else {
+ return false;
+ }
+ return true;
+}
+
+
+
+void start_leak_check()
+{
+ new_start_check = true;
+}
+
+
+
+bool check_leaks()
+{
+ bool fLeaked = false;
+ bool ret = false;
+
+ for (int i = 0; i < DEBUG_NEW_HASHTABLESIZE; ++i)
+ {
+ new_ptr_list_t* ptr = new_ptr_list[i];
+ if (ptr == NULL)
+ continue;
+
+ if (ptr->is_static != 0)
+ continue;
+
+ fLeaked = true;
+ while (ptr)
+ {
+ if (!ptr->line) {
+ ret = locate_addr(ptr->file, &ptr->line);
+ }
+
+ if (ret) {
+ printf("Leaked object at %p (size %d, %s:%d)\n",
+ (char*)ptr + sizeof(new_ptr_list_t),
+ (int)ptr->size,
+ ptr->file,
+ ptr->line);
+ ptr = ptr->next;
+ }
+ else {
+ printf("Leaked object at %p (size %d, %s:%d)\n",
+ (char*)ptr + sizeof(new_ptr_list_t),
+ (int)ptr->size,
+ ptr->file,
+ ptr->line);
+
+ ptr = ptr->next;
+ }
+ }
+ }
+ free_pmap_line();
+
+ if (fLeaked) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
+void* operator new(size_t size, const char* file, int line)
+{
+ char file_name[PATH_SIZE];
+
+ size_t s = size + sizeof(new_ptr_list_t);
+ new_ptr_list_t* ptr = (new_ptr_list_t*)malloc(s);
+ if (ptr == NULL)
+ {
+ if (0 == line) {
+ // release memory for memory check program
+ for (int i = 0; i < DEBUG_NEW_HASHTABLESIZE; ++i)
+ {
+ new_ptr_list_t* ptr_tmp = new_ptr_list[i];
+ if (ptr_tmp == NULL) {
+ continue;
+ } else if (ptr_tmp == ptr) {
+ continue;
+ } else {
+ delete((char*)ptr_tmp + sizeof(new_ptr_list_t));
+ }
+ }
+ memcpy(file_name, &file, 4); // address occupy 4 bytes
+ locate_addr(file_name, &line);
+ }
+
+ fprintf(stderr, "new: out of memory when allocating %d bytes at %s:%d\n",
+ (int)size,
+ file_name,
+ line);
+ abort();
+ }
+ total_size = total_size + size;
+ void* pointer = (char*)ptr + sizeof(new_ptr_list_t);
+ size_t hash_index = DEBUG_NEW_HASH(pointer);
+ ptr->next = new_ptr_list[hash_index];
+#ifdef DEBUG_NEW_NO_FILENAME_COPY
+ ptr->file = file;
+#else
+ if (0 == line) {
+ memcpy(ptr->file, &file, sizeof(void *));
+ } else {
+ strncpy(ptr->file, file, DEBUG_NEW_FILENAME_LEN - 1);
+ ptr->file[DEBUG_NEW_FILENAME_LEN - 1] = '\0';
+ }
+#endif
+ ptr->line = line;
+ ptr->size = size;
+ if (new_start_check)
+ ptr->is_static = 0;
+ else
+ {
+ ptr->is_static = 1;
+ static_alloc_counter++;
+ }
+ new_ptr_list[hash_index] = ptr;
+ if (new_verbose_flag) {
+ printf("new: allocated %p (size %d)\n", pointer, (int)size);
+ }
+ return pointer;
+}
+
+void* operator new[](size_t size, const char* file, int line)
+{
+ return operator new(size, file, line);
+}
+
+void* operator new(size_t size)
+{
+ return operator new(size, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0);
+}
+
+void* operator new[](size_t size)
+{
+ return operator new(size, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0);
+}
+
+void* operator new(size_t size, const std::nothrow_t&) throw()
+{
+ return operator new(size, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0);
+}
+
+void* operator new[](size_t size, const std::nothrow_t&) throw()
+{
+ return operator new[](size, (char *)_DEBUG_NEW_CALLER_ADDRESS, 0);
+}
+
+void operator delete(void* pointer)
+{
+ if (pointer == NULL)
+ return;
+ size_t hash_index = DEBUG_NEW_HASH(pointer);
+ new_ptr_list_t* ptr = new_ptr_list[hash_index];
+ new_ptr_list_t* ptr_last = NULL;
+ while (ptr)
+ {
+ if ((char*)ptr + sizeof(new_ptr_list_t) == pointer)
+ {
+ total_size = total_size - ptr->size;
+ if (new_verbose_flag && ptr->is_static == 0) {
+ printf("delete: freeing %p (size %d)\n", pointer, (int)ptr->size);
+ }
+ if (ptr->is_static != 0)
+ {
+ static_alloc_counter--;
+ if (static_alloc_counter == 0 && new_verbose_flag)
+ printf("Memory leaks check: all STATIC variables were freed\n");
+ else if (static_alloc_counter != 0 && new_verbose_flag)
+ printf("static_alloc_counter = %d\n", static_alloc_counter);
+ }
+
+ if (ptr_last == NULL)
+ new_ptr_list[hash_index] = ptr->next;
+ else
+ ptr_last->next = ptr->next;
+ free(ptr);
+ return;
+ } else if ((char*)ptr + sizeof(new_ptr_list_t) == (char *)pointer - 8) {
+ char file_name[PATH_SIZE];
+ int line = 0;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+ memcpy(file_name, &((long *)ptr->file)[0], 4);
+#pragma GCC diagnostic pop
+ locate_addr(file_name, &line);
+ printf("ERR: Maybe delete a array missing [] before the pointer at %s:%d\n", file_name, line);
+ }
+ ptr_last = ptr;
+ ptr = ptr->next;
+ }
+ fprintf(stderr, "delete: invalid pointer %p\n", pointer);
+}
+
+void operator delete[](void* pointer)
+{
+ operator delete(pointer);
+}
+
+// Some older compilers like Borland C++ Compiler 5.5.1 and Digital Mars
+// Compiler 8.29 do not support placement delete operators.
+// NO_PLACEMENT_DELETE needs to be defined when using such compilers.
+// Also note that in that case memory leakage will occur if an exception
+// is thrown in the initialization (constructor) of a dynamically
+// created object.
+#ifndef NO_PLACEMENT_DELETE
+void operator delete(void* pointer, const char* file, int line)
+{
+ if (new_verbose_flag)
+ printf("info: exception thrown on initializing object at %p (%s:%d)\n",
+ pointer, file, line);
+ operator delete(pointer);
+}
+
+void operator delete[](void* pointer, const char* file, int line)
+{
+ operator delete(pointer, file, line);
+}
+
+void operator delete(void* pointer, const std::nothrow_t&)
+{
+ operator delete(pointer);
+}
+
+void operator delete[](void* pointer, const std::nothrow_t&)
+{
+ operator delete(pointer, std::nothrow);
+}
+
+unsigned int PrintMemTotalSize()
+{
+ printf("\nNOW Allocate MEM SIZE ---- [0x%x]---\n", total_size);
+ return total_size;
+}
+
+#endif // NO_PLACEMENT_DELETE
+
+//// Proxy class to automatically call check_leaks if new_autocheck_flag is set
+//class new_check_t
+//{
+//public:
+// new_check_t() {}
+// ~new_check_t()
+// {
+// if (new_autocheck_flag)
+// {
+// // Check for leakage.
+// // If any leaks are found, set new_verbose_flag so that any
+// // delete operations in the destruction of global/static
+// // objects will display information to compensate for
+// // possible false leakage reports.
+// if (check_leaks())
+// new_verbose_flag = true;
+// }
+// }
+//};
+//static new_check_t new_check_object;
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/debug-new/debug_new.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/debug-new/debug_new.h b/thirdparty/pcap++/3rdParty/debug-new/debug_new.h
new file mode 100644
index 0000000..432641a
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/debug-new/debug_new.h
@@ -0,0 +1,76 @@
+/*
+ * debug_new.h 1.7 2003/07/03
+ *
+ * Header file for checking leakage by operator new
+ *
+ * By Wu Yongwei
+ *
+ */
+
+#ifndef _DEBUG_NEW_H
+#define _DEBUG_NEW_H
+
+#include <new>
+
+/* Prototypes */
+void start_leak_check();
+bool check_leaks();
+void* operator new(size_t size, const char* file, int line);
+void* operator new[](size_t size, const char* file, int line);
+#ifndef NO_PLACEMENT_DELETE
+void operator delete(void* pointer, const char* file, int line);
+void operator delete[](void* pointer, const char* file, int line);
+#endif // NO_PLACEMENT_DELETE
+void operator delete[](void*); // MSVC 6 requires this declaration
+
+/* Macros */
+#ifndef DEBUG_NEW_NO_NEW_REDEFINITION
+#define new DEBUG_NEW
+#define DEBUG_NEW new(__FILE__, __LINE__)
+#define debug_new new
+#else
+#define debug_new new(__FILE__, __LINE__)
+#endif // DEBUG_NEW_NO_NEW_REDEFINITION
+#ifdef DEBUG_NEW_EMULATE_MALLOC
+#include <stdlib.h>
+#define malloc(s) ((void*)(debug_new char[s]))
+#define free(p) delete[] (char*)(p)
+#endif // DEBUG_NEW_EMULATE_MALLOC
+
+/* Control flags */
+extern bool new_verbose_flag; // default to false: no verbose information
+extern bool new_autocheck_flag; // default to true: call check_leaks() on exit
+
+class debug_new_counter
+{
+ static int _S_count;
+public:
+ debug_new_counter()
+ {
+ ++_S_count;
+ }
+
+ ~debug_new_counter()
+ {
+ if (--_S_count == 0 && new_autocheck_flag)
+ if (check_leaks())
+ {
+ new_verbose_flag = true;
+ #if defined(__GNUC__) && __GNUC__ == 3
+ if (!getenv("GLIBCPP_FORCE_NEW") && !getenv("GLIBCXX_FORCE_NEW"))
+ fprintf(new_output_fp,
+ "*** WARNING: GCC 3 is detected, please make sure the environment\n"
+ " variable GLIBCPP_FORCE_NEW (GCC 3.2 and 3.3) or GLIBCXX_FORCE_NEW\n"
+ " (GCC 3.4) is defined. Check the README file for details.\n");
+ #endif
+ }
+ }
+
+};
+
+int debug_new_counter::_S_count = 0;
+
+/** Counting object for each file including debug_new.h. */
+static debug_new_counter __debug_new_count;
+
+#endif // _DEBUG_NEW_H
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/.gitignore
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/.gitignore b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/.gitignore
new file mode 100644
index 0000000..6646021
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/.gitignore
@@ -0,0 +1,23 @@
+*.vcproj
+CMakeCache.txt
+CMakeFiles
+CTestTestfile.cmake
+DartConfiguration.tcl
+cmake_install.cmake
+Testing
+Debug
+Release
+dirent.sln
+dirent.ncb
+dirent.suo
+*.dir
+locate.db
+Makefile
+t-compile
+t-dirent
+find
+ls
+locate
+updatedb
+*.user
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/CMakeLists.txt b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/CMakeLists.txt
new file mode 100644
index 0000000..c6c5d79
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required (VERSION 2.8.11)
+project (dirent)
+
+enable_language (C)
+
+# Only use the dirent file on windows systems
+if (WIN32)
+ include_directories (${CMAKE_SOURCE_DIR}/include)
+ install (FILES include/dirent.h DESTINATION include)
+else()
+ cmake_policy(SET CMP0037 OLD) # Supress warnings about fake install
+ add_custom_target(install) # Fake install target
+endif()
+
+# Build example programs
+add_executable (find examples/find.c)
+add_executable (ls examples/ls.c)
+add_executable (locate examples/locate.c)
+add_executable (updatedb examples/updatedb.c)
+
+# Build test programs
+include (CTest)
+add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})
+function (add_test_executable TEST_NAME)
+ add_executable (${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
+ add_test (NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND $<TARGET_FILE:${TEST_NAME}>)
+ add_dependencies (check ${TEST_NAME})
+endfunction (add_test_executable)
+
+add_test_executable (t-compile tests/t-compile.c)
+add_test_executable (t-dirent tests/t-dirent.c)
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/ChangeLog
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/ChangeLog b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/ChangeLog
new file mode 100644
index 0000000..a1e4bb7
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/ChangeLog
@@ -0,0 +1,117 @@
+2016-09-11 Toni Rönkkö
+
+ * Version 1.22: added support for CMake. Thanks to Paul Fultz II.
+
+2014-09-25 Toni Rönkkö
+
+ * Version 1.21: compiles correctly under Open Watcom. Thanks to
+ Virgil Banowetz for a patch!
+
+2014-04-07 Toni Rönkkö
+
+ * Version 1.20.1: the zip file from the previous version did not open
+ correctly with Microsoft's compressed folders. Thanks to Alexandre
+ for info!
+
+2014-03-17 Toni Ronkko
+
+ * Version 1.20: dirent.h compiles correctly in 64-bit architecture.
+ Thanks to Aaron Simmons!
+
+2014-03-03 Toni Ronkko
+
+ * Version 1.13.2: define DT_LNK for compatibility with Unix
+ programs. Thanks to Joel Bruick for suggestion!
+
+2013-01-27 Toni Ronkko
+
+ * Version 1.13.1: patch from Edward Berner fixes set_errno() on
+ Windows NT 4.0.
+
+ * Revised wcstombs() and mbstowcs() wrappers to make sure that they do
+ not write past their target string.
+
+ * PATH_MAX from windows.h includes zero terminator so there is no
+ need to add one extra byte to variables and structures.
+
+2012-12-12 Toni Ronkko
+
+ * Version 1.13: use the traditional 8+3 file naming scheme if a file
+ name cannot be represented in the default ANSI code page. Now
+ compiles again with MSVC 6.0. Thanks to Konstantin Khomoutov for
+ testing.
+
+2012-10-01 Toni Ronkko
+
+ * Version 1.12.1: renamed wide-character DIR structure _wDIR to
+ _WDIR (with capital W) in order to maintain compatibility with MingW.
+
+2012-09-30 Toni Ronkko
+
+ * Version 1.12: define PATH_MAX and NAME_MAX. Added wide-character
+ variants _wDIR, _wdirent, _wopendir(), _wreaddir(), _wclosedir() and
+ _wrewinddir(). Thanks to Edgar Buerkle and Jan Nijtmans for ideas
+ and code.
+
+ * Now avoiding windows.h. This allows dirent.h to be integrated
+ more easily into programs using winsock. Thanks to Fernando
+ Azaldegui.
+
+2011-03-15 Toni Ronkko
+
+ * Version 1.11: defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.
+
+2010-08-11 Toni Ronkko
+
+ * Version 1.10: added d_type and d_namlen fields to dirent structure.
+ The former is especially useful for determining whether directory
+ entry represents a file or a directory. For more information, see
+ http://www.delorie.com/gnu/docs/glibc/libc_270.html
+
+ * Improved conformance to the standards. For example, errno is now
+ set properly on failure and assert() is never used. Thanks to Peter
+ Brockam for suggestions.
+
+ * Fixed a bug in rewinddir(): when using relative directory names,
+ change of working directory no longer causes rewinddir() to fail.
+
+2009-12-15 John Cunningham
+
+ * Version 1.9: added rewinddir member function
+
+2008-01-18 Toni Ronkko
+
+ * Version 1.8: Using FindFirstFileA and WIN32_FIND_DATAA to avoid
+ converting string between multi-byte and unicode representations.
+ This makes the code simpler and also allows the code to be compiled
+ under MingW. Thanks to Azriel Fasten for the suggestion.
+
+2007-03-04 Toni Ronkko
+
+ * Bug fix: due to the strncpy_s() function this file only compiled in
+ Visual Studio 2005. Using the new string functions only when the
+ compiler version allows.
+
+2006-11-02 Toni Ronkko
+
+ * Major update: removed support for Watcom C, MS-DOS and Turbo C to
+ simplify the file, updated the code to compile cleanly on Visual
+ Studio 2005 with both unicode and multi-byte character strings,
+ removed rewinddir() as it had a bug.
+
+2006-08-20 Toni Ronkko
+
+ * Removed all remarks about MSVC 1.0, which is antiqued now.
+ Simplified comments by removing SGML tags.
+
+2002-05-14 Toni Ronkko
+
+ * Embedded the function definitions directly to the header so that no
+ source modules need to be included in the Visual Studio project.
+ Removed all the dependencies to other projects so that this header
+ file can be used independently.
+
+1998-05-28 Toni Ronkko
+
+ * First version.
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/LICENSE
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/LICENSE b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/LICENSE
new file mode 100644
index 0000000..86a4351
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Toni Rönkkö
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/Makefile.linux
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/Makefile.linux b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/Makefile.linux
new file mode 100644
index 0000000..287eb69
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/Makefile.linux
@@ -0,0 +1,69 @@
+# This Makefile will pack dirent into a distributable zip
+# package. To build the package, invoke this Makefile as
+#
+# make -f Makefile.linux dist
+#
+
+# Current cersion number
+VERSION=1.22
+
+# List of files to include in zip package
+DIST_FILES = include/*.h examples/*.c tests/*.c tests/1/file tests/1/dir/* tests/2/* CMakeLists.txt ChangeLog README.md
+
+# Default target
+all: ls find
+
+# Build Linux versions of example programs
+ls: examples/ls.c
+ gcc -W -Wall -o ls examples/ls.c
+
+find: examples/find.c
+ gcc -W -Wall -o find examples/find.c
+
+# Run regression tests
+check: t-dirent
+ ./t-dirent
+
+t-dirent: tests/t-dirent.c
+ gcc -W -Wall -o t-dirent tests/t-dirent.c
+
+# Show usage
+help:
+ @echo "Build targets available:"
+ @echo " clean Remove temporary files"
+ @echo " dist Build distributable package"
+ @echo " check Run regression tests"
+
+# Wipe out temporary files left behind by MS-Visual Studio and CMake
+clean:
+ rm -f ls find t-dirent t-compile locate updatedb
+ rm -fr Debug Release Testing
+ rm -fr *.dir
+ rm -f *.vcproj *.user
+ rm -fr CMakeFiles
+ rm -f CMakeCache.txt CTestTestfile.cmake cmake_install.cmake
+ rm -f dirent.ncb dirent.sln dirent.suo
+ rm -f DartConfiguration.tcl locate.db Makefile
+ rm -fr dirent-$(VERSION)
+ rm -f dirent-*.zip
+
+# Build installation package
+dist: dirent-$(VERSION).zip
+dirent-$(VERSION).zip: $(DIST_FILES)
+ rm -f dirent-$(VERSION).zip
+ rm -fr dirent-$(VERSION)
+ mkdir dirent-$(VERSION)
+ for f in $(DIST_FILES); do \
+ dir=`echo "$$f" | sed -e 's:^[^/]*$$::' -e 's://*[^/]*$$::' -e 's:^$$:.:'`; \
+ if [ -d "dirent-$(VERSION)/$$dir" ]; then \
+ :; \
+ else \
+ mkdir "dirent-$(VERSION)/$$dir"; \
+ chmod 0755 "dirent-$(VERSION)/$$dir"; \
+ fi; \
+ cp "$$f" "dirent-$(VERSION)/$$dir/"; \
+ chmod 0644 "dirent-$(VERSION)/$$f"; \
+ done
+ ( cd dirent-$(VERSION) && zip -r ../dirent-$(VERSION).zip . )
+ rm -fr dirent-$(VERSION)
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/README.md
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/README.md b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/README.md
new file mode 100644
index 0000000..8ba3703
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/README.md
@@ -0,0 +1,77 @@
+# Dirent
+Dirent is a C/C++ programming interface that allows programmers to retrieve
+information about files and directories under Linux/UNIX. This project
+provides Linux compatible Dirent interface for Microsoft Windows.
+
+
+# Installation
+
+Download the latest Dirent installation package from
+[softagalleria.net](http://softagalleria.net/download/dirent/?C=M;O=D)
+
+Unpack the installation file with 7-zip, for example. The installation
+package contains dirent.h file as well as a few example programs.
+
+
+## Install Dirent for All Programs
+
+To make dirent.h available for all C/C++ programs, simply copy the
+``include/dirent.h`` file to the system include directory. System include
+directory contains header files such as assert.h and windows.h. In Visual
+Studio 2008, for example, the system include may be found at
+``C:\Program Files\Microsoft Visual Studio 9.0\VC\include``.
+
+Everything you need is included in the single dirent.h file, and you can
+start using Dirent immediately -- there is no need to add files to your
+Visual Studio project.
+
+
+## Embed Dirent into Your Own Project
+
+If you wish to distribute dirent.h alongside with your own source code, then
+copy ``include/dirent.h`` file to a new sub-directory within your project and
+add that directory to include path on Windows while omitting the directory
+under Linux/UNIX. This allows your project to be compiled against native
+dirent.h on Linux/UNIX while substituting the functionality on Microsoft
+Windows.
+
+
+## Building Example Programs
+
+The installation package contains some example programs and tests under
+the directories examples and tests. To run these programs, install
+[CMake](https://cmake.org/)
+
+Open command prompt, navigate to dirent directory with cd and generate
+build files as
+
+```
+cmake .
+```
+
+Load the generated dirent.sln file into Visual Studio and build the
+solution. Run the example programs from command prompt as
+
+```
+Debug\updatedb c:\
+Debug\locate cmd.exe
+Debug\ls .
+Debug\find .
+```
+
+
+# Copying
+
+Dirent may be freely distributed under the MIT license. See the LICENSE
+file for details.
+
+
+# Alternatives to Dirent
+
+I ported Dirent to Microsoft Windows in 1998 when only a few alternatives
+were available. However, the situation has changed since then and nowadays
+both [Cygwin](http://www.cygwin.com) and [MingW](http://www.mingw.org)
+allow you to compile a great number of UNIX programs in Microsoft Windows.
+They both provide a full dirent API as well as many other UNIX APIs. MingW
+can even be used for commercial applications!
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/find.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/find.c b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/find.c
new file mode 100644
index 0000000..3e7f984
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/find.c
@@ -0,0 +1,144 @@
+/*
+ * An example demonstrating recursive directory traversal.
+ *
+ * Compile this file with Visual Studio 2008 project vs2008.sln and run
+ * the produced command in console with a directory name argument. For
+ * example, command
+ *
+ * find "C:\Program Files"
+ *
+ * might produce a listing with thousands of entries such as
+ *
+ * c:\Program Files/7-Zip/7-zip.chm
+ * c:\Program Files/7-Zip/7-zip.dll
+ * c:\Program Files/7-Zip/7z.dll
+ * c:\Program Files/Adobe/Reader 10.0/Reader/logsession.dll
+ * c:\Program Files/Adobe/Reader 10.0/Reader/LogTransport2.exe
+ * c:\Program Files/Windows NT/Accessories/wordpad.exe
+ * c:\Program Files/Windows NT/Accessories/write.wpc
+ *
+ * The find command provided by this file is only an example. That is,
+ * the command does not provide options to restrict the output to certain
+ * files as the Linux version does.
+ *
+ * Copyright (C) 2006-2012 Toni Ronkko
+ * This file is part of dirent. Dirent may be freely distributed
+ * under the MIT license. For all details and documentation, see
+ * https://github.com/tronkko/dirent
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+
+static int find_directory (const char *dirname);
+
+
+int
+main(
+ int argc, char *argv[])
+{
+ int i;
+ int ok;
+
+ /* For each directory in command line */
+ i = 1;
+ while (i < argc) {
+ ok = find_directory (argv[i]);
+ if (!ok) {
+ exit (EXIT_FAILURE);
+ }
+ i++;
+ }
+
+ /* List current working directory if no arguments on command line */
+ if (argc == 1) {
+ find_directory (".");
+ }
+ return EXIT_SUCCESS;
+}
+
+/* Find files and subdirectories recursively */
+static int
+find_directory(
+ const char *dirname)
+{
+ DIR *dir;
+ char buffer[PATH_MAX + 2];
+ char *p = buffer;
+ const char *src;
+ char *end = &buffer[PATH_MAX];
+ int ok;
+
+ /* Copy directory name to buffer */
+ src = dirname;
+ while (p < end && *src != '\0') {
+ *p++ = *src++;
+ }
+ *p = '\0';
+
+ /* Open directory stream */
+ dir = opendir (dirname);
+ if (dir != NULL) {
+ struct dirent *ent;
+
+ /* Print all files and directories within the directory */
+ while ((ent = readdir (dir)) != NULL) {
+ char *q = p;
+ char c;
+
+ /* Get final character of directory name */
+ if (buffer < q) {
+ c = q[-1];
+ } else {
+ c = ':';
+ }
+
+ /* Append directory separator if not already there */
+ if (c != ':' && c != '/' && c != '\\') {
+ *q++ = '/';
+ }
+
+ /* Append file name */
+ src = ent->d_name;
+ while (q < end && *src != '\0') {
+ *q++ = *src++;
+ }
+ *q = '\0';
+
+ /* Decide what to do with the directory entry */
+ switch (ent->d_type) {
+ case DT_LNK:
+ case DT_REG:
+ /* Output file name with directory */
+ printf ("%s\n", buffer);
+ break;
+
+ case DT_DIR:
+ /* Scan sub-directory recursively */
+ if (strcmp (ent->d_name, ".") != 0
+ && strcmp (ent->d_name, "..") != 0) {
+ find_directory (buffer);
+ }
+ break;
+
+ default:
+ /* Ignore device entries */
+ /*NOP*/;
+ }
+
+ }
+
+ closedir (dir);
+ ok = 1;
+
+ } else {
+ /* Could not open directory */
+ printf ("Cannot open directory %s\n", dirname);
+ ok = 0;
+ }
+
+ return ok;
+}
+
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/locate.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/locate.c b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/locate.c
new file mode 100644
index 0000000..b05b46d
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/locate.c
@@ -0,0 +1,281 @@
+/*
+ * A file look-up utility to complement updatedb
+ *
+ * Compile and run updatedb first to create locate.db file. Then, compile
+ * this program with the same Visual Studio 2008 project file and run the
+ * program in console with a file name argument. For example, command
+ *
+ * locate autoexec
+ *
+ * might output
+ *
+ * c:/AUTOEXEC.BAT
+ * c:/WINDOWS/repair/autoexec.nt
+ * c:/WINDOWS/system32/AUTOEXEC.NT
+ *
+ * Be ware that this file uses wide-character API which is not compatible
+ * with Linux or other major Unixes.
+ *
+ * Copyright (C) 2006-2012 Toni Ronkko
+ * This file is part of dirent. Dirent may be freely distributed
+ * under the MIT license. For all details and documentation, see
+ * https://github.com/tronkko/dirent
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#ifdef WIN32
+# include <io.h>
+# include <fcntl.h>
+#endif
+#include <dirent.h>
+
+/* File name and location of database file */
+#define DB_LOCATION L"locate.db"
+
+
+/* Forward-decl */
+static int db_locate (const wchar_t *pattern);
+static int db_match (const wchar_t *fn, const wchar_t *pattern);
+static void db_open (void);
+static void db_close (void);
+static int db_read (wchar_t *buffer, size_t max);
+
+
+/* Module local variables */
+static FILE *db = NULL;
+
+
+int
+main(
+ int argc, char *argv[])
+{
+#ifdef WIN32
+ int i;
+
+ /* Prepare for unicode output */
+ _setmode (_fileno (stdout), _O_U16TEXT);
+
+ /* For each pattern in command line */
+ i = 1;
+ while (i < argc) {
+ wchar_t buffer[PATH_MAX + 1];
+ errno_t error;
+ size_t n;
+ int count = 0;
+
+ /* Convert ith argument to wide-character string */
+ error = mbstowcs_s (&n, buffer, PATH_MAX, argv[i], _TRUNCATE);
+ if (!error) {
+ /* Find files matching pattern */
+ count = db_locate (buffer);
+
+ /* Output warnign if string is not found */
+ if (count == 0) {
+ wprintf (L"%s not found\n", buffer);
+ }
+ }
+
+
+ i++;
+ }
+
+ if (argc < 2) {
+ wprintf (L"Usage: locate pattern\n");
+ exit (EXIT_FAILURE);
+ }
+#else
+ printf ("locate only works on Microsoft Windows\n");
+#endif
+
+ return EXIT_SUCCESS;
+}
+
+/* Match pattern against files in locate.db file */
+static int
+db_locate(
+ const wchar_t *pattern)
+{
+ int count = 0;
+
+#ifdef WIN32
+ wchar_t buffer[PATH_MAX + 1];
+
+ /* Open locate.db for read */
+ db_open ();
+
+ /* Read one directory and file name at a time from database file */
+ while (db_read (buffer, PATH_MAX)) {
+ /* See if file name in buffer matches the search pattern */
+ if (db_match (buffer, pattern)) {
+ /* Match found => output file name and path */
+ wprintf (L"%s\n", buffer);
+ count++;
+ }
+
+ }
+
+ db_close ();
+#endif
+
+ return count;
+}
+
+/* Match pattern against file name */
+static int
+db_match(
+ const wchar_t *fn, const wchar_t *pattern)
+{
+ int found = 0;
+
+#ifdef WIN32
+ wchar_t *p;
+ wchar_t base[PATH_MAX + 1];
+ wchar_t patt[PATH_MAX + 1];
+ int i;
+ int done = 0;
+
+ /* Locate zero-terminator from fn */
+ p = wcschr (fn, '\0');
+
+ /* Find base name from buffer */
+ while (fn < p && !done) {
+ switch (p[-1]) {
+ case ':':
+ case '/':
+ case '\\':
+ /* Final path separator found */
+ done = 1;
+ break;
+
+ default:
+ /* No path separator yet */
+ p--;
+ }
+ }
+
+ /* Convert base name to lower case */
+ i = 0;
+ while (i < PATH_MAX && p[i] != '\0') {
+ base[i] = towlower (p[i]);
+ i++;
+ }
+ base[i] = '\0';
+
+ /* Convert search pattern to lower case */
+ i = 0;
+ while (i < PATH_MAX && pattern[i] != '\0') {
+ patt[i] = towlower (pattern[i]);
+ i++;
+ }
+ patt[i] = '\0';
+
+ /* See if file name matches pattern */
+ if (wcsstr (base, patt) != NULL) {
+ found = 1;
+ } else {
+ found = 0;
+ }
+#endif
+
+ return found;
+}
+
+/*
+ * Read line from locate.db. This function is same as fgetws() except
+ * that new-line at the end of line is not included.
+ */
+static int
+db_read(
+ wchar_t *buffer, size_t max)
+{
+ int ok = 0;
+
+#ifdef WIN32
+ size_t i = 0;
+ wchar_t c;
+ int done = 0;
+
+ do {
+ /* Read wide-character from stream */
+ if (db) {
+ c = fgetwc (db);
+ } else {
+ wprintf (L"Database not open\n");
+ exit (EXIT_SUCCESS);
+ }
+
+ /* Determine how to process character */
+ switch (c) {
+ case '\r':
+ /* Ignore, should be handled by run-time libraries */
+ /*NOP*/;
+ break;
+
+ case '\n':
+ /* End of string => return file name and true */
+ done = 1;
+ ok = 1;
+ break;
+
+ case /*EOF*/WEOF:
+ /* End of file */
+ done = 1;
+ if (i == 0) {
+ /* No data in buffer => return false to indicate EOF */
+ ok = 0;
+ } else {
+ /* Data in buffer => return true */
+ ok = 1;
+ }
+ break;
+
+ default:
+ /* Store character */
+ if (i < max - 1) {
+ buffer[i++] = c;
+ } else {
+ wprintf (L"Buffer too small");
+ exit (EXIT_FAILURE);
+ }
+ }
+ } while (!done);
+
+ /* Zero-terminate buffer */
+ buffer[i] = '\0';
+#endif
+
+ return ok;
+}
+
+/* Open database file locate.db */
+static void
+db_open(
+ void)
+{
+#ifdef WIN32
+ if (db == NULL) {
+ errno_t error;
+
+ /* Open file for writing */
+ error = _wfopen_s (&db, DB_LOCATION, L"rt, ccs=UNICODE");
+ if (error) {
+ wprintf (L"Cannot open %s\n", DB_LOCATION);
+ exit (EXIT_FAILURE);
+ }
+ }
+#endif
+}
+
+/* Close database file */
+static void
+db_close(
+ void)
+{
+ if (db) {
+ fclose (db);
+ db = NULL;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/ls.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/ls.c b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/ls.c
new file mode 100644
index 0000000..1b67729
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/ls.c
@@ -0,0 +1,99 @@
+/*
+ * An example demonstrating basic directory listing.
+ *
+ * Compile this file with Visual Studio 2008 project vs2008.sln and run the
+ * produced command in console with a directory name argument. For example,
+ * command
+ *
+ * ls "c:\Program Files"
+ *
+ * might output something like
+ *
+ * ./
+ * ../
+ * 7-Zip/
+ * Internet Explorer/
+ * Microsoft Visual Studio 9.0/
+ * Microsoft.NET/
+ * Mozilla Firefox/
+ *
+ * The ls command provided by this file is only an example. That is, the
+ * command does not have any fancy options like "ls -al" in Linux and the
+ * command does not support file name matching like "ls *.c".
+ *
+ * Copyright (C) 2006-2012 Toni Ronkko
+ * This file is part of dirent. Dirent may be freely distributed
+ * under the MIT license. For all details and documentation, see
+ * https://github.com/tronkko/dirent
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+
+static void list_directory (const char *dirname);
+
+
+int
+main(
+ int argc, char *argv[])
+{
+ int i;
+
+ /* For each directory in command line */
+ i = 1;
+ while (i < argc) {
+ list_directory (argv[i]);
+ i++;
+ }
+
+ /* List current working directory if no arguments on command line */
+ if (argc == 1) {
+ list_directory (".");
+ }
+ return EXIT_SUCCESS;
+}
+
+/*
+ * List files and directories within a directory.
+ */
+static void
+list_directory(
+ const char *dirname)
+{
+ DIR *dir;
+ struct dirent *ent;
+
+ /* Open directory stream */
+ dir = opendir (dirname);
+ if (dir != NULL) {
+
+ /* Print all files and directories within the directory */
+ while ((ent = readdir (dir)) != NULL) {
+ switch (ent->d_type) {
+ case DT_REG:
+ printf ("%s\n", ent->d_name);
+ break;
+
+ case DT_DIR:
+ printf ("%s/\n", ent->d_name);
+ break;
+
+ case DT_LNK:
+ printf ("%s@\n", ent->d_name);
+ break;
+
+ default:
+ printf ("%s*\n", ent->d_name);
+ }
+ }
+
+ closedir (dir);
+
+ } else {
+ /* Could not open directory */
+ printf ("Cannot open directory %s\n", dirname);
+ exit (EXIT_FAILURE);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/updatedb.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/updatedb.c b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/updatedb.c
new file mode 100644
index 0000000..58147f9
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/examples/updatedb.c
@@ -0,0 +1,234 @@
+/*
+ * An example demonstrating wide-character functions
+ *
+ * Compile this file with Visual Studio 2008 project vs2008.sln and run
+ * the produced command in console with a directory name argument. For
+ * example, command
+ *
+ * updatedb C:\
+ *
+ * will produce file locate.db containing lines such as
+ *
+ * c:\Program Files/7-Zip/7-zip.chm
+ * c:\Program Files/7-Zip/7-zip.dll
+ * c:\Program Files/7-Zip/7z.dll
+ * c:\Program Files/Adobe/Reader 10.0/Reader/logsession.dll
+ * c:\Program Files/Adobe/Reader 10.0/Reader/LogTransport2.exe
+ * c:\Program Files/Windows NT/Accessories/wordpad.exe
+ * c:\Program Files/Windows NT/Accessories/write.wpc
+ *
+ * Be ware that this code is not compatible with Linux or other major
+ * Unixes. Linux does not even have wide-character version of dirent!
+ *
+ * Copyright (C) 2006-2012 Toni Ronkko
+ * This file is part of dirent. Dirent may be freely distributed
+ * under the MIT license. For all details and documentation, see
+ * https://github.com/tronkko/dirent
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#ifdef WIN32
+# include <io.h>
+# include <fcntl.h>
+#endif
+#include <dirent.h>
+
+/* File name and location of database file */
+#define DB_LOCATION L"locate.db"
+
+
+/* Forward-decl */
+static int update_directory (const wchar_t *dirname);
+static void db_open (void);
+static void db_close (void);
+static void db_store (const wchar_t *dirname);
+
+
+/* Module local variables */
+static FILE *db = NULL;
+
+
+int
+main(
+ int argc, char *argv[])
+{
+#ifdef WIN32
+ int i;
+ int ok;
+
+ /* Prepare for unicode output */
+ _setmode (_fileno (stdout), _O_U16TEXT);
+
+ /* Open locate.db */
+ db_open ();
+
+ /* For each directory in command line */
+ i = 1;
+ while (i < argc) {
+ wchar_t buffer[PATH_MAX + 1];
+ errno_t error;
+ size_t n;
+
+ /* Convert ith argument to wide-character string */
+ error = mbstowcs_s (&n, buffer, PATH_MAX, argv[i], _TRUNCATE);
+ if (!error) {
+
+ /* Scan directory for files */
+ ok = update_directory (buffer);
+ if (!ok) {
+ wprintf (L"Cannot open directory %s\n", buffer);
+ exit (EXIT_FAILURE);
+ }
+
+ }
+
+ i++;
+ }
+
+ /* Use current working directory if no arguments on command line */
+ if (argc == 1) {
+ update_directory (L".");
+ }
+
+ db_close ();
+#else
+ printf ("updatedb only works on Microsoft Windows\n");
+#endif
+
+ return EXIT_SUCCESS;
+}
+
+/* Find files recursively */
+static int
+update_directory(
+ const wchar_t *dirname)
+{
+ int ok = 0;
+
+#ifdef WIN32
+ _WDIR *dir;
+ wchar_t buffer[PATH_MAX + 2];
+ wchar_t *p = buffer;
+ const wchar_t *src;
+ wchar_t *end = &buffer[PATH_MAX];
+
+ /* Copy directory name to buffer */
+ src = dirname;
+ while (p < end && *src != '\0') {
+ *p++ = *src++;
+ }
+ *p = '\0';
+
+ /* Open directory stream */
+ dir = _wopendir (dirname);
+ if (dir != NULL) {
+ struct _wdirent *ent;
+
+ /* Print all files and directories within the directory */
+ while ((ent = _wreaddir (dir)) != NULL) {
+ wchar_t *q = p;
+ wchar_t c;
+
+ /* Get final character of directory name */
+ if (buffer < q) {
+ c = q[-1];
+ } else {
+ c = ':';
+ }
+
+ /* Append directory separator if not already there */
+ if (c != ':' && c != '/' && c != '\\') {
+ *q++ = '/';
+ }
+
+ /* Append file name */
+ src = ent->d_name;
+ while (q < end && *src != '\0') {
+ *q++ = *src++;
+ }
+ *q = '\0';
+
+ /* Decide what to do with the directory entry */
+ switch (ent->d_type) {
+ case DT_REG:
+ /* Store file name */
+ db_store (buffer);
+ break;
+
+ case DT_DIR:
+ /* Scan sub-directory recursively */
+ if (wcscmp (ent->d_name, L".") != 0
+ && wcscmp (ent->d_name, L"..") != 0) {
+ update_directory (buffer);
+ }
+ break;
+
+ default:
+ /* Do not device entries */
+ /*NOP*/;
+ }
+
+ }
+
+ wclosedir (dir);
+ ok = 1;
+
+ } else {
+
+ /* Cannot open directory */
+ ok = 0;
+
+ }
+#endif
+
+ return ok;
+}
+
+/* Store file name to locate.db */
+static void
+db_store(
+ const wchar_t *dirname)
+{
+#ifdef WIN32
+ if (db) {
+ /* Output line to file */
+ fwprintf (db, L"%s\n", dirname);
+ } else {
+ wprintf (L"Database not open\n");
+ exit (EXIT_FAILURE);
+ }
+#endif
+}
+
+/* Open database file locate.db */
+static void
+db_open(
+ void)
+{
+#ifdef WIN32
+ if (db == NULL) {
+ errno_t error;
+
+ /* Open file for writing */
+ error = _wfopen_s (&db, DB_LOCATION, L"wt, ccs=UNICODE");
+ if (error) {
+ wprintf (L"Cannot open %s\n", DB_LOCATION);
+ exit (EXIT_FAILURE);
+ }
+ }
+#endif
+}
+
+/* Close database file */
+static void
+db_close(
+ void)
+{
+ if (db) {
+ fclose (db);
+ db = NULL;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/include/dirent.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/include/dirent.h b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/include/dirent.h
new file mode 100644
index 0000000..ad9d2b3
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/include/dirent.h
@@ -0,0 +1,929 @@
+/*
+ * Dirent interface for Microsoft Visual Studio
+ * Version 1.21
+ *
+ * Copyright (C) 2006-2012 Toni Ronkko
+ * This file is part of dirent. Dirent may be freely distributed
+ * under the MIT license. For all details and documentation, see
+ * https://github.com/tronkko/dirent
+ */
+#ifndef DIRENT_H
+#define DIRENT_H
+
+/*
+ * Include windows.h without Windows Sockets 1.1 to prevent conflicts with
+ * Windows Sockets 2.0.
+ */
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <wchar.h>
+#include <string.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+/* Indicates that d_type field is available in dirent structure */
+#define _DIRENT_HAVE_D_TYPE
+
+/* Indicates that d_namlen field is available in dirent structure */
+#define _DIRENT_HAVE_D_NAMLEN
+
+/* Entries missing from MSVC 6.0 */
+#if !defined(FILE_ATTRIBUTE_DEVICE)
+# define FILE_ATTRIBUTE_DEVICE 0x40
+#endif
+
+/* File type and permission flags for stat(), general mask */
+#if !defined(S_IFMT)
+# define S_IFMT _S_IFMT
+#endif
+
+/* Directory bit */
+#if !defined(S_IFDIR)
+# define S_IFDIR _S_IFDIR
+#endif
+
+/* Character device bit */
+#if !defined(S_IFCHR)
+# define S_IFCHR _S_IFCHR
+#endif
+
+/* Pipe bit */
+#if !defined(S_IFFIFO)
+# define S_IFFIFO _S_IFFIFO
+#endif
+
+/* Regular file bit */
+#if !defined(S_IFREG)
+# define S_IFREG _S_IFREG
+#endif
+
+/* Read permission */
+#if !defined(S_IREAD)
+# define S_IREAD _S_IREAD
+#endif
+
+/* Write permission */
+#if !defined(S_IWRITE)
+# define S_IWRITE _S_IWRITE
+#endif
+
+/* Execute permission */
+#if !defined(S_IEXEC)
+# define S_IEXEC _S_IEXEC
+#endif
+
+/* Pipe */
+#if !defined(S_IFIFO)
+# define S_IFIFO _S_IFIFO
+#endif
+
+/* Block device */
+#if !defined(S_IFBLK)
+# define S_IFBLK 0
+#endif
+
+/* Link */
+#if !defined(S_IFLNK)
+# define S_IFLNK 0
+#endif
+
+/* Socket */
+#if !defined(S_IFSOCK)
+# define S_IFSOCK 0
+#endif
+
+/* Read user permission */
+#if !defined(S_IRUSR)
+# define S_IRUSR S_IREAD
+#endif
+
+/* Write user permission */
+#if !defined(S_IWUSR)
+# define S_IWUSR S_IWRITE
+#endif
+
+/* Execute user permission */
+#if !defined(S_IXUSR)
+# define S_IXUSR 0
+#endif
+
+/* Read group permission */
+#if !defined(S_IRGRP)
+# define S_IRGRP 0
+#endif
+
+/* Write group permission */
+#if !defined(S_IWGRP)
+# define S_IWGRP 0
+#endif
+
+/* Execute group permission */
+#if !defined(S_IXGRP)
+# define S_IXGRP 0
+#endif
+
+/* Read others permission */
+#if !defined(S_IROTH)
+# define S_IROTH 0
+#endif
+
+/* Write others permission */
+#if !defined(S_IWOTH)
+# define S_IWOTH 0
+#endif
+
+/* Execute others permission */
+#if !defined(S_IXOTH)
+# define S_IXOTH 0
+#endif
+
+/* Maximum length of file name */
+#if !defined(PATH_MAX)
+# define PATH_MAX MAX_PATH
+#endif
+#if !defined(FILENAME_MAX)
+# define FILENAME_MAX MAX_PATH
+#endif
+#if !defined(NAME_MAX)
+# define NAME_MAX FILENAME_MAX
+#endif
+
+/* File type flags for d_type */
+#define DT_UNKNOWN 0
+#define DT_REG S_IFREG
+#define DT_DIR S_IFDIR
+#define DT_FIFO S_IFIFO
+#define DT_SOCK S_IFSOCK
+#define DT_CHR S_IFCHR
+#define DT_BLK S_IFBLK
+#define DT_LNK S_IFLNK
+
+/* Macros for converting between st_mode and d_type */
+#define IFTODT(mode) ((mode) & S_IFMT)
+#define DTTOIF(type) (type)
+
+/*
+ * File type macros. Note that block devices, sockets and links cannot be
+ * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
+ * only defined for compatibility. These macros should always return false
+ * on Windows.
+ */
+#if !defined(S_ISFIFO)
+# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
+#endif
+#if !defined(S_ISDIR)
+# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
+#if !defined(S_ISREG)
+# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+#if !defined(S_ISLNK)
+# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
+#endif
+#if !defined(S_ISSOCK)
+# define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
+#endif
+#if !defined(S_ISCHR)
+# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
+#endif
+#if !defined(S_ISBLK)
+# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
+#endif
+
+/* Return the exact length of d_namlen without zero terminator */
+#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
+
+/* Return number of bytes needed to store d_namlen */
+#define _D_ALLOC_NAMLEN(p) (PATH_MAX)
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Wide-character version */
+struct _wdirent {
+ /* Always zero */
+ long d_ino;
+
+ /* Structure size */
+ unsigned short d_reclen;
+
+ /* Length of name without \0 */
+ size_t d_namlen;
+
+ /* File type */
+ int d_type;
+
+ /* File name */
+ wchar_t d_name[PATH_MAX];
+};
+typedef struct _wdirent _wdirent;
+
+struct _WDIR {
+ /* Current directory entry */
+ struct _wdirent ent;
+
+ /* Private file data */
+ WIN32_FIND_DATAW data;
+
+ /* True if data is valid */
+ int cached;
+
+ /* Win32 search handle */
+ HANDLE handle;
+
+ /* Initial directory name */
+ wchar_t *patt;
+};
+typedef struct _WDIR _WDIR;
+
+static _WDIR *_wopendir (const wchar_t *dirname);
+static struct _wdirent *_wreaddir (_WDIR *dirp);
+static int _wclosedir (_WDIR *dirp);
+static void _wrewinddir (_WDIR* dirp);
+
+
+/* For compatibility with Symbian */
+#define wdirent _wdirent
+#define WDIR _WDIR
+#define wopendir _wopendir
+#define wreaddir _wreaddir
+#define wclosedir _wclosedir
+#define wrewinddir _wrewinddir
+
+
+/* Multi-byte character versions */
+struct dirent {
+ /* Always zero */
+ long d_ino;
+
+ /* Structure size */
+ unsigned short d_reclen;
+
+ /* Length of name without \0 */
+ size_t d_namlen;
+
+ /* File type */
+ int d_type;
+
+ /* File name */
+ char d_name[PATH_MAX];
+};
+typedef struct dirent dirent;
+
+struct DIR {
+ struct dirent ent;
+ struct _WDIR *wdirp;
+};
+typedef struct DIR DIR;
+
+static DIR *opendir (const char *dirname);
+static struct dirent *readdir (DIR *dirp);
+static int closedir (DIR *dirp);
+static void rewinddir (DIR* dirp);
+
+
+/* Internal utility functions */
+static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp);
+static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp);
+
+static int dirent_mbstowcs_s(
+ size_t *pReturnValue,
+ wchar_t *wcstr,
+ size_t sizeInWords,
+ const char *mbstr,
+ size_t count);
+
+static int dirent_wcstombs_s(
+ size_t *pReturnValue,
+ char *mbstr,
+ size_t sizeInBytes,
+ const wchar_t *wcstr,
+ size_t count);
+
+static void dirent_set_errno (int error);
+
+/*
+ * Open directory stream DIRNAME for read and return a pointer to the
+ * internal working area that is used to retrieve individual directory
+ * entries.
+ */
+static _WDIR*
+_wopendir(
+ const wchar_t *dirname)
+{
+ _WDIR *dirp = NULL;
+ int error;
+
+ /* Must have directory name */
+ if (dirname == NULL || dirname[0] == '\0') {
+ dirent_set_errno (ENOENT);
+ return NULL;
+ }
+
+ /* Allocate new _WDIR structure */
+ dirp = (_WDIR*) malloc (sizeof (struct _WDIR));
+ if (dirp != NULL) {
+ DWORD n;
+
+ /* Reset _WDIR structure */
+ dirp->handle = INVALID_HANDLE_VALUE;
+ dirp->patt = NULL;
+ dirp->cached = 0;
+
+ /* Compute the length of full path plus zero terminator
+ *
+ * Note that on WinRT there's no way to convert relative paths
+ * into absolute paths, so just assume its an absolute path.
+ */
+# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+ n = wcslen(dirname);
+# else
+ n = GetFullPathNameW (dirname, 0, NULL, NULL);
+# endif
+
+ /* Allocate room for absolute directory name and search pattern */
+ dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16);
+ if (dirp->patt) {
+
+ /*
+ * Convert relative directory name to an absolute one. This
+ * allows rewinddir() to function correctly even when current
+ * working directory is changed between opendir() and rewinddir().
+ *
+ * Note that on WinRT there's no way to convert relative paths
+ * into absolute paths, so just assume its an absolute path.
+ */
+# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+ wcsncpy_s(dirp->patt, n+1, dirname, n);
+# else
+ n = GetFullPathNameW (dirname, n, dirp->patt, NULL);
+# endif
+ if (n > 0) {
+ wchar_t *p;
+
+ /* Append search pattern \* to the directory name */
+ p = dirp->patt + n;
+ if (dirp->patt < p) {
+ switch (p[-1]) {
+ case '\\':
+ case '/':
+ case ':':
+ /* Directory ends in path separator, e.g. c:\temp\ */
+ /*NOP*/;
+ break;
+
+ default:
+ /* Directory name doesn't end in path separator */
+ *p++ = '\\';
+ }
+ }
+ *p++ = '*';
+ *p = '\0';
+
+ /* Open directory stream and retrieve the first entry */
+ if (dirent_first (dirp)) {
+ /* Directory stream opened successfully */
+ error = 0;
+ } else {
+ /* Cannot retrieve first entry */
+ error = 1;
+ dirent_set_errno (ENOENT);
+ }
+
+ } else {
+ /* Cannot retrieve full path name */
+ dirent_set_errno (ENOENT);
+ error = 1;
+ }
+
+ } else {
+ /* Cannot allocate memory for search pattern */
+ error = 1;
+ }
+
+ } else {
+ /* Cannot allocate _WDIR structure */
+ error = 1;
+ }
+
+ /* Clean up in case of error */
+ if (error && dirp) {
+ _wclosedir (dirp);
+ dirp = NULL;
+ }
+
+ return dirp;
+}
+
+/*
+ * Read next directory entry. The directory entry is returned in dirent
+ * structure in the d_name field. Individual directory entries returned by
+ * this function include regular files, sub-directories, pseudo-directories
+ * "." and ".." as well as volume labels, hidden files and system files.
+ */
+static struct _wdirent*
+_wreaddir(
+ _WDIR *dirp)
+{
+ WIN32_FIND_DATAW *datap;
+ struct _wdirent *entp;
+
+ /* Read next directory entry */
+ datap = dirent_next (dirp);
+ if (datap) {
+ size_t n;
+ DWORD attr;
+
+ /* Pointer to directory entry to return */
+ entp = &dirp->ent;
+
+ /*
+ * Copy file name as wide-character string. If the file name is too
+ * long to fit in to the destination buffer, then truncate file name
+ * to PATH_MAX characters and zero-terminate the buffer.
+ */
+ n = 0;
+ while (n + 1 < PATH_MAX && datap->cFileName[n] != 0) {
+ entp->d_name[n] = datap->cFileName[n];
+ n++;
+ }
+ dirp->ent.d_name[n] = 0;
+
+ /* Length of file name excluding zero terminator */
+ entp->d_namlen = n;
+
+ /* File type */
+ attr = datap->dwFileAttributes;
+ if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
+ entp->d_type = DT_CHR;
+ } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ entp->d_type = DT_DIR;
+ } else {
+ entp->d_type = DT_REG;
+ }
+
+ /* Reset dummy fields */
+ entp->d_ino = 0;
+ entp->d_reclen = sizeof (struct _wdirent);
+
+ } else {
+
+ /* Last directory entry read */
+ entp = NULL;
+
+ }
+
+ return entp;
+}
+
+/*
+ * Close directory stream opened by opendir() function. This invalidates the
+ * DIR structure as well as any directory entry read previously by
+ * _wreaddir().
+ */
+static int
+_wclosedir(
+ _WDIR *dirp)
+{
+ int ok;
+ if (dirp) {
+
+ /* Release search handle */
+ if (dirp->handle != INVALID_HANDLE_VALUE) {
+ FindClose (dirp->handle);
+ dirp->handle = INVALID_HANDLE_VALUE;
+ }
+
+ /* Release search pattern */
+ if (dirp->patt) {
+ free (dirp->patt);
+ dirp->patt = NULL;
+ }
+
+ /* Release directory structure */
+ free (dirp);
+ ok = /*success*/0;
+
+ } else {
+ /* Invalid directory stream */
+ dirent_set_errno (EBADF);
+ ok = /*failure*/-1;
+ }
+ return ok;
+}
+
+/*
+ * Rewind directory stream such that _wreaddir() returns the very first
+ * file name again.
+ */
+static void
+_wrewinddir(
+ _WDIR* dirp)
+{
+ if (dirp) {
+ /* Release existing search handle */
+ if (dirp->handle != INVALID_HANDLE_VALUE) {
+ FindClose (dirp->handle);
+ }
+
+ /* Open new search handle */
+ dirent_first (dirp);
+ }
+}
+
+/* Get first directory entry (internal) */
+static WIN32_FIND_DATAW*
+dirent_first(
+ _WDIR *dirp)
+{
+ WIN32_FIND_DATAW *datap;
+
+ /* Open directory and retrieve the first entry */
+ dirp->handle = FindFirstFileExW(
+ dirp->patt, FindExInfoStandard, &dirp->data,
+ FindExSearchNameMatch, NULL, 0);
+ if (dirp->handle != INVALID_HANDLE_VALUE) {
+
+ /* a directory entry is now waiting in memory */
+ datap = &dirp->data;
+ dirp->cached = 1;
+
+ } else {
+
+ /* Failed to re-open directory: no directory entry in memory */
+ dirp->cached = 0;
+ datap = NULL;
+
+ }
+ return datap;
+}
+
+/* Get next directory entry (internal) */
+static WIN32_FIND_DATAW*
+dirent_next(
+ _WDIR *dirp)
+{
+ WIN32_FIND_DATAW *p;
+
+ /* Get next directory entry */
+ if (dirp->cached != 0) {
+
+ /* A valid directory entry already in memory */
+ p = &dirp->data;
+ dirp->cached = 0;
+
+ } else if (dirp->handle != INVALID_HANDLE_VALUE) {
+
+ /* Get the next directory entry from stream */
+ if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) {
+ /* Got a file */
+ p = &dirp->data;
+ } else {
+ /* The very last entry has been processed or an error occured */
+ FindClose (dirp->handle);
+ dirp->handle = INVALID_HANDLE_VALUE;
+ p = NULL;
+ }
+
+ } else {
+
+ /* End of directory stream reached */
+ p = NULL;
+
+ }
+
+ return p;
+}
+
+/*
+ * Open directory stream using plain old C-string.
+ */
+static DIR*
+opendir(
+ const char *dirname)
+{
+ struct DIR *dirp;
+ int error;
+
+ /* Must have directory name */
+ if (dirname == NULL || dirname[0] == '\0') {
+ dirent_set_errno (ENOENT);
+ return NULL;
+ }
+
+ /* Allocate memory for DIR structure */
+ dirp = (DIR*) malloc (sizeof (struct DIR));
+ if (dirp) {
+ wchar_t wname[PATH_MAX];
+ size_t n;
+
+ /* Convert directory name to wide-character string */
+ error = dirent_mbstowcs_s (&n, wname, PATH_MAX, dirname, PATH_MAX);
+ if (!error) {
+
+ /* Open directory stream using wide-character name */
+ dirp->wdirp = _wopendir (wname);
+ if (dirp->wdirp) {
+ /* Directory stream opened */
+ error = 0;
+ } else {
+ /* Failed to open directory stream */
+ error = 1;
+ }
+
+ } else {
+ /*
+ * Cannot convert file name to wide-character string. This
+ * occurs if the string contains invalid multi-byte sequences or
+ * the output buffer is too small to contain the resulting
+ * string.
+ */
+ error = 1;
+ }
+
+ } else {
+ /* Cannot allocate DIR structure */
+ error = 1;
+ }
+
+ /* Clean up in case of error */
+ if (error && dirp) {
+ free (dirp);
+ dirp = NULL;
+ }
+
+ return dirp;
+}
+
+/*
+ * Read next directory entry.
+ *
+ * When working with text consoles, please note that file names returned by
+ * readdir() are represented in the default ANSI code page while any output to
+ * console is typically formatted on another code page. Thus, non-ASCII
+ * characters in file names will not usually display correctly on console. The
+ * problem can be fixed in two ways: (1) change the character set of console
+ * to 1252 using chcp utility and use Lucida Console font, or (2) use
+ * _cprintf function when writing to console. The _cprinf() will re-encode
+ * ANSI strings to the console code page so many non-ASCII characters will
+ * display correcly.
+ */
+static struct dirent*
+readdir(
+ DIR *dirp)
+{
+ WIN32_FIND_DATAW *datap;
+ struct dirent *entp;
+
+ /* Read next directory entry */
+ datap = dirent_next (dirp->wdirp);
+ if (datap) {
+ size_t n;
+ int error;
+
+ /* Attempt to convert file name to multi-byte string */
+ error = dirent_wcstombs_s(
+ &n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX);
+
+ /*
+ * If the file name cannot be represented by a multi-byte string,
+ * then attempt to use old 8+3 file name. This allows traditional
+ * Unix-code to access some file names despite of unicode
+ * characters, although file names may seem unfamiliar to the user.
+ *
+ * Be ware that the code below cannot come up with a short file
+ * name unless the file system provides one. At least
+ * VirtualBox shared folders fail to do this.
+ */
+ if (error && datap->cAlternateFileName[0] != '\0') {
+ error = dirent_wcstombs_s(
+ &n, dirp->ent.d_name, PATH_MAX,
+ datap->cAlternateFileName, PATH_MAX);
+ }
+
+ if (!error) {
+ DWORD attr;
+
+ /* Initialize directory entry for return */
+ entp = &dirp->ent;
+
+ /* Length of file name excluding zero terminator */
+ entp->d_namlen = n - 1;
+
+ /* File attributes */
+ attr = datap->dwFileAttributes;
+ if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
+ entp->d_type = DT_CHR;
+ } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ entp->d_type = DT_DIR;
+ } else {
+ entp->d_type = DT_REG;
+ }
+
+ /* Reset dummy fields */
+ entp->d_ino = 0;
+ entp->d_reclen = sizeof (struct dirent);
+
+ } else {
+ /*
+ * Cannot convert file name to multi-byte string so construct
+ * an errornous directory entry and return that. Note that
+ * we cannot return NULL as that would stop the processing
+ * of directory entries completely.
+ */
+ entp = &dirp->ent;
+ entp->d_name[0] = '?';
+ entp->d_name[1] = '\0';
+ entp->d_namlen = 1;
+ entp->d_type = DT_UNKNOWN;
+ entp->d_ino = 0;
+ entp->d_reclen = 0;
+ }
+
+ } else {
+ /* No more directory entries */
+ entp = NULL;
+ }
+
+ return entp;
+}
+
+/*
+ * Close directory stream.
+ */
+static int
+closedir(
+ DIR *dirp)
+{
+ int ok;
+ if (dirp) {
+
+ /* Close wide-character directory stream */
+ ok = _wclosedir (dirp->wdirp);
+ dirp->wdirp = NULL;
+
+ /* Release multi-byte character version */
+ free (dirp);
+
+ } else {
+
+ /* Invalid directory stream */
+ dirent_set_errno (EBADF);
+ ok = /*failure*/-1;
+
+ }
+ return ok;
+}
+
+/*
+ * Rewind directory stream to beginning.
+ */
+static void
+rewinddir(
+ DIR* dirp)
+{
+ /* Rewind wide-character string directory stream */
+ _wrewinddir (dirp->wdirp);
+}
+
+/* Convert multi-byte string to wide character string */
+static int
+dirent_mbstowcs_s(
+ size_t *pReturnValue,
+ wchar_t *wcstr,
+ size_t sizeInWords,
+ const char *mbstr,
+ size_t count)
+{
+ int error;
+
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+
+ /* Microsoft Visual Studio 2005 or later */
+ error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
+
+#else
+
+ /* Older Visual Studio or non-Microsoft compiler */
+ size_t n;
+
+ /* Convert to wide-character string (or count characters) */
+ n = mbstowcs (wcstr, mbstr, sizeInWords);
+ if (!wcstr || n < count) {
+
+ /* Zero-terminate output buffer */
+ if (wcstr && sizeInWords) {
+ if (n >= sizeInWords) {
+ n = sizeInWords - 1;
+ }
+ wcstr[n] = 0;
+ }
+
+ /* Length of resuting multi-byte string WITH zero terminator */
+ if (pReturnValue) {
+ *pReturnValue = n + 1;
+ }
+
+ /* Success */
+ error = 0;
+
+ } else {
+
+ /* Could not convert string */
+ error = 1;
+
+ }
+
+#endif
+
+ return error;
+}
+
+/* Convert wide-character string to multi-byte string */
+static int
+dirent_wcstombs_s(
+ size_t *pReturnValue,
+ char *mbstr,
+ size_t sizeInBytes, /* max size of mbstr */
+ const wchar_t *wcstr,
+ size_t count)
+{
+ int error;
+
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+
+ /* Microsoft Visual Studio 2005 or later */
+ error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
+
+#else
+
+ /* Older Visual Studio or non-Microsoft compiler */
+ size_t n;
+
+ /* Convert to multi-byte string (or count the number of bytes needed) */
+ n = wcstombs (mbstr, wcstr, sizeInBytes);
+ if (!mbstr || n < count) {
+
+ /* Zero-terminate output buffer */
+ if (mbstr && sizeInBytes) {
+ if (n >= sizeInBytes) {
+ n = sizeInBytes - 1;
+ }
+ mbstr[n] = '\0';
+ }
+
+ /* Length of resulting multi-bytes string WITH zero-terminator */
+ if (pReturnValue) {
+ *pReturnValue = n + 1;
+ }
+
+ /* Success */
+ error = 0;
+
+ } else {
+
+ /* Cannot convert string */
+ error = 1;
+
+ }
+
+#endif
+
+ return error;
+}
+
+/* Set errno variable */
+static void
+dirent_set_errno(
+ int error)
+{
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+
+ /* Microsoft Visual Studio 2005 and later */
+ _set_errno (error);
+
+#else
+
+ /* Non-Microsoft compiler or older Microsoft compiler */
+ errno = error;
+
+#endif
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*DIRENT_H*/
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/1/dir/readme.txt
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/1/dir/readme.txt b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/1/dir/readme.txt
new file mode 100644
index 0000000..a230251
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/1/dir/readme.txt
@@ -0,0 +1,4 @@
+This file ensures that the directory dir will be created accordingly when
+you unzip dirent to your computer. The directory itself is needed by the
+test program t-dirent.
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/1/file
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/1/file b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/1/file
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/2/Testfile-1.2.3.dat
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/2/Testfile-1.2.3.dat b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/2/Testfile-1.2.3.dat
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/2/file.txt
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/2/file.txt b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/2/file.txt
new file mode 100644
index 0000000..d32e004
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/2/file.txt
@@ -0,0 +1 @@
+This dummy file is needed by the test program t-dirent.
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/t-compile.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/t-compile.c b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/t-compile.c
new file mode 100644
index 0000000..81b47ec
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/dirent-for-Visual-Studio/tests/t-compile.c
@@ -0,0 +1,30 @@
+/*
+ * Test program to make sure that dirent compiles cleanly.
+ *
+ * Attempt to compile this program using Visual Studio. If dirent.h is
+ * working properly, then this program compiles without errors.
+ *
+ * Copyright (C) 2006-2012 Toni Ronkko
+ * This file is part of dirent. Dirent may be freely distributed
+ * under the MIT license. For all details and documentation, see
+ * https://github.com/tronkko/dirent
+ */
+#include <dirent.h>
+#ifdef WIN32
+# include <winsock2.h>
+# include <ws2tcpip.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(
+ int argc, char *argv[])
+{
+ (void) argc;
+ (void) argv;
+
+ printf ("OK\n");
+ return EXIT_SUCCESS;
+}