Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

instance.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define INST_GROW_COUNT   4
#define perrs   ((MONERRSTRUCT *)&pep->Data)

Functions

HANDLE AddInstance (HANDLE hInstServer)
HANDLE DestroyInstance (HANDLE hInstClient)
PCL_INSTANCE_INFO ValidateInstance (HANDLE hInstClient)
VOID SetLastDDEMLError (PCL_INSTANCE_INFO pcii, DWORD error)

Variables

PHANDLE aInstance = NULL
int cInstAllocated = 0
int iFirstFreeInst = 0


Define Documentation

#define INST_GROW_COUNT   4
 

Definition at line 17 of file instance.c.

Referenced by AddInstance().

#define perrs   ((MONERRSTRUCT *)&pep->Data)
 

Referenced by SetLastDDEMLError().


Function Documentation

HANDLE AddInstance HANDLE  hInstServer  ) 
 

Definition at line 40 of file instance.c.

References aInstance, cInstAllocated, CreateHandle(), DDEMLAlloc, DDEMLReAlloc, HTYPE_INSTANCE, iFirstFreeInst, INST_GROW_COUNT, MAX_INST, and UINT.

Referenced by InternalDdeInitialize().

00042 { 00043 int i, iNextFree; 00044 PHANDLE ph; 00045 00046 if (iFirstFreeInst >= cInstAllocated) { 00047 if (cInstAllocated == 0) { 00048 aInstance = (PHANDLE)DDEMLAlloc(sizeof(HANDLE) * INST_GROW_COUNT); 00049 } else { 00050 aInstance = (PHANDLE)DDEMLReAlloc((PVOID)aInstance, 00051 sizeof(HANDLE) * (cInstAllocated + INST_GROW_COUNT)); 00052 } 00053 if (aInstance == 0) { 00054 return (0); 00055 } 00056 ph = &aInstance[cInstAllocated]; 00057 i = cInstAllocated + 1; 00058 while (i <= cInstAllocated + INST_GROW_COUNT) { 00059 *ph++ = (HANDLE)(UINT_PTR)(UINT)i++; 00060 } 00061 cInstAllocated += INST_GROW_COUNT; 00062 } 00063 iNextFree = HandleToUlong(aInstance[iFirstFreeInst]); 00064 if (iNextFree > MAX_INST) { 00065 /* 00066 * Instance limit for this process exceeded! 00067 */ 00068 return(0); 00069 } 00070 aInstance[iFirstFreeInst] = hInstServer; 00071 i = iFirstFreeInst; 00072 iFirstFreeInst = iNextFree; 00073 return (CreateHandle(0, HTYPE_INSTANCE, i)); 00074 }

HANDLE DestroyInstance HANDLE  hInstClient  ) 
 

Definition at line 87 of file instance.c.

References aInstance, DestroyHandle(), iFirstFreeInst, and InstFromHandle.

Referenced by DdeUninitialize().

00089 { 00090 register HANDLE hInstServerRet = 0; 00091 00092 DestroyHandle(hInstClient); 00093 hInstServerRet = aInstance[InstFromHandle(hInstClient)]; 00094 aInstance[InstFromHandle(hInstClient)] = (HANDLE)UIntToPtr( iFirstFreeInst ); 00095 iFirstFreeInst = InstFromHandle(hInstClient); 00096 00097 return (hInstServerRet); 00098 }

VOID SetLastDDEMLError PCL_INSTANCE_INFO  pcii,
DWORD  error
 

Definition at line 137 of file instance.c.

References tagCL_INSTANCE_INFO::afCmd, DDEMLAlloc, DWORD, EnterDDECrit, Event(), GetCurrentProcessId, tagCL_INSTANCE_INFO::LastError, LeaveDDECrit, tagCL_INSTANCE_INFO::MonitorFlags, NtGetTickCount(), NULL, pep, perrs, tagCL_INSTANCE_INFO::tid, TRUE, and VOID().

