Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef __ROUTING_RTUTILS_H__
      7 #define __ROUTING_RTUTILS_H__
      8 
      9 #include <_mingw_unicode.h>
     10 
     11 #ifdef __cplusplus
     12 extern "C" {
     13 #endif
     14 
     15 #define TRACE_USE_FILE 0x00000001
     16 #define TRACE_USE_CONSOLE 0x00000002
     17 #define TRACE_NO_SYNCH 0x00000004
     18 
     19 #define TRACE_NO_STDINFO 0x00000001
     20 #define TRACE_USE_MASK 0x00000002
     21 #define TRACE_USE_MSEC 0x00000004
     22 #define TRACE_USE_DATE 0x00000008
     23 
     24 #define INVALID_TRACEID 0xFFFFFFFF
     25 
     26   DWORD WINAPI TraceRegisterExA(LPCSTR lpszCallerName,DWORD dwFlags);
     27   DWORD WINAPI TraceDeregisterA(DWORD dwTraceID);
     28   DWORD WINAPI TraceDeregisterExA(DWORD dwTraceID,DWORD dwFlags);
     29   DWORD WINAPI TraceGetConsoleA(DWORD dwTraceID,LPHANDLE lphConsole);
     30   DWORD __cdecl TracePrintfA(DWORD dwTraceID,LPCSTR lpszFormat,...);
     31   DWORD __cdecl TracePrintfExA(DWORD dwTraceID,DWORD dwFlags,LPCSTR lpszFormat,...);
     32   DWORD WINAPI TraceVprintfExA(DWORD dwTraceID,DWORD dwFlags,LPCSTR lpszFormat,va_list arglist);
     33   DWORD WINAPI TracePutsExA(DWORD dwTraceID,DWORD dwFlags,LPCSTR lpszString);
     34   DWORD WINAPI TraceDumpExA(DWORD dwTraceID,DWORD dwFlags,LPBYTE lpbBytes,DWORD dwByteCount,DWORD dwGroupSize,WINBOOL bAddressPrefix,LPCSTR lpszPrefix);
     35 
     36 #define TraceRegisterA(a) TraceRegisterExA(a,0)
     37 #define TraceVprintfA(a,b,c) TraceVprintfExA(a,0,b,c)
     38 #define TracePutsA(a,b) TracePutsExA(a,0,b)
     39 #define TraceDumpA(a,b,c,d,e,f) TraceDumpExA(a,0,b,c,d,e,f)
     40 
     41   DWORD WINAPI TraceRegisterExW(LPCWSTR lpszCallerName,DWORD dwFlags);
     42   DWORD WINAPI TraceDeregisterW(DWORD dwTraceID);
     43   DWORD WINAPI TraceDeregisterExW(DWORD dwTraceID,DWORD dwFlags);
     44   DWORD WINAPI TraceGetConsoleW(DWORD dwTraceID,LPHANDLE lphConsole);
     45   DWORD __cdecl TracePrintfW(DWORD dwTraceID,LPCWSTR lpszFormat,...);
     46   DWORD __cdecl TracePrintfExW(DWORD dwTraceID,DWORD dwFlags,LPCWSTR lpszFormat,...);
     47   DWORD WINAPI TraceVprintfExW(DWORD dwTraceID,DWORD dwFlags,LPCWSTR lpszFormat,va_list arglist);
     48   DWORD WINAPI TracePutsExW(DWORD dwTraceID,DWORD dwFlags,LPCWSTR lpszString);
     49   DWORD WINAPI TraceDumpExW(DWORD dwTraceID,DWORD dwFlags,LPBYTE lpbBytes,DWORD dwByteCount,DWORD dwGroupSize,WINBOOL bAddressPrefix,LPCWSTR lpszPrefix);
     50 
     51 #define TraceRegisterW(a) TraceRegisterExW(a,0)
     52 #define TraceVprintfW(a,b,c) TraceVprintfExW(a,0,b,c)
     53 #define TracePutsW(a,b) TracePutsExW(a,0,b)
     54 #define TraceDumpW(a,b,c,d,e,f) TraceDumpExW(a,0,b,c,d,e,f)
     55 
     56 #define TraceRegister __MINGW_NAME_AW(TraceRegister)
     57 #define TraceDeregister __MINGW_NAME_AW(TraceDeregister)
     58 #define TraceDeregisterEx __MINGW_NAME_AW(TraceDeregisterEx)
     59 #define TraceGetConsole __MINGW_NAME_AW(TraceGetConsole)
     60 #define TracePrintf __MINGW_NAME_AW(TracePrintf)
     61 #define TraceVprintf __MINGW_NAME_AW(TraceVprintf)
     62 #define TracePuts __MINGW_NAME_AW(TracePuts)
     63 #define TraceDump __MINGW_NAME_AW(TraceDump)
     64 #define TraceRegisterEx __MINGW_NAME_AW(TraceRegisterEx)
     65 #define TracePrintfEx __MINGW_NAME_AW(TracePrintfEx)
     66 #define TraceVprintfEx __MINGW_NAME_AW(TraceVprintfEx)
     67 #define TracePutsEx __MINGW_NAME_AW(TracePutsEx)
     68 #define TraceDumpEx __MINGW_NAME_AW(TraceDumpEx)
     69 
     70   VOID WINAPI LogErrorA(DWORD dwMessageId,DWORD cNumberOfSubStrings,LPSTR *plpwsSubStrings,DWORD dwErrorCode);
     71   VOID WINAPI LogEventA(DWORD wEventType,DWORD dwMessageId,DWORD cNumberOfSubStrings,LPSTR *plpwsSubStrings);
     72   VOID LogErrorW(DWORD dwMessageId,DWORD cNumberOfSubStrings,LPWSTR *plpwsSubStrings,DWORD dwErrorCode);
     73   VOID LogEventW(DWORD wEventType,DWORD dwMessageId,DWORD cNumberOfSubStrings,LPWSTR *plpwsSubStrings);
     74 
     75 #define LogError __MINGW_NAME_AW(LogError)
     76 #define LogEvent __MINGW_NAME_AW(LogEvent)
     77 
     78   HANDLE RouterLogRegisterA(LPCSTR lpszSource);
     79   VOID RouterLogDeregisterA(HANDLE hLogHandle);
     80   VOID RouterLogEventA(HANDLE hLogHandle,DWORD dwEventType,DWORD dwMessageId,DWORD dwSubStringCount,LPSTR *plpszSubStringArray,DWORD dwErrorCode);
     81   VOID RouterLogEventDataA(HANDLE hLogHandle,DWORD dwEventType,DWORD dwMessageId,DWORD dwSubStringCount,LPSTR *plpszSubStringArray,DWORD dwDataBytes,LPBYTE lpDataBytes);
     82   VOID RouterLogEventStringA(HANDLE hLogHandle,DWORD dwEventType,DWORD dwMessageId,DWORD dwSubStringCount,LPSTR *plpszSubStringArray,DWORD dwErrorCode,DWORD dwErrorIndex);
     83   VOID __cdecl RouterLogEventExA(HANDLE hLogHandle,DWORD dwEventType,DWORD dwErrorCode,DWORD dwMessageId,LPCSTR ptszFormat,...);
     84   VOID RouterLogEventValistExA(HANDLE hLogHandle,DWORD dwEventType,DWORD dwErrorCode,DWORD dwMessageId,LPCSTR ptszFormat,va_list arglist);
     85   DWORD RouterGetErrorStringA(DWORD dwErrorCode,LPSTR *lplpszErrorString);
     86 
     87 #define RouterLogErrorA(h,msg,count,array,err) RouterLogEventA(h,EVENTLOG_ERROR_TYPE,msg,count,array,err)
     88 #define RouterLogWarningA(h,msg,count,array,err) RouterLogEventA(h,EVENTLOG_WARNING_TYPE,msg,count,array,err)
     89 #define RouterLogInformationA(h,msg,count,array,err) RouterLogEventA(h,EVENTLOG_INFORMATION_TYPE,msg,count,array,err)
     90 
     91 #define RouterLogErrorDataA(h,msg,count,array,c,buf) RouterLogEventDataA(h,EVENTLOG_ERROR_TYPE,msg,count,array,c,buf)
     92 #define RouterLogWarningDataA(h,msg,count,array,c,buf) RouterLogEventDataA(h,EVENTLOG_WARNING_TYPE,msg,count,array,c,buf)
     93 #define RouterLogInformationDataA(h,msg,count,array,c,buf) RouterLogEventDataA(h,EVENTLOG_INFORMATION_TYPE,msg,count,array,c,buf)
     94 
     95 #define RouterLogErrorStringA(h,msg,count,array,err,index) RouterLogEventStringA(h,EVENTLOG_ERROR_TYPE,msg,count,array,err,index)
     96 #define RouterLogWarningStringA(h,msg,count,array,err,index) RouterLogEventStringA(h,EVENTLOG_WARNING_TYPE,msg,count,array,err,index)
     97 #define RouterLogInformationStringA(h,msg,count,array,err,index) RouterLogEventStringA(h,EVENTLOG_INFORMATION_TYPE,msg,count,array,err,index)
     98 
     99   HANDLE RouterLogRegisterW(LPCWSTR lpszSource);
    100   VOID RouterLogDeregisterW(HANDLE hLogHandle);
    101   VOID RouterLogEventW(HANDLE hLogHandle,DWORD dwEventType,DWORD dwMessageId,DWORD dwSubStringCount,LPWSTR *plpszSubStringArray,DWORD dwErrorCode);
    102   VOID RouterLogEventDataW(HANDLE hLogHandle,DWORD dwEventType,DWORD dwMessageId,DWORD dwSubStringCount,LPWSTR *plpszSubStringArray,DWORD dwDataBytes,LPBYTE lpDataBytes);
    103   VOID RouterLogEventStringW(HANDLE hLogHandle,DWORD dwEventType,DWORD dwMessageId,DWORD dwSubStringCount,LPWSTR *plpszSubStringArray,DWORD dwErrorCode,DWORD dwErrorIndex);
    104   VOID __cdecl RouterLogEventExW(HANDLE hLogHandle,DWORD dwEventType,DWORD dwErrorCode,DWORD dwMessageId,LPCWSTR ptszFormat,...);
    105   VOID RouterLogEventValistExW(HANDLE hLogHandle,DWORD dwEventType,DWORD dwErrorCode,DWORD dwMessageId,LPCWSTR ptszFormat,va_list arglist);
    106   DWORD RouterGetErrorStringW(DWORD dwErrorCode,LPWSTR *lplpwszErrorString);
    107 
    108 #define RouterLogErrorW(h,msg,count,array,err) RouterLogEventW(h,EVENTLOG_ERROR_TYPE,msg,count,array,err)
    109 #define RouterLogWarningW(h,msg,count,array,err) RouterLogEventW(h,EVENTLOG_WARNING_TYPE,msg,count,array,err)
    110 #define RouterLogInformationW(h,msg,count,array,err) RouterLogEventW(h,EVENTLOG_INFORMATION_TYPE,msg,count,array,err)
    111 
    112 #define RouterLogErrorDataW(h,msg,count,array,c,buf) RouterLogEventDataW(h,EVENTLOG_ERROR_TYPE,msg,count,array,c,buf)
    113 #define RouterLogWarningDataW(h,msg,count,array,c,buf) RouterLogEventDataW(h,EVENTLOG_WARNING_TYPE,msg,count,array,c,buf)
    114 #define RouterLogInformationDataW(h,msg,count,array,c,buf) RouterLogEventDataW(h,EVENTLOG_INFORMATION_TYPE,msg,count,array,c,buf)
    115 
    116 #define RouterLogErrorStringW(h,msg,count,array,err,index) RouterLogEventStringW(h,EVENTLOG_ERROR_TYPE,msg,count,array,err,index)
    117 #define RouterLogWarningStringW(h,msg,count,array,err,index) RouterLogEventStringW(h,EVENTLOG_WARNING_TYPE,msg,count,array,err,index)
    118 #define RouterLogInformationStringW(h,msg,count,array,err,index) RouterLogEventStringW(h,EVENTLOG_INFORMATION_TYPE,msg,count,array,err,index)
    119 
    120 #define RouterLogRegister __MINGW_NAME_AW(RouterLogRegister)
    121 #define RouterLogDeregister __MINGW_NAME_AW(RouterLogDeregister)
    122 #define RouterLogEvent __MINGW_NAME_AW(RouterLogEvent)
    123 #define RouterLogError __MINGW_NAME_AW(RouterLogError)
    124 #define RouterLogWarning __MINGW_NAME_AW(RouterLogWarning)
    125 #define RouterLogInformation __MINGW_NAME_AW(RouterLogInformation)
    126 
    127 #define RouterLogEventData __MINGW_NAME_AW(RouterLogEventData)
    128 #define RouterLogErrorData __MINGW_NAME_AW(RouterLogErrorData)
    129 #define RouterLogWarningData __MINGW_NAME_AW(RouterLogWarningData)
    130 #define RouterLogInformationData __MINGW_NAME_AW(RouterLogInformationData)
    131 #define RouterLogEventString __MINGW_NAME_AW(RouterLogEventString)
    132 #define RouterLogEventEx __MINGW_NAME_AW(RouterLogEventEx)
    133 #define RouterLogEventValistEx __MINGW_NAME_AW(RouterLogEventValistEx)
    134 #define RouterLogErrorString __MINGW_NAME_AW(RouterLogErrorString)
    135 #define RouterLogWarningString __MINGW_NAME_AW(RouterLogWarningString)
    136 #define RouterLogInformationString __MINGW_NAME_AW(RouterLogInformationString)
    137 #define RouterGetErrorString __MINGW_NAME_AW(RouterGetErrorString)
    138 
    139   typedef VOID (WINAPI *WORKERFUNCTION)(PVOID);
    140 
    141   DWORD WINAPI QueueWorkItem(WORKERFUNCTION functionptr,PVOID context,WINBOOL serviceinalertablethread);
    142   DWORD WINAPI SetIoCompletionProc(HANDLE FileHandle,LPOVERLAPPED_COMPLETION_ROUTINE CompletionProc);
    143 
    144 #define NUM_ALERTABLE_THREADS 2
    145 #define MAX_WORKER_THREADS 10
    146 #define WORK_QUEUE_TIMEOUT 1
    147 #define THREAD_IDLE_TIMEOUT 10
    148 
    149   VOID RouterAssert(PSTR pszFailedAssertion,PSTR pszFileName,DWORD dwLineNumber,PSTR pszMessage);
    150 
    151 #define RTASSERT(exp)
    152 #define RTASSERTMSG(msg,exp)
    153 
    154 #define RTUTILS_MAX_PROTOCOL_NAME_LEN 40
    155 #define RTUTILS_MAX_PROTOCOL_DLL_LEN 48
    156 
    157 #ifndef MAX_PROTOCOL_NAME_LEN
    158 #define MAX_PROTOCOL_NAME_LEN RTUTILS_MAX_PROTOCOL_NAME_LEN
    159 #else
    160 #undef MAX_PROTOCOL_NAME_LEN
    161 #endif
    162 #define MAX_PROTOCOL_DLL_LEN RTUTILS_MAX_PROTOCOL_DLL_LEN
    163 
    164   typedef struct _MPR_PROTOCOL_0 {
    165     DWORD dwProtocolId;
    166     WCHAR wszProtocol[RTUTILS_MAX_PROTOCOL_NAME_LEN+1];
    167     WCHAR wszDLLName[RTUTILS_MAX_PROTOCOL_DLL_LEN+1];
    168   } MPR_PROTOCOL_0;
    169 
    170   DWORD WINAPI MprSetupProtocolEnum(DWORD dwTransportId,LPBYTE *lplpBuffer,LPDWORD lpdwEntriesRead);
    171   DWORD WINAPI MprSetupProtocolFree(LPVOID lpBuffer);
    172 
    173 #define ROUTING_RESERVED
    174 #define OPT1_1
    175 #define OPT1_2
    176 #define OPT2_1
    177 #define OPT2_2
    178 #define OPT3_1
    179 #define OPT3_2
    180 
    181   struct _WAIT_THREAD_ENTRY;
    182   struct _WT_EVENT_ENTRY;
    183 
    184 #define TIMER_INACTIVE 3
    185 #define TIMER_ACTIVE 4
    186 
    187   typedef struct _WT_TIMER_ENTRY {
    188     LONGLONG te_Timeout;
    189     WORKERFUNCTION te_Function;
    190     PVOID te_Context;
    191     DWORD te_ContextSz;
    192     WINBOOL te_RunInServer;
    193     DWORD te_Status;
    194     DWORD te_ServerId;
    195     struct _WAIT_THREAD_ENTRY *teP_wte;
    196     LIST_ENTRY te_ServerLinks;
    197     LIST_ENTRY te_Links;
    198     WINBOOL te_Flag;
    199     DWORD te_TimerId;
    200   } WT_TIMER_ENTRY,*PWT_TIMER_ENTRY;
    201 
    202   typedef struct _WT_WORK_ITEM {
    203     WORKERFUNCTION wi_Function;
    204     PVOID wi_Context;
    205     DWORD wi_ContextSz;
    206     WINBOOL wi_RunInServer;
    207     struct _WT_EVENT_ENTRY *wiP_ee;
    208     LIST_ENTRY wi_ServerLinks;
    209     LIST_ENTRY wi_Links;
    210   } WT_WORK_ITEM,*PWT_WORK_ITEM;
    211 
    212 #define WT_EVENT_BINDING WT_WORK_ITEM
    213 #define PWT_EVENT_BINDING PWT_WORK_ITEM
    214 
    215   typedef struct _WT_EVENT_ENTRY {
    216     HANDLE ee_Event;
    217     WINBOOL ee_bManualReset;
    218     WINBOOL ee_bInitialState;
    219     WINBOOL ee_bDeleteEvent;
    220     DWORD ee_Status;
    221     WINBOOL ee_bHighPriority;
    222 
    223     LIST_ENTRY eeL_wi;
    224     WINBOOL ee_bSignalSingle;
    225     WINBOOL ee_bOwnerSelf;
    226     INT ee_ArrayIndex;
    227     DWORD ee_ServerId;
    228     struct _WAIT_THREAD_ENTRY *eeP_wte;
    229     LIST_ENTRY ee_ServerLinks;
    230     LIST_ENTRY ee_Links;
    231     DWORD ee_RefCount;
    232     WINBOOL ee_bFlag;
    233     DWORD ee_EventId;
    234   } WT_EVENT_ENTRY,*PWT_EVENT_ENTRY;
    235 
    236   PWT_EVENT_ENTRY WINAPI CreateWaitEvent(HANDLE pEvent OPT1_1,LPSECURITY_ATTRIBUTES lpEventAttributes OPT1_2,WINBOOL bManualReset,WINBOOL bInitialState,LPCTSTR lpName OPT1_2,WINBOOL bHighPriority,WORKERFUNCTION pFunction OPT2_1,PVOID pContext OPT2_1,DWORD dwContextSz OPT2_1,WINBOOL bRunInServerContext OPT2_1);
    237   PWT_EVENT_BINDING WINAPI CreateWaitEventBinding(PWT_EVENT_ENTRY pee,WORKERFUNCTION pFunction,PVOID pContext,DWORD dwContextSz,WINBOOL bRunInServerContext);
    238   PWT_TIMER_ENTRY WINAPI CreateWaitTimer(WORKERFUNCTION pFunction,PVOID pContext,DWORD dwContextSz,WINBOOL bRunInServerContext);
    239   DWORD WINAPI DeRegisterWaitEventBindingSelf(PWT_EVENT_BINDING pwiWorkItem);
    240   DWORD WINAPI DeRegisterWaitEventBinding(PWT_EVENT_BINDING pwiWorkItem);
    241   DWORD WINAPI DeRegisterWaitEventsTimers (PLIST_ENTRY pLEvents,PLIST_ENTRY pLTimers);
    242   DWORD WINAPI DeRegisterWaitEventsTimersSelf(PLIST_ENTRY pLEvents,PLIST_ENTRY pLTimers);
    243   DWORD WINAPI RegisterWaitEventBinding(PWT_EVENT_BINDING pwiWorkItem);
    244   DWORD WINAPI RegisterWaitEventsTimers(PLIST_ENTRY pLEventsToAdd,PLIST_ENTRY pLTimersToAdd);
    245   DWORD WINAPI UpdateWaitTimer(PWT_TIMER_ENTRY pte,LONGLONG *time);
    246   VOID WINAPI WTFree (PVOID ptr);
    247   VOID WINAPI WTFreeEvent(PWT_EVENT_ENTRY peeEvent);
    248   VOID WINAPI WTFreeTimer(PWT_TIMER_ENTRY pteTimer);
    249   VOID WINAPI DebugPrintWaitWorkerThreads (DWORD dwDebugLevel);
    250 
    251 #define DEBUGPRINT_FILTER_NONCLIENT_EVENTS 0x2
    252 #define DEBUGPRINT_FILTER_EVENTS 0x4
    253 #define DEBUGPRINT_FILTER_TIMERS 0x8
    254 
    255 #define ERROR_WAIT_THREAD_UNAVAILABLE 1
    256 #define ERROR_WT_EVENT_ALREADY_DELETED 2
    257 #define TIMER_HIGH(time) (((LARGE_INTEGER*)&time)->HighPart)
    258 #define TIMER_LOW(time) (((LARGE_INTEGER*)&time)->LowPart)
    259 
    260 #ifdef __cplusplus
    261 }
    262 #endif
    263 #endif
    264