--- mstools/samples/rpc/handles/auto/autos.c 2018/08/09 18:20:56 1.1.1.1 +++ mstools/samples/rpc/handles/auto/autos.c 2018/08/09 18:22:05 1.1.1.2 @@ -4,7 +4,7 @@ Auto Example FILE: autos.c - USAGE: server + USAGE: autos PURPOSE: Server side of RPC distributed application Auto FUNCTIONS: main() - registers server as RPC server COMMENTS: Server side of auto handle example program. @@ -21,16 +21,28 @@ void Usage(char * pszProgramName) fprintf(stderr, "Usage: %s\n", pszProgramName); fprintf(stderr, " -p protocol_sequence\n"); fprintf(stderr, " -e endpoint\n"); + fprintf(stderr, " -m maxcalls\n"); + fprintf(stderr, " -n mincalls\n"); + fprintf(stderr, " -f flag for RpcServerListen wait\n"); + fprintf(stderr, " -s security_descriptor\n"); + fprintf(stderr, " -a auto_sample_nsi_entry_name\n"); + fprintf(stderr, " -t name_syntax_type\n"); exit(1); } -void main(int argc, char * argv[]) +void _CRTAPI1 main(int argc, char * argv[]) { RPC_STATUS status; RPC_BINDING_VECTOR * pBindingVector; + unsigned char * pszAutoEntryName = "/.:/Autohandle_sample"; unsigned char * pszEndpoint = "\\pipe\\auto"; unsigned char * pszProtocolSequence = "ncacn_np"; + unsigned char * pszSecurity = NULL; + unsigned int cMinCalls = 1; + unsigned int cMaxCalls = 20; + unsigned int fDontWait = FALSE; + unsigned int fNameSyntaxType = RPC_C_NS_SYNTAX_DEFAULT; int i; // allow the user to override settings with command line switches @@ -43,6 +55,24 @@ void main(int argc, char * argv[]) case 'e': pszEndpoint = argv[++i]; break; + case 'm': + cMaxCalls = (unsigned int) atoi(argv[++i]); + break; + case 'n': + cMinCalls = (unsigned int) atoi(argv[++i]); + break; + case 'f': + fDontWait = (unsigned int) atoi(argv[++i]); + break; + case 's': + pszSecurity = argv[++i]; + break; + case 'a': + pszAutoEntryName = argv[++i]; + break; + case 't': + fNameSyntaxType = (unsigned int) atoi(argv[++i]); + break; case 'h': case '?': default: @@ -53,46 +83,56 @@ void main(int argc, char * argv[]) Usage(argv[0]); } - status = RpcServerUseProtseqEp(pszProtocolSequence, - 1, // maximum concurrent calls + cMaxCalls, // max concurrent calls pszEndpoint, - 0); + pszSecurity); // Security descriptor printf("RpcServerUseProtseqEp returned 0x%x\n", status); if (status) { - exit(2); + exit(status); } - status = RpcServerRegisterIf(autoh_ServerIfHandle, 0, 0); + status = RpcServerRegisterIf( + autoh_ServerIfHandle, // interface to register + NULL, // MgrTypeUuid + NULL); // MgrEpv; null means use default printf("RpcServerRegisterIf returned 0x%x\n", status); if (status) { - exit(2); + exit(status); } status = RpcServerInqBindings(&pBindingVector); printf("RpcServerInqBindings returned 0x%x\n", status); if (status) { - exit(2); + exit(status); } - status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, /* name syntax */ - "/.:/Autohandle_sample", /* name */ + status = RpcNsBindingExport(fNameSyntaxType, /* name syntax type */ + pszAutoEntryName, /* nsi entry name */ autoh_ServerIfHandle, - pBindingVector, + pBindingVector, /* set in previous call */ NULL); /* UUID vector */ printf("RpcNsBindingExport returned 0x%x\n", status); if (status) { - exit(2); + exit(status); } - printf("Calling RpcServerListen\n"); - status = RpcServerListen(1, - 20); + status = RpcServerListen(cMinCalls, + cMaxCalls, + fDontWait); /* wait flag */ printf("RpcServerListen returned: 0x%x\n", status); if (status) { - exit(2); + exit(status); } + if (fDontWait) { + printf("Calling RpcMgmtWaitServerListen\n"); + status = RpcMgmtWaitServerListen(); // wait operation + printf("RpcMgmtWaitServerListen returned: 0x%x\n", status); + if (status) { + exit(status); + } + } } /* end main() */ // ====================================================================