Организация удаленного доступа к распределенным базам данных

Информация - Компьютеры, программирование

Другие материалы по предмету Компьютеры, программирование

>{

MIDL_STUB_MESSAGE _StubMsg;

RPC_STATUS _Status;

((void)(_Status));

NdrServerInitializeNew(

_pRpcMessage,

&_StubMsg,

&CommService_StubDesc);

RpcTryFinally

{

RefreshIniProps();

}

RpcFinally

{

}

RpcEndFinally

_pRpcMessage->BufferLength =

Buffer);"> (unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer);

}

 

 

static const MIDL_STUB_DESC CommService_StubDesc =

{

(void __RPC_FAR *)& CommService___RpcServerInterface,

MIDL_user_allocate,

MIDL_user_free,

0,

0,

0,

0,

0,

__MIDLTypeFormatString.Format,

0, /* -error bounds_check flag */

0x10001, /* Ndr library version */

0,

0x300000f, /* MIDL Version 3.0.15 */

0,

0,

0, /* Reserved1 */

0, /* Reserved2 */

0, /* Reserved3 */

0, /* Reserved4 */

0 /* Reserved5 */

};

 

static RPC_DISPATCH_FUNCTION CommService_table[] =

{

CommService_RefreshIniProps,

0

};

RPC_DISPATCH_TABLE CommService_DispatchTable =

{

1,

CommService_table

};

 

#if !defined(__RPC_WIN32__)

#error Invalid build platform for this stub.

#endif

 

static const MIDL_PROC_FORMAT_STRING __MIDLProcFormatString =

{

0,

{

0x5b,/* FC_END */

0x5c,/* FC_PAD */

 

0x0

}

};

 

static const MIDL_TYPE_FORMAT_STRING __MIDLTypeFormatString =

{

0,

{

 

0x0

}

};

 

ShedulerServ.c

/**********************************************************//* Task Sheduler

/**********************************************************/

 

#include

#include "ShedulerServ.h"

#include "CommonConfig.h"

#include "EventLog.h"

 

#define SLEEP_INTERVAL 5000

#define ACTIVATE_INTERVAL 60000

 

BOOL TerminateSheduling = FALSE;

DWORD ShedulingThread;

 

 

DWORD WINAPI TaskProc(LPVOID ThreadParm);

voidAnalyseTaskTable();

DWORDGetTimeInMins();

 

DWORD WINAPI ShedulingProc(LPVOID ThreadParm)

{

long i = 0;

 

while (!TerminateSheduling) {

 

if ((i += SLEEP_INTERVAL) >= ACTIVATE_INTERVAL) {

 

i = 0;

if (TaskCount == 0)UpdateVariables();

 

AnalyseTaskTable();

}

Sleep(SLEEP_INTERVAL);

}

return 0;

}

 

DWORD WINAPI TaskProc(LPVOID ThreadParm)

{

HINSTANCEhLib;

FARPROChProc;

 

InterlockedIncrement(&TaskCount);

 

WaitForSingleObject(hConfigMutex, INFINITE);

MessageBeep(1);

if (hLib = LoadLibrary((char *)&((struct TASKENTRY*)ThreadParm)->DllName)) {

 

if (((struct TASKENTRY*)ThreadParm)->TermProc = GetProcAddress(hLib, (LPCSTR)TaskProcName))

{

((struct TASKENTRY*)ThreadParm)->Active = TRUE;

ReleaseMutex(hConfigMutex);

 

if (hProc = GetProcAddress(hLib, (LPCSTR)TaskProcName)) {

hProc();

__try {

WaitForSingleObject(hConfigMutex, INFINITE);

((struct TASKENTRY*)ThreadParm)->Active = FALSE;

CloseHandle((HANDLE)((struct TASKENTRY*)ThreadParm)->TaskThread);

}

__finally {

ReleaseMutex(hConfigMutex);

}

} else LogEvent(EVENTLOG_ERROR_TYPE, "Error Getting Procedure Address");

 

} else LogEvent(EVENTLOG_ERROR_TYPE, "Error Getting TermProc Address");

 

} else {

ReleaseMutex(hConfigMutex);

LogEvent(EVENTLOG_ERROR_TYPE, "Error Loading Library");

}

 

InterlockedDecrement(&TaskCount);

 

return 0;

}

 

