Skip to content

Instantly share code, notes, and snippets.

@gvanem
Created January 18, 2019 07:25
Show Gist options
  • Save gvanem/872b876da7a0bd2533008f04de30f191 to your computer and use it in GitHub Desktop.
Save gvanem/872b876da7a0bd2533008f04de30f191 to your computer and use it in GitHub Desktop.
My private patches for the EveryThing SDK. Ref. http://www.voidtools.com
--- a/EveryThing-SDK/src/Everything.c 2017-09-02 00:00:44
+++ b/EveryThing-SDK/src/Everything.c 2019-01-18 06:30:34
@@ -28,14 +28,80 @@
// this project builds the dll (visual studio will also build the lib for us)
// we declare all exported calls to __stdcall, so theres no need to set the default calling standard.
-// disable warnings
-#pragma warning(disable : 4996) // deprecation
+/*
+ * With changes by G. Vanem <2017> for the envtool program.
+ */
+
+/** \file Everything.c
+ * \ingroup EveryThing_SDK
+ * \brief
+ * The EveryThing SDK for user queries.
+ */
+
+#if defined(__POCC__)
+ /*
+ * warning #2130: Result of comparison is constant.
+ */
+ #pragma warn (disable: 2130)
+
+ /*
+ * warning #2154: Unreachable code.
+ */
+ #pragma warn (disable: 2154)
+
+#elif defined(__clang__)
+ /*
+ * Turn off these:
+ * Everything.c(1165,14): warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
+ * if (dwIndex < 0)
+ */
+ #pragma clang diagnostic ignored "-Wtautological-compare"
+ #pragma clang diagnostic ignored "-Wtautological-unsigned-zero-compare"
+ #pragma clang diagnostic ignored "-Wmissing-variable-declarations"
+
+#elif defined(_MSC_VER)
+ // disable warnings
+ #pragma warning(disable : 4996) // deprecation
+#endif
+#ifndef EVERYTHINGUSERAPI
#define EVERYTHINGUSERAPI __declspec(dllexport)
+#endif
// include
-#include "../include/Everything.h"
-#include "../ipc/Everything_IPC.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <wchar.h>
+
+#include "Everything.h"
+#include "Everything_IPC.h"
+
+#if defined(__CYGWIN__)
+ #define stricmp(s1, s2) strcasecmp (s1, s2)
+ #define wcsicmp(s1, s2) lstrcmpW (s1, s2)
+
+#elif defined(__WATCOMC__) || defined(__POCC__)
+ #define wcsicmp(s1, s2) _wcsicmp (s1, s2)
+#endif
+
+/*
+ * All MS compilers insists that 'main()', signal-handlers, atexit functions and
+ * var-arg functions must be defined as cdecl. This is only an issue if a program
+ * is using 'fastcall' globally (cl option '-Gr').
+ */
+#if defined(_MSC_VER) && !defined(__POCC__)
+ #define MS_CDECL __cdecl
+#else
+ #define MS_CDECL
+#endif
+
+/*
+ * From 'gcc -m64':
+ * Everything.c:33:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
+ */
+#define HWND_32BIT(h) ( (*(DWORD*) &(h)) & ULONG_MAX)
// return copydata code
#define _EVERYTHING_COPYDATA_QUERYREPLY 0
@@ -549,7 +615,6 @@
break;
}
}
-
return DefWindowProc(hwnd,msg,wParam,lParam);
}
@@ -641,7 +706,7 @@
*buf = 0;
}
-static DWORD EVERYTHINGAPI _Everything_query_thread_proc(void *param)
+static DWORD __stdcall _Everything_query_thread_proc(void *param)
{
HWND everything_hwnd;
@@ -726,9 +791,12 @@
_Everything_LastError = EVERYTHING_ERROR_IPC;
}
+ (void) param;
return 0;
}
+HANDLE Everything_hthread;
+
static BOOL EVERYTHINGAPI _Everything_Query(void)
{
HANDLE hthread;
@@ -738,12 +806,14 @@
_Everything_LastError = 0;
hthread = CreateThread(0,0,_Everything_query_thread_proc,0,0,&thread_id);
+ Everything_hthread = hthread;
if (hthread)
{
WaitForSingleObject(hthread,INFINITE);
CloseHandle(hthread);
+ Everything_hthread = NULL;
}
else
{
@@ -994,7 +1064,7 @@
return ret;
}
-static int __cdecl _Everything_CompareA(const void *a,const void *b)
+static int MS_CDECL _Everything_CompareA(const void *a,const void *b)
{
int i;
@@ -1015,7 +1085,7 @@
}
}
-static int __cdecl _Everything_CompareW(const void *a,const void *b)
+static int MS_CDECL _Everything_CompareW(const void *a,const void *b)
{
int i;
@@ -1074,6 +1144,20 @@
return ret;
}
+/*
+ * Set '_Everything_LastError' to a specific value.
+ * Must useful with 'err == EVERYTHING_OK' to avoid a next Everything_XX() function
+ * to not trigger an unrelated error.
+ */
+void EVERYTHINGAPI Everything_SetLastError(DWORD err)
+{
+ _Everything_Lock();
+
+ _Everything_LastError = err;
+
+ _Everything_Unlock();
+}
+
DWORD EVERYTHINGAPI Everything_GetNumFileResults(void)
{
DWORD ret;
@@ -2129,6 +2213,7 @@
}
}
+ (void) wParam;
return FALSE;
}
--- a/EveryThing-SDK/include/Everything.h 2016-12-17 23:21:16
+++ b/EveryThing-SDK/include/Everything.h 2019-01-18 06:33:50
@@ -24,6 +24,9 @@
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+/** \file Everything.h
+ * \ingroup EveryThing_SDK
+ */
#ifndef _EVERYTHING_DLL_
#define _EVERYTHING_DLL_
@@ -126,6 +129,7 @@
EVERYTHINGUSERAPI LPCSTR EVERYTHINGAPI Everything_GetSearchA(void);
EVERYTHINGUSERAPI LPCWSTR EVERYTHINGAPI Everything_GetSearchW(void);
EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetLastError(void);
+EVERYTHINGUSERAPI void EVERYTHINGAPI Everything_SetLastError(DWORD err);
EVERYTHINGUSERAPI HWND EVERYTHINGAPI Everything_GetReplyWindow(void);
EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetReplyID(void);
EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetSort(void); // Everything 1.4.1
@@ -243,4 +247,3 @@
#endif
#endif
-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment