📄 rpcfact_s.cpp
字号:
/* this ALWAYS GENERATED file contains the RPC server stubs */
/* File created by MIDL compiler version 5.01.0164 */
/* at Wed Dec 05 09:20:26 2007
*/
/* Compiler settings for Rpcfact.idl:
Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext
error checks: allocation ref bounds_check enum stub_data
*/
//@@MIDL_FILE_HEADING( )
#include <string.h>
//////////////////////////////////////////////////////////////////////////
// File: RpcFact_s.c
#include "stdio.h"
#include "stdlib.h"
#include <windows.h>
#include <iostream.h>
#include <rpc.h>
#include "Rpcfact.h"
#include "memstub.h" // 实现RPC函数的存储分配, 稍后介绍
//////////////////////////////////////////////////////////////////////////
#define TYPE_FORMAT_STRING_SIZE 3
#define PROC_FORMAT_STRING_SIZE 5
typedef struct _MIDL_TYPE_FORMAT_STRING
{
short Pad;
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
} MIDL_TYPE_FORMAT_STRING;
typedef struct _MIDL_PROC_FORMAT_STRING
{
short Pad;
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
} MIDL_PROC_FORMAT_STRING;
extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
/* Standard interface: rpcfactorial, ver. 1.0,
GUID={0xC16F6562,0x520D,0x11D0,{0xB3,0x38,0x44,0x45,0x53,0x54,0x00,0x00}} */
static RPC_PROTSEQ_ENDPOINT __RpcProtseqEndpoint[] =
{
{(unsigned char *) "ncalrpc", (unsigned char *) "myFactorial"}
};
extern RPC_DISPATCH_TABLE rpcfactorial_v1_0_DispatchTable;
static const RPC_SERVER_INTERFACE rpcfactorial___RpcServerInterface =
{
sizeof(RPC_SERVER_INTERFACE),
{{0xC16F6562,0x520D,0x11D0,{0xB3,0x38,0x44,0x45,0x53,0x54,0x00,0x00}},{1,0}},
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
&rpcfactorial_v1_0_DispatchTable,
1,
__RpcProtseqEndpoint,
0,
0,
0
};
RPC_IF_HANDLE rpcfactorial_v1_0_s_ifspec = (RPC_IF_HANDLE)& rpcfactorial___RpcServerInterface;
extern const MIDL_STUB_DESC rpcfactorial_StubDesc;
void __RPC_STUB
rpcfactorial_RpcFactorial(
PRPC_MESSAGE _pRpcMessage )
{
long _RetVal;
MIDL_STUB_MESSAGE _StubMsg;
long nVal;
RPC_STATUS _Status;
((void)(_Status));
NdrServerInitializeNew(
_pRpcMessage,
&_StubMsg,
&rpcfactorial_StubDesc);
RpcTryFinally
{
RpcTryExcept
{
if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );
nVal = (*(( long __RPC_FAR * )_StubMsg.Buffer))++;
if(_StubMsg.Buffer > _StubMsg.BufferEnd)
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
}
RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
RpcEndExcept
_RetVal = RpcFactorial(nVal);
_StubMsg.BufferLength = 4U;
_pRpcMessage->BufferLength = _StubMsg.BufferLength;
_Status = I_RpcGetBuffer( _pRpcMessage );
if ( _Status )
RpcRaiseException( _Status );
_StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer;
(*(( long __RPC_FAR * )_StubMsg.Buffer))++ ;
*(( long __RPC_FAR * )_StubMsg.Buffer)= _RetVal;
}
RpcFinally
{
}
RpcEndFinally
_pRpcMessage->BufferLength =
(unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer);
}
static const MIDL_STUB_DESC rpcfactorial_StubDesc =
{
(void __RPC_FAR *)& rpcfactorial___RpcServerInterface,
MIDL_user_allocate,
MIDL_user_free,
0,
0,
0,
0,
0,
__MIDL_TypeFormatString.Format,
1, /* -error bounds_check flag */
0x10001, /* Ndr library version */
0,
0x50100a4, /* MIDL Version 5.1.164 */
0,
0,
0, /* notify & notify_flag routine table */
1, /* Flags */
0, /* Reserved3 */
0, /* Reserved4 */
0 /* Reserved5 */
};
static RPC_DISPATCH_FUNCTION rpcfactorial_table[] =
{
rpcfactorial_RpcFactorial,
0
};
RPC_DISPATCH_TABLE rpcfactorial_v1_0_DispatchTable =
{
1,
rpcfactorial_table
};
#if !defined(__RPC_WIN32__)
#error Invalid build platform for this stub.
#endif
static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
{
0,
{
0x4e, /* FC_IN_PARAM_BASETYPE */
0x8, /* FC_LONG */
/* 2 */ 0x53, /* FC_RETURN_PARAM_BASETYPE */
0x8, /* FC_LONG */
0x0
}
};
static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
{
0,
{
NdrFcShort( 0x0 ), /* 0 */
0x0
}
};
main()
{
RPC_BINDING_VECTOR* bindVector;
RPC_STATUS lRetVal;
unsigned char * pszAutoEntryName = (unsigned char*)"/.:/implicit_IFLink";
unsigned char * pszSecurity = NULL;
unsigned int cMinCalls = 1;
unsigned int cMaxCalls = RPC_C_LISTEN_MAX_CALLS_DEFAULT;
unsigned int fDontWait = FALSE;
unsigned int fNameSyntaxType = RPC_C_NS_SYNTAX_DEFAULT;
// 注册所有可行的协议序列, 所支持的协议由在RpcFact.idl的端点定义中的字符串指定
// 参数rpcfactorial_v1_0_s_ifspec定义在RpcFact.h中, 由MIDL编译生成
if (lRetVal = RpcServerUseAllProtseqsIf(2, rpcfactorial_v1_0_s_ifspec, NULL))
{
cout<<"Error in RpcServerUseAllProtseqsIf"<<lRetVal<<endl;
return 1;
}
// 注册所支持的接口
if (RpcServerRegisterIf(rpcfactorial_v1_0_s_ifspec, NULL, NULL))
{
cout<<"Error in RpcServerRegister"<<endl;
return 1;
}
// 将接口的捆绑输出到名称服务程序
if (RpcServerInqBindings(&bindVector))
{
cout<<"Error in RpcServerInqBindings"<<endl;
return 1;
}
// if (RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, (UCHAR*)"/.: /autorpc", rpcfactorial_v1_0_s_ifspec, bindVector, NULL))
//
// {
//
// cout<<"Error in RpcServerBidingExport"<<endl;
//
// return 1;
//
// }
if(RpcNsBindingExport(fNameSyntaxType, pszAutoEntryName, rpcfactorial_v1_0_s_ifspec, bindVector, NULL))
{
cout<<"Error in RpcServerBidingExport"<<endl;
return 1;
}
if(RpcEpRegister(rpcfactorial_v1_0_s_ifspec, bindVector, NULL,NULL))
{
cout<<"Error in RpcEpRegister"<<endl;
return 1;
}
// 侦听RPC请求
cout<<"Calling RpcServerListen"<<endl;
if (RpcServerListen(1, 5, FALSE))
{
cout<<"Error in RpcServerListen"<<endl;
return 1;
}
return 0;
}// end main
// end File RpcFact_s.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -