[RXCE]
[reactos.git] / rostests / win32 / rpcrt4 / context_handles / server.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <ctype.h>
4 #include "ctx.h"
5
6 void CtxOpen( PCTXTYPE *pphContext,
7 long Value)
8 {
9 printf("CtxOpen(): Value=%d\n",Value);
10 *pphContext = (PCTXTYPE)midl_user_allocate( sizeof(CTXTYPE) );
11 **pphContext = Value;
12 }
13
14 void CtxHello( PCTXTYPE phContext )
15 {
16 printf("CtxHello(): Hello, World! Context value: %d\n", *phContext);
17 }
18
19 void CtxClose(PCTXTYPE *pphContext )
20 {
21 printf("CtxClose(): %d\n", **pphContext);
22 midl_user_free(*pphContext);
23 *pphContext = NULL;
24 }
25
26
27 void main()
28 {
29 RPC_STATUS status;
30 unsigned int cMinCalls = 1;
31 unsigned int cMaxCalls = 20;
32 int i;
33
34 status = RpcServerUseProtseqEp("ncacn_np", 20, "\\pipe\\hello", NULL);
35
36 if (status)
37 {
38 printf("RpcServerUseProtseqEp %x\n", status);
39 exit(status);
40 }
41
42 status = RpcServerRegisterIf(hello_v1_0_s_ifspec, NULL, NULL);
43
44 if (status)
45 {
46 printf("RpcServerRegisterIf %x\n", status);
47 exit(status);
48 }
49
50 status = RpcServerListen(1, 20, FALSE);
51
52 if (status)
53 {
54 printf("RpcServerListen %x", status);
55 exit(status);
56 }
57
58 scanf("%d", &i);
59 }
60
61
62 void __RPC_USER PCTXTYPE_rundown(
63 PCTXTYPE hContext)
64 {
65 PCTXTYPE pCtx = (PCTXTYPE)hContext;
66 printf("Context rundown: Value=%d \n", *pCtx);
67 midl_user_free(hContext);
68 }
69
70 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
71 {
72 return(malloc(len));
73 }
74
75 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
76 {
77 free(ptr);
78 }