Referenced by AddLink(), BestSetLastDDEMLError(), ClRespRequestData(), ClSpontAdviseData(), ClStartAdvise(), ClStartExecute(), ClStartPoke(), ClStartRequest(), ClStartUnadvise(), ConnectConv(), DdeAbandonTransaction(), DdeAddData(), DdeClientTransaction(), DdeConnect(), DdeConnectList(), DdeCreateDataHandle(), DdeEnableCallback(), DdeFreeStringHandle(), DdeGetData(), DdeKeepStringHandle(), DdeNameService(), DdePostAdvise(), DdeQueryConvInfo(), DdeQueryNextServer(), DdeReconnect(), InternalDdeQueryString(), MonitorConv(), MonitorLink(), MonitorStringHandle(), SvSpontAdvise(), SvSpontExecute(), SvSpontPoke(), SvSpontRequest(), SvSpontUnadvise(), SvStartAdviseUpdate(), TransactionComplete(), ValidateConnectParameters(), and ValidateTransaction().

00140 { 00141 PEVENT_PACKET pep; 00142 00143 if (pcii->MonitorFlags & MF_ERRORS && !(pcii->afCmd & APPCLASS_MONITOR)) { 00144 pep = (PEVENT_PACKET)DDEMLAlloc(sizeof(EVENT_PACKET) - sizeof(DWORD) + 00145 sizeof(MONERRSTRUCT)); 00146 if (pep != NULL) { 00147 pep->EventType = MF_ERRORS; 00148 pep->fSense = TRUE; 00149 pep->cbEventData = sizeof(MONERRSTRUCT); 00150 #define perrs ((MONERRSTRUCT *)&pep->Data) 00151 perrs->cb = sizeof(MONERRSTRUCT); 00152 perrs->wLastError = (WORD)error; 00153 perrs->dwTime = NtGetTickCount(); 00154 perrs->hTask = (HANDLE)LongToHandle( pcii->tid ); 00155 #undef perrs 00156 LeaveDDECrit; 00157 Event(pep); 00158 EnterDDECrit; 00159 } 00160 } 00161 #if DBG 00162 if (error != 0 && error != DMLERR_NO_CONV_ESTABLISHED) { 00163 RIPMSG3(RIP_WARNING, 00164 "DDEML Error set=%x, Client Instance=%x, Process=%x.", 00165 error, pcii, GetCurrentProcessId()); 00166 } 00167 #endif 00168 pcii->LastError = error; 00169 }

PCL_INSTANCE_INFO ValidateInstance HANDLE  hInstClient  ) 
 

Definition at line 111 of file instance.c.

References HINST_ANY, tagCL_INSTANCE_INFO::hInstClient, HTYPE_INSTANCE, NULL, tagCL_INSTANCE_INFO::tid, and ValidateCHandle().

Referenced by DdeAbandonTransaction(), DdeCreateDataHandle(), DdeEnableCallback(), DdeFreeStringHandle(), DdeGetLastError(), DdeKeepStringHandle(), DDEMLClientWndProc(), DdeNameService(), DdePostAdvise(), DdeUninitialize(), InternalDdeCreateStringHandle(), InternalDdeInitialize(), InternalDdeQueryString(), ValidateConnectParameters(), and ValidateTransaction().

00113 { 00114 PCL_INSTANCE_INFO pcii; 00115 00116 pcii = (PCL_INSTANCE_INFO)ValidateCHandle(hInstClient, HTYPE_INSTANCE, HINST_ANY); 00117 00118 if (pcii != NULL) { 00119 if (pcii->tid != GetCurrentThreadId() || 00120 pcii->hInstClient != hInstClient) { 00121 return (NULL); 00122 } 00123 } 00124 return (pcii); 00125 }


Variable Documentation

PHANDLE aInstance = NULL
 

Definition at line 21 of file instance.c.

Referenced by AddInstance(), and DestroyInstance().

int cInstAllocated = 0
 

Definition at line 22 of file instance.c.

Referenced by AddInstance().

int iFirstFreeInst = 0
 

Definition at line 23 of file instance.c.

Referenced by AddInstance(), and DestroyInstance().


Generated on Sat May 15 19:44:13 2004 for test by doxygen 1.3.7