diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-26 16:50:14 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-26 16:50:14 +0000 |
commit | c992cb2fdc11f1cac4bc5cbce26e8e2bb3b57da0 (patch) | |
tree | 697bdbf38a8a1f6b828a8bfbd08a478e19a82c6b /include | |
parent | f616294363c642d138f9dc0ef6eceae639e2434c (diff) |
- microkernel addded;
- version bumped to 0.92.2
git-svn-id: http://svn.miranda-ng.org/main/trunk@641 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include')
-rw-r--r-- | include/m_core.h | 396 | ||||
-rw-r--r-- | include/m_langpack.h | 99 | ||||
-rw-r--r-- | include/m_protomod.h | 2 | ||||
-rw-r--r-- | include/m_protosvc.h | 2 | ||||
-rw-r--r-- | include/m_system.h | 102 | ||||
-rw-r--r-- | include/m_system_cpp.h | 106 | ||||
-rw-r--r-- | include/m_utils.h | 62 | ||||
-rw-r--r-- | include/newpluginapi.h | 60 |
8 files changed, 444 insertions, 385 deletions
diff --git a/include/m_core.h b/include/m_core.h new file mode 100644 index 0000000000..0aeff8ae2f --- /dev/null +++ b/include/m_core.h @@ -0,0 +1,396 @@ +/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2008 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_CORE_H__
+#define M_CORE_H__ 1
+
+#ifdef MIR_CORE_EXPORTS
+ #define MIR_CORE_DLL(T) __declspec(dllexport) T __cdecl
+#else
+ #define MIR_CORE_DLL(T) __declspec(dllimport) T __cdecl
+#endif
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// events, hooks & services
+
+#define MAXMODULELABELLENGTH 64
+
+typedef int (*MIRANDAHOOK)(WPARAM, LPARAM);
+typedef int (*MIRANDAHOOKPARAM)(WPARAM, LPARAM, LPARAM);
+typedef int (*MIRANDAHOOKOBJ)(void*, WPARAM, LPARAM);
+typedef int (*MIRANDAHOOKOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
+
+typedef INT_PTR (*MIRANDASERVICE)(WPARAM, LPARAM);
+typedef INT_PTR (*MIRANDASERVICEPARAM)(WPARAM, LPARAM, LPARAM);
+typedef INT_PTR (*MIRANDASERVICEOBJ)(void*, LPARAM, LPARAM);
+typedef INT_PTR (*MIRANDASERVICEOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
+
+#ifdef _WIN64
+ #define CALLSERVICE_NOTFOUND ((INT_PTR)0x8000000000000000)
+#else
+ #define CALLSERVICE_NOTFOUND ((int)0x80000000)
+#endif
+
+MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name);
+MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent);
+MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook);
+MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(int) CallHookSubscribers(HANDLE hEvent, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam);
+
+MIR_CORE_DLL(HANDLE) HookEvent(const char* name, MIRANDAHOOK hookProc);
+MIR_CORE_DLL(HANDLE) HookEventParam(const char* name, MIRANDAHOOKPARAM hookProc, LPARAM lParam);
+MIR_CORE_DLL(HANDLE) HookEventObj(const char* name, MIRANDAHOOKOBJ hookProc, void* object);
+MIR_CORE_DLL(HANDLE) HookEventObjParam(const char* name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam);
+MIR_CORE_DLL(HANDLE) HookEventMessage(const char* name, HWND hwnd, UINT message);
+MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook);
+MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject);
+MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE pModule);
+
+MIR_CORE_DLL(HANDLE) CreateServiceFunction(const char *name, MIRANDASERVICE serviceProc);
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionParam(const char *name, MIRANDASERVICEPARAM serviceProc, LPARAM lParam);
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionObj(const char *name, MIRANDASERVICEOBJ serviceProc, void* object);
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionObjParam(const char *name, MIRANDASERVICEOBJPARAM serviceProc, void* object, LPARAM lParam);
+MIR_CORE_DLL(int) DestroyServiceFunction(HANDLE hService);
+MIR_CORE_DLL(int) ServiceExists(const char *name);
+
+MIR_CORE_DLL(INT_PTR) CallService(const char *name, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lParam);
+
+MIR_CORE_DLL(int) CallFunctionAsync(void (__stdcall *func)(void *), void *arg);
+MIR_CORE_DLL(void) KillModuleServices(HINSTANCE hInst);
+MIR_CORE_DLL(void) KillObjectServices(void* pObject);
+
+#if defined(_STATIC)
+__declspec(dllexport) INT_PTR CallContactService(HANDLE, const char *, WPARAM, LPARAM);
+__declspec(dllexport) INT_PTR CallProtoService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
+#else
+MIR_CORE_DLL(INT_PTR) CallContactService(HANDLE, const char *, WPARAM, LPARAM);
+MIR_CORE_DLL(INT_PTR) CallProtoService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// exceptions
+
+typedef DWORD (__cdecl *pfnExceptionFilter)(DWORD code, EXCEPTION_POINTERS* info);
+
+MIR_CORE_DLL(pfnExceptionFilter) GetExceptionFilter(void);
+MIR_CORE_DLL(pfnExceptionFilter) SetExceptionFilter(pfnExceptionFilter pMirandaExceptFilter);
+
+///////////////////////////////////////////////////////////////////////////////
+// language packs support
+
+#define LANG_UNICODE 0x1000
+
+extern int hLangpack;
+
+MIR_CORE_DLL(void) LangPackDropUnusedItems(void);
+MIR_CORE_DLL(int) LangPackGetDefaultCodePage( void );
+MIR_CORE_DLL(int) LangPackGetDefaultLocale(void);
+MIR_CORE_DLL(TCHAR*) LangPackPcharToTchar(const char* pszStr);
+
+MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack);
+MIR_CORE_DLL(void) ReloadLangpack(TCHAR *pszStr);
+
+MIR_CORE_DLL(char*) TranslateA_LP(const char* str, int hLang);
+MIR_CORE_DLL(WCHAR*) TranslateW_LP(const WCHAR* str, int hLang);
+MIR_CORE_DLL(void) TranslateMenu_LP(HMENU, int hLang);
+MIR_CORE_DLL(void) TranslateDialog_LP(HWND hDlg, int hLang);
+
+#define Translate(s) TranslateA_LP(s, hLangpack)
+#define TranslateW(s) TranslateW_LP(s, hLangpack)
+#define TranslateMenu(h) TranslateMenu_LP(h,hLangpack)
+#define TranslateDialogDefault(h) TranslateDialog_LP(h,hLangpack)
+
+#ifdef _UNICODE
+ #define TranslateT(s) TranslateW_LP(_T(s),hLangpack)
+ #define TranslateTS(s) TranslateW_LP(s,hLangpack)
+ #define TranslateTH(l,s) TranslateW_LP(s,l)
+#else
+ #define TranslateT(s) TranslateA_LP(s,hLangpack)
+ #define TranslateTS(s) TranslateA_LP(s,hLangpack)
+ #define TranslateTH(l,s) TranslateA_LP(s,l)
+#endif
+
+MIR_CORE_DLL(unsigned int) mir_hash(const void * key, unsigned int len);
+
+#pragma optimize("gt", on)
+__inline unsigned int mir_hashstr(const char * key)
+{
+ if (key == NULL) return 0;
+ else {
+ unsigned int len = (unsigned int)strlen((const char*)key);
+ return mir_hash(key, len);
+} }
+
+__inline unsigned int mir_hashstrW(const wchar_t * key)
+{
+ if (key == NULL) return 0;
+ else {
+ unsigned int len = (unsigned int)wcslen((const wchar_t*)key);
+ return mir_hash(key, len * sizeof(wchar_t));
+} }
+#pragma optimize("", on)
+
+#define mir_hashstrT mir_hashstrW
+
+///////////////////////////////////////////////////////////////////////////////
+// lists
+
+typedef int (*FSortFunc)(void*, void*); // sort function prototype
+
+// Assumes first 32 bit value of the data is the numeric key
+// and uses it to perform sort/search operations, this results
+// in much better performance as no compare function calls needed
+// Incredibly useful for Hash Tables
+#define NumericKeySort (FSortFunc)(void*) -1
+#define HandleKeySort (FSortFunc)(void*) -2
+#define PtrKeySort (FSortFunc)(void*) -3
+
+typedef struct
+{
+ void** items;
+ int realCount;
+ int limit;
+ int increment;
+
+ FSortFunc sortFunc;
+}
+ SortedList;
+
+MIR_CORE_DLL(SortedList*) List_Create(int p_limit, int p_increment);
+MIR_CORE_DLL(void) List_Destroy(SortedList* p_list);
+MIR_CORE_DLL(void*) List_Find(SortedList* p_list, void* p_value);
+MIR_CORE_DLL(int) List_GetIndex(SortedList* p_list, void* p_value, int* p_index);
+MIR_CORE_DLL(int) List_IndexOf(SortedList* p_list, void* p_value);
+MIR_CORE_DLL(int) List_Insert(SortedList* p_list, void* p_value, int p_index);
+MIR_CORE_DLL(int) List_InsertPtr(SortedList* list, void* p);
+MIR_CORE_DLL(int) List_Remove(SortedList* p_list, int index);
+MIR_CORE_DLL(int) List_RemovePtr(SortedList* list, void* p);
+MIR_CORE_DLL(void) List_Copy(SortedList* s, SortedList* d, size_t itemSize);
+MIR_CORE_DLL(void) List_ObjCopy(SortedList* s, SortedList* d, size_t itemSize);
+
+///////////////////////////////////////////////////////////////////////////////
+// memory functions
+
+MIR_CORE_DLL(void*) mir_alloc(size_t);
+MIR_CORE_DLL(void*) mir_calloc(size_t);
+MIR_CORE_DLL(void*) mir_realloc(void* ptr, size_t);
+MIR_CORE_DLL(void) mir_free(void* ptr);
+MIR_CORE_DLL(char*) mir_strdup(const char* str);
+MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR* str);
+MIR_CORE_DLL(char*) mir_strndup(const char* str, size_t len);
+
+///////////////////////////////////////////////////////////////////////////////
+// modules
+
+MIR_CORE_DLL(void) RegisterModule(HINSTANCE hInst);
+MIR_CORE_DLL(void) UnregisterModule(HINSTANCE hInst);
+
+MIR_CORE_DLL(HINSTANCE) GetInstByAddress(void* codePtr);
+
+///////////////////////////////////////////////////////////////////////////////
+// path utils
+
+MIR_CORE_DLL(void) CreatePathToFile(char* wszFilePath);
+MIR_CORE_DLL(int) CreateDirectoryTree(const char* szDir);
+MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base);
+MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut);
+
+MIR_CORE_DLL(void) CreatePathToFileW(WCHAR* wszFilePath);
+MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR* szDir);
+MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, WCHAR* base);
+MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut);
+
+#define CreatePathToFileT CreatePathToFileW
+#define CreateDirectoryTreeT CreateDirectoryTreeW
+#define PathToAbsoluteT PathToAbsoluteW
+#define PathToRelativeT PathToRelativeW
+
+///////////////////////////////////////////////////////////////////////////////
+// print functions
+
+MIR_CORE_DLL(int) mir_snprintf(char *buffer, size_t count, const char* fmt, ...);
+MIR_CORE_DLL(int) mir_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...);
+MIR_CORE_DLL(int) mir_vsnprintf(char *buffer, size_t count, const char* fmt, va_list va);
+MIR_CORE_DLL(int) mir_vsntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, va_list va);
+
+///////////////////////////////////////////////////////////////////////////////
+// strings
+
+MIR_CORE_DLL(char*) rtrim(char *str);
+MIR_CORE_DLL(WCHAR*) wrtrim(WCHAR *str);
+
+#ifdef _UNICODE
+ #define trtrim wrtrim
+#else
+ #define trtrim rtrim
+#endif
+
+MIR_CORE_DLL(char*) ltrim(char *str); // returns pointer to the beginning of string
+MIR_CORE_DLL(char*) ltrimp(char *str); // returns pointer to the trimmed portion of string
+
+MIR_CORE_DLL(int) wildcmp(char *name, char *mask);
+
+__inline char* lrtrim(char* str) { return ltrim(rtrim(str)); };
+__inline char* lrtrimp(char* str) { return ltrimp(rtrim(str)); };
+
+///////////////////////////////////////////////////////////////////////////////
+// text conversion functions
+
+#ifdef _UNICODE
+ #define mir_t2a(s) mir_u2a(s)
+ #define mir_a2t(s) mir_a2u(s)
+ #define mir_t2u(s) mir_wstrdup(s)
+ #define mir_u2t(s) mir_wstrdup(s)
+
+ #define mir_t2a_cp(s,c) mir_u2a_cp(s,c)
+ #define mir_a2t_cp(s,c) mir_a2u_cp(s,c)
+ #define mir_t2u_cp(s,c) mir_wstrdup(s)
+ #define mir_u2t_cp(s,c) mir_wstrdup(s)
+
+ #define mir_tstrdup mir_wstrdup
+#else
+ #define mir_t2a(s) mir_strdup(s)
+ #define mir_a2t(s) mir_strdup(s)
+ #define mir_t2u(s) mir_a2u(s)
+ #define mir_u2t(s) mir_u2a(s)
+
+ #define mir_t2a_cp(s,c) mir_strdup(s)
+ #define mir_a2t_cp(s,c) mir_strdup(s)
+ #define mir_t2u_cp(s,c) mir_a2u_cp(s,c)
+ #define mir_u2t_cp(s,c) mir_u2a_cp(s,c)
+
+ #define mir_tstrdup mir_strdup
+#endif
+
+MIR_CORE_DLL(WCHAR*) mir_a2u_cp(const char* src, int codepage);
+MIR_CORE_DLL(WCHAR*) mir_a2u(const char* src);
+MIR_CORE_DLL(char*) mir_u2a_cp(const wchar_t* src, int codepage);
+MIR_CORE_DLL(char*) mir_u2a(const wchar_t* src);
+
+#if defined(__cplusplus)
+
+class _A2T
+{
+ TCHAR* buf;
+
+public:
+ __forceinline _A2T(const char* s) : buf(mir_a2t(s)) {}
+ __forceinline _A2T(const char* s, int cp) : buf(mir_a2t_cp(s, cp)) {}
+ ~_A2T() { mir_free(buf); }
+
+ __forceinline operator TCHAR*() const
+ { return buf;
+ }
+};
+
+class _T2A
+{
+ char* buf;
+
+public:
+ __forceinline _T2A(const TCHAR* s) : buf(mir_t2a(s)) {}
+ __forceinline _T2A(const TCHAR* s, int cp) : buf(mir_t2a_cp(s, cp)) {}
+ __forceinline ~_T2A() { mir_free(buf); }
+
+ __forceinline operator char*() const
+ { return buf;
+ }
+};
+
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// threads
+
+MIR_CORE_DLL(INT_PTR) UnwindThreadPush(WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(INT_PTR) UnwindThreadPop(WPARAM, LPARAM);
+MIR_CORE_DLL(void) UnwindThreadWait(void);
+
+MIR_CORE_DLL(UINT_PTR) forkthread( void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg);
+MIR_CORE_DLL(UINT_PTR) forkthreadex(void *sec, unsigned stacksize, unsigned (__stdcall *threadcode)(void*), void* owner, void *arg, unsigned *thraddr);
+
+MIR_CORE_DLL(void) KillObjectThreads(void* pObject);
+
+///////////////////////////////////////////////////////////////////////////////
+// utf8 interface
+
+MIR_CORE_DLL(char*) Utf8Decode(char* str, wchar_t** ucs2);
+MIR_CORE_DLL(char*) Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2);
+
+MIR_CORE_DLL(wchar_t*) Utf8DecodeW(const char* str);
+
+MIR_CORE_DLL(char*) Utf8Encode(const char* str);
+MIR_CORE_DLL(char*) Utf8EncodeCP(const char* src, int codepage);
+
+MIR_CORE_DLL(char*) Utf8EncodeW(const wchar_t* str);
+
+MIR_CORE_DLL(int) Ucs2toUtf8Len(const wchar_t *src);
+
+#define Utf8DecodeT Utf8DecodeW
+#define Utf8EncodeT Utf8EncodeW
+
+#define mir_utf8decode(A, B) Utf8Decode(A, B)
+#define mir_utf8decodecp(A, B, C) Utf8DecodeCP(A, B, C)
+#define mir_utf8decodeW(A) Utf8DecodeW(A)
+#define mir_utf8encode(A) Utf8Encode(A)
+#define mir_utf8encodecp(A, B) Utf8EncodeCP(A, B)
+#define mir_utf8encodeW(A) Utf8EncodeW(A)
+#define mir_utf8lenW(A) Ucs2toUtf8Len(A)
+
+__forceinline char* mir_utf8decodeA(const char* src)
+{
+ char* tmp = mir_strdup(src);
+ mir_utf8decode(tmp, NULL);
+ return tmp;
+}
+
+#if defined(_UNICODE)
+ #define mir_utf8decodeT mir_utf8decodeW
+ #define mir_utf8encodeT mir_utf8encodeW
+#else
+ #define mir_utf8decodeT mir_utf8decodeA
+ #define mir_utf8encodeT mir_utf8encode
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
+#if defined(__cplusplus)
+}
+#endif
+
+#ifndef MIR_CORE_EXPORTS
+ #if !defined( _WIN64 )
+ #pragma comment(lib, "mir_core.lib")
+ #else
+ #pragma comment(lib, "mir_core64.lib")
+ #endif
+#endif
+
+#endif // M_CORE_H
diff --git a/include/m_langpack.h b/include/m_langpack.h index d1dfb9d326..efcca8d27c 100644 --- a/include/m_langpack.h +++ b/include/m_langpack.h @@ -24,12 +24,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_LANGPACK_H__
#define M_LANGPACK_H__
+#if !defined(M_CORE_H__)
+ #include <m_core.h>
+#endif
+
#if !defined(_STATIC)
#define MIRANDA_CUSTOM_LP
#endif
-#define LANG_UNICODE 0x1000
-
//translates a single string into the user's local language v0.1.1.0+
//wParam=0
//lParam=(LPARAM)(const char*)szEnglish
@@ -41,38 +43,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //these versions, I pity them.
#define MS_LANGPACK_TRANSLATESTRING "LangPack/TranslateString"
-#if defined(MIRANDA_CUSTOM_LP)
-
-extern int hLangpack;
-
-__inline static char* Translate(const char* str)
-{ return (char*)CallService(MS_LANGPACK_TRANSLATESTRING, hLangpack, (LPARAM)(str));
-}
-
-__inline static WCHAR* TranslateW(const WCHAR* str)
-{ return (WCHAR*)CallService(MS_LANGPACK_TRANSLATESTRING, hLangpack+LANG_UNICODE, (LPARAM)(str));
-}
-
-#else
-
-__inline static char* Translate(const char* str)
-{ return (char*)CallService(MS_LANGPACK_TRANSLATESTRING, 0, (LPARAM)(str));
-}
-
-__inline static WCHAR* TranslateW(const WCHAR* str)
-{ return (WCHAR*)CallService(MS_LANGPACK_TRANSLATESTRING, LANG_UNICODE, (LPARAM)(str));
-}
-
-#endif
-
-#ifdef _UNICODE
- #define TranslateT(s) TranslateW(_T(s))
- #define TranslateTS(s) TranslateW(s)
-#else
- #define TranslateT(s) Translate(s)
- #define TranslateTS(s) Translate(s)
-#endif
-
// If you're storing some string for calling later-on Translate or using it
// with an API call that does translation automatically marked with
// [TRANSLATED-BY-CORE] please wrap it with one of LPGEN macros in order to
@@ -86,71 +56,12 @@ __inline static WCHAR* TranslateW(const WCHAR* str) #endif
//Those macros do NOTHING. They are just markers for lpgen.pl.
-//translates a dialog into the user's local language v0.1.1.0+
-//wParam=0
-//lParam=(LPARAM)(LANGPACKTRANSLATEDIALOG*)&lptd
-//returns 0 on success, nonzero on failure
-//This service only knows about the following controls:
-//Window titles, STATIC, EDIT, Hyperlink, BUTTON
-typedef struct {
- int cbSize;
- DWORD flags;
- HWND hwndDlg;
- const int *ignoreControls; //zero-terminated list of control IDs *not* to
- //translate
-} LANGPACKTRANSLATEDIALOG;
-#define LPTDF_NOIGNOREEDIT 1 //translate all edit controls. By default
- //non-read-only edit controls are not translated
-#define LPTDF_NOTITLE 2 //do not translate the title of the dialog
-
-#define MS_LANGPACK_TRANSLATEDIALOG "LangPack/TranslateDialog"
-
-#if defined(MIRANDA_CUSTOM_LP)
-
-__inline static INT_PTR TranslateDialogDefault(HWND hwndDlg)
-{
- LANGPACKTRANSLATEDIALOG lptd;
- lptd.cbSize=sizeof(lptd);
- lptd.flags=hLangpack;
- lptd.hwndDlg=hwndDlg;
- lptd.ignoreControls=NULL;
- return CallService(MS_LANGPACK_TRANSLATEDIALOG, 0, (LPARAM)&lptd);
-}
-
-#else
-
-__inline static INT_PTR TranslateDialogDefault(HWND hwndDlg)
-{
- LANGPACKTRANSLATEDIALOG lptd;
- lptd.cbSize=sizeof(lptd);
- lptd.flags=0;
- lptd.hwndDlg=hwndDlg;
- lptd.ignoreControls=NULL;
- return CallService(MS_LANGPACK_TRANSLATEDIALOG, 0, (LPARAM)&lptd);
-}
-
-#endif
-
//translates a menu into the user's local language v0.1.1.0+
//wParam=(WPARAM)(HMENU)hMenu
//lParam=langpack handle (v.0.10.0+)
//returns 0 on success, nonzero on failure
#define MS_LANGPACK_TRANSLATEMENU "LangPack/TranslateMenu"
-#if defined(MIRANDA_CUSTOM_LP)
-
-__inline static INT_PTR TranslateMenu(HMENU hMenu)
-{ return CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu, hLangpack);
-}
-
-#else
-
-__inline static INT_PTR TranslateMenu(HMENU hMenu)
-{ return CallService(MS_LANGPACK_TRANSLATEMENU, (LPARAM)hMenu, 0);
-}
-
-#endif
-
//returns the codepage used in the language pack v0.4.3.0+
//wParam=0
//lParam=0
@@ -191,7 +102,7 @@ __inline static INT_PTR Langpack_PCharToTChar(const char* str) #define MS_LANGPACK_REGISTER "LangPack/Register"
#if defined(MIRANDA_CUSTOM_LP)
-__forceinline void mir_getLP(const PLUGININFOEX* pInfo)
+__inline static void mir_getLP(const PLUGININFOEX* pInfo)
{ CallService(MS_LANGPACK_REGISTER, (WPARAM)&hLangpack, (LPARAM)pInfo);
}
#endif
diff --git a/include/m_protomod.h b/include/m_protomod.h index ee28bf232d..bce86385d6 100644 --- a/include/m_protomod.h +++ b/include/m_protomod.h @@ -61,7 +61,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //Create a protocol service
//Protocol services are called with wParam and lParam as standard if they are
-//to be called with CallProtoService() (as PS_ services are)
+//to be called with CallProtoServiceInt(NULL,) (as PS_ services are)
//If they are called with CallContactService() (PSS_ and PSR_ services) then
//they are called with lParam=(CCSDATA*)&ccs and wParam an opaque internal
//reference that should be passed unchanged to MS_PROTO_CHAIN*.
diff --git a/include/m_protosvc.h b/include/m_protosvc.h index b8259911ff..f7ce4f26e9 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -43,7 +43,7 @@ convert Unicode to ANSI and call the appropriate service. */
/*************************** NON-CONTACT SERVICES ************************/
-//these should be called with CallProtoService()
+//these should be called with CallProtoServiceInt(NULL,)
//Get the capability flags of the module.
//wParam=flagNum
diff --git a/include/m_system.h b/include/m_system.h index d17896a0a5..ffca735b4a 100644 --- a/include/m_system.h +++ b/include/m_system.h @@ -25,8 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <tchar.h>
+#include <m_core.h>
+
#ifndef MIRANDANAME
- #define MIRANDANAME "Miranda IM"
+ #define MIRANDANAME "Miranda IM"
#endif
#ifndef MIRANDACLASS
#define MIRANDACLASS "Miranda"
@@ -164,73 +166,15 @@ struct MM_INTERFACE __forceinline INT_PTR mir_getMMI(struct MM_INTERFACE* dest)
{
- dest->cbSize = sizeof(*dest);
- return CallService(MS_SYSTEM_GET_MMI, 0, (LPARAM)dest);
+ return 0;
}
-#ifndef _STATIC
- extern struct MM_INTERFACE mmi;
- #define mir_alloc(n) mmi.mmi_malloc(n)
- #define mir_free(ptr) mmi.mmi_free(ptr)
- #define mir_realloc(ptr, size) mmi.mmi_realloc(ptr, size)
-
- #define mir_calloc(n) mmi.mmi_calloc(n)
- #define mir_strdup(str) mmi.mmi_strdup(str)
- #define mir_wstrdup(str) mmi.mmi_wstrdup(str)
- #define mir_snprintf mmi.mir_snprintf
- #define mir_sntprintf mmi.mir_sntprintf
- #define mir_vsnprintf mmi.mir_vsnprintf
- #define mir_vsntprintf mmi.mir_vsntprintf
-
- #define mir_a2u_cp(src, cp) mmi.mir_a2u_cp(src, cp)
- #define mir_a2u(src) mmi.mir_a2u(src)
- #define mir_u2a_cp(src, cp) mmi.mir_u2a_cp(src, cp)
- #define mir_u2a(src) mmi.mir_u2a(src)
-#else
- char* mir_strdup(const char *src);
- WCHAR* mir_wstrdup(const WCHAR *src);
-#endif
-
-#if defined(_UNICODE)
- #define mir_tstrdup mir_wstrdup
-#else
- #define mir_tstrdup mir_strdup
-#endif
-
-#define miranda_sys_free mir_free
-#define memoryManagerInterface mmi
-
/* Returns the pointer to the simple lists manager.
If the sortFunc member of the list gets assigned, the list becomes sorted
wParam=0, lParam = (LPARAM)LIST_INTERFACE*
*/
-#define LIST_INTERFACE_V1_SIZE (sizeof(size_t)+7*sizeof(void*))
-#define LIST_INTERFACE_V2_SIZE (sizeof(size_t)+9*sizeof(void*))
-#define LIST_INTERFACE_V3_SIZE (sizeof(size_t)+11*sizeof(void*))
-
-typedef int (*FSortFunc)(void*, void*);
-
-// Assumes first 32 bit value of the data is the numeric key
-// and uses it to perform sort/search operations, this results
-// in much better performance as no compare function calls needed
-// Incredibly useful for Hash Tables
-#define NumericKeySort (FSortFunc)(void*) -1
-#define HandleKeySort (FSortFunc)(void*) -2
-#define PtrKeySort (FSortFunc)(void*) -3
-
-typedef struct
-{
- void** items;
- int realCount;
- int limit;
- int increment;
-
- FSortFunc sortFunc;
-}
- SortedList;
-
struct LIST_INTERFACE
{
size_t cbSize;
@@ -255,8 +199,7 @@ struct LIST_INTERFACE __forceinline INT_PTR mir_getLI(struct LIST_INTERFACE* dest)
{
- dest->cbSize = sizeof(*dest);
- return CallService(MS_SYSTEM_GET_LI, 0, (LPARAM)dest);
+ return 0;
}
/*
@@ -301,35 +244,9 @@ struct UTF8_INTERFACE __forceinline INT_PTR mir_getUTFI(struct UTF8_INTERFACE* dest)
{
- dest->cbSize = sizeof(*dest);
- return CallService(MS_SYSTEM_GET_UTFI, 0, (LPARAM)dest);
+ return 0;
}
-extern struct UTF8_INTERFACE utfi;
-
-#define mir_utf8decode(A, B) utfi.utf8_decode(A, B)
-#define mir_utf8decodecp(A, B, C) utfi.utf8_decodecp(A, B, C)
-#define mir_utf8decodeW(A) utfi.utf8_decodeW(A)
-#define mir_utf8encode(A) utfi.utf8_encode(A)
-#define mir_utf8encodecp(A, B) utfi.utf8_encodecp(A, B)
-#define mir_utf8encodeW(A) utfi.utf8_encodeW(A)
-#define mir_utf8lenW(A) utfi.utf8_lenW(A)
-
-__forceinline char* mir_utf8decodeA(const char* src)
-{
- char* tmp = mir_strdup(src);
- mir_utf8decode(tmp, NULL);
- return tmp;
-}
-
-#if defined(_UNICODE)
- #define mir_utf8decodeT mir_utf8decodeW
- #define mir_utf8encodeT mir_utf8encodeW
-#else
- #define mir_utf8decodeT mir_utf8decodeA
- #define mir_utf8encodeT mir_utf8encode
-#endif
-
/*
-- Thread Safety --
@@ -608,19 +525,16 @@ obtain this filter and call it inside the __except section 0.8.0+ addition (2008/07/20)
*/
-typedef DWORD (__cdecl *pfnExceptionFilter)(DWORD code, EXCEPTION_POINTERS* info);
-
#define MS_SYSTEM_GETEXCEPTFILTER "System/GetExceptFilter"
__inline static pfnExceptionFilter Miranda_GetExceptFilter(void)
-{ return (pfnExceptionFilter)CallService(MS_SYSTEM_GETEXCEPTFILTER, 0, 0);
+{ return GetExceptionFilter();
}
#define MS_SYSTEM_SETEXCEPTFILTER "System/SetExceptFilter"
__inline static pfnExceptionFilter Miranda_SetExceptFilter(pfnExceptionFilter foo)
-{ return (pfnExceptionFilter)CallService(MS_SYSTEM_SETEXCEPTFILTER, 0, (LPARAM)foo);
+{ return SetExceptionFilter(foo);
}
-
#endif // M_SYSTEM_H
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index c0e448fec3..086eba0fc3 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -70,59 +70,31 @@ template<class T> struct LIST __inline int getCount(void) const { return count; }
__inline T** getArray(void) const { return items; }
- #if defined(_STATIC)
- __inline LIST(const LIST& x)
- { items = NULL;
- List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- }
-
- __inline LIST& operator=(const LIST& x)
- { destroy();
- List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- return *this;
- }
-
- __inline int getIndex(T* p) const
- { int idx;
- return ( !List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
- }
-
- __inline void destroy(void) { List_Destroy((SortedList*)this); }
-
- __inline T* find(T* p) { return (T*)List_Find((SortedList*)this, p); }
- __inline int indexOf(T* p) { return List_IndexOf((SortedList*)this, p); }
- __inline int insert(T* p, int idx) { return List_Insert((SortedList*)this, p, idx); }
- __inline int remove(int idx) { return List_Remove((SortedList*)this, idx); }
-
- __inline int insert(T* p) { return List_InsertPtr((SortedList*)this, p); }
- __inline int remove(T* p) { return List_RemovePtr((SortedList*)this, p); }
- #else
- __inline LIST(const LIST& x)
- { items = NULL;
- li.List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- }
-
- __inline LIST& operator=(const LIST& x)
- { destroy();
- li.List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- return *this;
- }
+ __inline LIST(const LIST& x)
+ { items = NULL;
+ List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
+ }
+
+ __inline LIST& operator=(const LIST& x)
+ { destroy();
+ List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
+ return *this;
+ }
- __inline int getIndex(T* p) const
- { int idx;
- return ( !li.List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
- }
+ __inline int getIndex(T* p) const
+ { int idx;
+ return ( !List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
+ }
- __inline void destroy(void) { li.List_Destroy((SortedList*)this); }
+ __inline void destroy(void) { List_Destroy((SortedList*)this); }
- __inline T* find(T* p) { return (T*)li.List_Find((SortedList*)this, p); }
- __inline int indexOf(T* p) { return li.List_IndexOf((SortedList*)this, p); }
- __inline int insert(T* p, int idx) { return li.List_Insert((SortedList*)this, p, idx); }
- __inline int remove(int idx) { return li.List_Remove((SortedList*)this, idx); }
+ __inline T* find(T* p) { return (T*)List_Find((SortedList*)this, p); }
+ __inline int indexOf(T* p) { return List_IndexOf((SortedList*)this, p); }
+ __inline int insert(T* p, int idx) { return List_Insert((SortedList*)this, p, idx); }
+ __inline int remove(int idx) { return List_Remove((SortedList*)this, idx); }
- __inline int insert(T* p) { return li.List_InsertPtr((SortedList*)this, p); }
- __inline int remove(T* p) { return li.List_RemovePtr((SortedList*)this, p); }
- #endif
+ __inline int insert(T* p) { return List_InsertPtr((SortedList*)this, p); }
+ __inline int remove(T* p) { return List_RemovePtr((SortedList*)this, p); }
protected:
T** items;
@@ -145,29 +117,18 @@ template<class T> struct OBJLIST : public LIST<T> __inline OBJLIST(const OBJLIST& x) :
LIST<T>(x.increment, x.sortFunc)
{ items = NULL;
- #if defined(_STATIC)
- List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #else
- li.List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #endif
+ List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
}
__inline OBJLIST& operator=(const OBJLIST& x)
{ destroy();
- #if defined(_STATIC)
- List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #else
- li.List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #endif
+ List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
return *this;
}
~OBJLIST()
{
- #if !defined(_STATIC)
- if (li.cbSize != 0)
- #endif
- destroy();
+ destroy();
}
__inline void destroy(void)
@@ -175,30 +136,17 @@ template<class T> struct OBJLIST : public LIST<T> for (int i=0; i < this->count; i++)
delete this->items[i];
- #if defined(_STATIC)
- List_Destroy((SortedList*)this);
- #else
- li.List_Destroy((SortedList*)this);
- #endif
+ List_Destroy((SortedList*)this);
}
__inline int remove(int idx) {
delete this->items[idx];
- #if defined(_STATIC)
- return List_Remove((SortedList*)this, idx);
- #else
- return li.List_Remove((SortedList*)this, idx);
- #endif
+ return List_Remove((SortedList*)this, idx);
}
__inline int remove(T* p)
{
- #if defined(_STATIC)
- if (li.List_RemovePtr((SortedList*)this, p) != -1)
- #else
- if (li.List_RemovePtr((SortedList*)this, p) != -1)
- #endif
- {
+ if (List_RemovePtr((SortedList*)this, p) != -1) {
delete p;
return 1;
}
diff --git a/include/m_utils.h b/include/m_utils.h index b8366f31a9..ad8b99e46d 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -518,66 +518,4 @@ extern struct SHA1_INTERFACE sha1i; #define TCHAR_STR_PARAM "%s"
#endif
-#ifdef _UNICODE
- #define mir_t2a(s) mir_u2a(s)
- #define mir_a2t(s) mir_a2u(s)
- #define mir_t2u(s) mir_wstrdup(s)
- #define mir_u2t(s) mir_wstrdup(s)
-
- #define mir_t2a_cp(s,c) mir_u2a_cp(s,c)
- #define mir_a2t_cp(s,c) mir_a2u_cp(s,c)
- #define mir_t2u_cp(s,c) mir_wstrdup(s)
- #define mir_u2t_cp(s,c) mir_wstrdup(s)
-#else
- #define mir_t2a(s) mir_strdup(s)
- #define mir_a2t(s) mir_strdup(s)
- #define mir_t2u(s) mir_a2u(s)
- #define mir_u2t(s) mir_u2a(s)
-
- #define mir_t2a_cp(s,c) mir_strdup(s)
- #define mir_a2t_cp(s,c) mir_strdup(s)
- #define mir_t2u_cp(s,c) mir_a2u_cp(s,c)
- #define mir_u2t_cp(s,c) mir_u2a_cp(s,c)
-#endif
-
-#if defined(__cplusplus)
-
-#ifdef _STATIC
- void mir_free(void*);
- WCHAR* mir_a2u_cp(const char* src, int codepage);
- WCHAR* mir_a2u(const char* src);
- char* mir_u2a_cp(const wchar_t* src, int codepage);
- char* mir_u2a(const wchar_t* src);
-#endif
-
-class _A2T
-{
- TCHAR* buf;
-
-public:
- __forceinline _A2T(const char* s) : buf(mir_a2t(s)) {}
- __forceinline _A2T(const char* s, int cp) : buf(mir_a2t_cp(s, cp)) {}
- ~_A2T() { mir_free(buf); }
-
- __forceinline operator TCHAR*() const
- { return buf;
- }
-};
-
-class _T2A
-{
- char* buf;
-
-public:
- __forceinline _T2A(const TCHAR* s) : buf(mir_t2a(s)) {}
- __forceinline _T2A(const TCHAR* s, int cp) : buf(mir_t2a_cp(s, cp)) {}
- __forceinline ~_T2A() { mir_free(buf); }
-
- __forceinline operator char*() const
- { return buf;
- }
-};
-
-#endif
-
#endif // M_UTILS_H__
diff --git a/include/newpluginapi.h b/include/newpluginapi.h index 0f2a6aa8d7..c539b9222b 100644 --- a/include/newpluginapi.h +++ b/include/newpluginapi.h @@ -24,7 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_NEWPLUGINAPI_H__
#define M_NEWPLUGINAPI_H__
-#include "m_plugins.h"
+#include <m_core.h>
+#include <m_plugins.h>
#define PLUGIN_MAKE_VERSION(a, b, c, d) (((((DWORD)(a))&0xFF)<<24)|((((DWORD)(b))&0xFF)<<16)|((((DWORD)(c))&0xFF)<<8)|(((DWORD)(d))&0xFF))
#define MAXMODULELABELLENGTH 64
@@ -100,7 +101,8 @@ typedef struct _MUUID { /* Each service mode plugin must implement MS_SERVICEMODE_LAUNCH */
#define MS_SERVICEMODE_LAUNCH "ServiceMode/Launch"
-typedef struct {
+typedef struct PLUGININFOEX_tag
+{
int cbSize;
char *shortName;
DWORD version;
@@ -115,7 +117,8 @@ typedef struct { //with the implication that this plugin provides back-end-compatible features
/*********** WILL BE DEPRECATED in 0.8 * *************/
MUUID uuid; // Not required until 0.8.
-} PLUGININFOEX;
+}
+ PLUGININFOEX;
//Miranda/System/LoadModule event
//called when a plugin is being loaded dynamically
@@ -129,25 +132,6 @@ typedef struct { //lParam=HINSTANCE of the plugin to be unloaded
#define ME_SYSTEM_MODULEUNLOAD "Miranda/System/UnloadModule"
-#ifndef MODULES_H_
- typedef int (*MIRANDAHOOK)(WPARAM, LPARAM);
- typedef int (*MIRANDAHOOKPARAM)(WPARAM, LPARAM, LPARAM);
- typedef int (*MIRANDAHOOKOBJ)(void*, WPARAM, LPARAM);
- typedef int (*MIRANDAHOOKOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
-
- typedef INT_PTR (*MIRANDASERVICE)(WPARAM, LPARAM);
- typedef INT_PTR (*MIRANDASERVICEPARAM)(WPARAM, LPARAM, LPARAM);
- typedef INT_PTR (*MIRANDASERVICEOBJ)(void*, WPARAM, LPARAM);
- typedef INT_PTR (*MIRANDASERVICEOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
-
-#ifdef _WIN64
- #define CALLSERVICE_NOTFOUND ((INT_PTR)0x8000000000000000)
-#else
- #define CALLSERVICE_NOTFOUND ((int)0x80000000)
-#endif
-
-#endif
-
//see modules.h for what all this stuff is
typedef struct tagPLUGINLINK {
HANDLE (*CreateHookableEvent)(const char *);
@@ -177,38 +161,6 @@ typedef struct tagPLUGINLINK { void (*KillObjectEventHooks)(void *);
} PLUGINLINK;
-#ifndef MODULES_H_
- #ifndef NODEFINEDLINKFUNCTIONS
- //relies on a global variable 'pluginLink' in the plugins
- extern PLUGINLINK *pluginLink;
- #define CreateHookableEvent(a) pluginLink->CreateHookableEvent(a)
- #define DestroyHookableEvent(a) pluginLink->DestroyHookableEvent(a)
- #define NotifyEventHooks(a, b, c) pluginLink->NotifyEventHooks(a, b, c)
- #define HookEventMessage(a, b, c) pluginLink->HookEventMessage(a, b, c)
- #define HookEvent(a, b) pluginLink->HookEvent(a, b)
- #define UnhookEvent(a) pluginLink->UnhookEvent(a)
- #define CreateServiceFunction(a, b) pluginLink->CreateServiceFunction(a, b)
- #define CreateTransientServiceFunction(a, b) pluginLink->CreateTransientServiceFunction(a, b)
- #define DestroyServiceFunction(a) pluginLink->DestroyServiceFunction(a)
- #define CallService(a, b, c) pluginLink->CallService(a, b, c)
- #define ServiceExists(a) pluginLink->ServiceExists(a)
- #define CallServiceSync(a, b, c) pluginLink->CallServiceSync(a, b, c)
- #define CallFunctionAsync(a, b) pluginLink->CallFunctionAsync(a, b)
- #define SetHookDefaultForHookableEvent(a, b) pluginLink->SetHookDefaultForHookableEvent(a, b)
- #define CreateServiceFunctionParam(a, b, c) pluginLink->CreateServiceFunctionParam(a, b, c)
- #define NotifyEventHooksDirect(a, b, c) pluginLink->NotifyEventHooksDirect(a, b, c)
- #define CallProtoService(a, b, c, d) pluginLink->CallProtoService(a, b, c, d)
- #define CallContactService(a, b, c, d) pluginLink->CallContactService(a, b, c, d)
- #define HookEventParam(a, b, c) pluginLink->HookEventParam(a, b, c)
- #define HookEventObj(a, b, c) pluginLink->HookEventObj(a, b, c)
- #define HookEventObjParam(a, b, c, d) pluginLink->HookEventObjParam(a, b, c, d)
- #define CreateServiceFunctionObj(a, b, c) pluginLink->CreateServiceFunctionObj(a, b, c)
- #define CreateServiceFunctionObjParam(a, b, c, d) pluginLink->CreateServiceFunctionObjParam(a, b, c, d)
- #define KillObjectServices(a) pluginLink->KillObjectServices(a)
- #define KillObjectEventHooks(a) pluginLink->KillObjectEventHooks(a)
- #endif
-#endif
-
/*
Database plugin stuff
*/
|