4 Copyright (C) Tim Potter 2003
\r
6 This program is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 This program is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with this program; if not, write to the Free Software
\r
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
\r
21 #define _WIN32_WINNT 0x0500
\r
26 #include "rpcecho.h"
\r
28 #define RPC_MIN_CALLS 1
\r
29 #define RPC_MAX_CALLS 20
\r
30 #define RPC_ENDPOINT "\\pipe\\rpcecho"
\r
32 void AddOne(int in_data, __RPC_FAR int *out_data)
\r
34 printf("AddOne: got in_data = %d\n", in_data);
\r
35 *out_data = in_data + 1;
\r
38 void EchoData(int len, unsigned char __RPC_FAR in_data[],
\r
39 unsigned char __RPC_FAR out_data[])
\r
41 printf("EchoData: got len = %d\n", len);
\r
43 memcpy(out_data, in_data, len);
\r
46 void SinkData(int len, unsigned char __RPC_FAR in_data[ ])
\r
48 printf("SinkData: got len = %d\n", len);
\r
51 void SourceData(int len, unsigned char __RPC_FAR out_data[ ])
\r
55 printf("SourceData: got len = %d\n", len);
\r
57 for (i = 0; i < len; i++)
\r
58 out_data[i] = i & 0xff;
\r
61 void TestCall(wchar_t **s1, wchar_t **s2)
\r
64 printf("s1='%S'\n", *s1);
\r
66 printf("s1=NULL\n");
\r
68 *s2 = L"test string";
\r
71 long TestCall2(short level, echo_Info **info)
\r
75 printf("TestCall2 level %d\n", level);
\r
98 i.info6.info1.v = 61;
\r
102 i.info7.info4.v = 71;
\r
111 void TestSleep(PRPC_ASYNC_STATE pAsync, long seconds)
\r
114 printf("async Sleeping for %d seconds\n", seconds);
\r
115 Sleep(1000 * seconds);
\r
117 RpcAsyncCompleteCall(pAsync, &ret);
\r
120 long TestSleep(long seconds)
\r
122 printf("non-async Sleeping for %d seconds\n", seconds);
\r
123 Sleep(1000 * seconds);
\r
128 void main(int argc, char **argv)
\r
131 RPC_BINDING_VECTOR *pBindingVector;
\r
134 printf("Usage: rpcechosrv\n");
\r
138 status = RpcServerUseProtseqEp("ncacn_np", RPC_MAX_CALLS, "\\pipe\\rpcecho", NULL);
\r
140 printf("Failed to register ncacn_np endpoint\n");
\r
144 status = RpcServerUseProtseqEp("ncacn_ip_tcp", RPC_MAX_CALLS, "1234", NULL);
\r
146 printf("Failed to register ncacn_ip_tcp endpoint\n");
\r
150 status = RpcServerInqBindings(&pBindingVector);
\r
152 printf("Failed RpcServerInqBindings\n");
\r
156 status = RpcEpRegister(rpcecho_v1_0_s_ifspec, pBindingVector, NULL, "rpcecho server");
\r
158 printf("Failed RpcEpRegister\n");
\r
162 status = RpcServerRegisterIf(rpcecho_v1_0_s_ifspec, NULL, NULL);
\r
165 printf("Failed to register interface\n");
\r
169 status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL);
\r
171 printf("Failed to setup auth info\n");
\r
174 status = RpcServerListen(RPC_MIN_CALLS, RPC_MAX_CALLS, FALSE);
\r
177 printf("RpcServerListen returned error %d\n", status);
\r