voidAnalyseTaskTable()

{

DWORDCurrTime;

inti;

 

CurrTime = GetTimeInMins();

 

__try {

WaitForSingleObject(hConfigMutex, INFINITE);

 

for (i = 0; i < EntryCount; i++) {

if ((TaskTable[i].ExecTime == CurrTime) &&

(!TaskTable[i].Active)) {

CreateThread(NULL, 0, TaskProc, &TaskTable[i], 0, &TaskTable[i].TaskThread);

}

}

 

}

__finally {

ReleaseMutex(hConfigMutex);

}

}

 

DWORDGetTimeInMins()

{

SYSTEMTIME SysTime;

 

GetLocalTime(&SysTime);

 

return SysTime.wHour*60+SysTime.wMinute;

}

 

voidTerminateTasks()

{

inti;

DWORDTaskIndex = 0;

 

HANDLEHandles[TASK_COUNT];

 

for (i = 0; i < EntryCount; i++) {

if (TaskTable[i].Active) {

TaskTable[i].TermProc();

Handles[TaskIndex++] = (HANDLE)TaskTable[i].TaskThread;

}

}

 

WaitForMultipleObjects(TaskIndex, Handles, TRUE, INFINITE);

}

Comm.h

/* this ALWAYS GENERATED file contains the definitions for the interfaces */

 

 

/* File created by MIDL compiler version 3.00.15 */

/* at Tue Jun 03 11:35:46 1997

*/

/* Compiler settings for comm.idl:

Os, W1, Zp8, env=Win32, ms_ext, c_ext, oldnames

error checks: none

*/

//@@MIDL_FILE_HEADING( )

#include "rpc.h"

#include "rpcndr.h"

 

#ifndef __comm_h__

#define __comm_h__

 

#ifdef __cplusplus

extern "C"{

#endif

 

/* Forward Declarations */

 

void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);

void __RPC_USER MIDL_user_free( void __RPC_FAR * );

 

#ifndef __CommService_INTERFACE_DEFINED__

#define __CommService_INTERFACE_DEFINED__

 

/****************************************

* Generated header for interface: CommService

* at Tue Jun 03 11:35:46 1997

* using MIDL 3.00.15

****************************************/

/* [implicit_handle][version][uuid] */

 

 

void RefreshIniProps( void);

 

 

extern handle_t CommServ_IfHandle;

 

 

extern RPC_IF_HANDLE CommService_ClientIfHandle;

extern RPC_IF_HANDLE CommService_ServerIfHandle;

#endif /* __CommService_INTERFACE_DEFINED__ */

 

/* Additional Prototypes for ALL interfaces */

 

/* end of Additional Prototypes */

 

#ifdef __cplusplus

}

#endif

 

#endif

 

 

 

 

DoService.h

/**************************************************************/

/* DoService Module - implementation of initialisation other

/* tasks */

/* */

/* Copuright (c) 1997 by Malkov O.V. */

/* JSC "Svyazinform" RM */

/**************************************************************/

 

#ifndef __DOSERVICE

#define __DESERVICE

 

void ServerProcess();

DWORD ServerInit();

void ServerDoPause();

void ServerDoStop();

void ServerDoContinue();

 

 

#endif

 

CommonConfig.h

/**************** Server Engine Header File *******************/

 

#ifndef __COMMON_CONFIG

#define __COMMON_CONFIG

 

#define TASK_COUNT 10

 

#include "../RegistryConfig.h"

 

extern DWORD ConfigWatchingThread;

 

extern HANDLE hConfigMutex;

extern HANDLE hTaskMutex;

 

extern unsigned char *pszProtocolSequence;

extern unsigned char *pszSecurity;

extern unsigned char *pszEndpoint;

extern unsigned int cMinCalls;

extern unsigned int cMaxCalls;

extern unsigned int fDontWait;

 

extern structTASKENTRY TaskTable[TASK_COUNT];

extern intEntryCount;

extern DWORDTaskThreads[TASK_COUNT];

extern intTaskCount;

 

 

 

DWORD WINAPI CommonConfigWatcher(LPVOID ThreadParm);

void UpdateVariables();

 

#endif

 

EventLog.h

 

#ifndef __EVENT_LOG

#define __EVENT_LOG

 

void LogEvent(WORD EventType, LPSTR Eve