--- mstools/samples/rpc/handles/auto/autos.c 2018/08/09 18:22:05 1.1.1.2 +++ mstools/samples/rpc/handles/auto/autos.c 2018/08/09 18:24:19 1.1.1.3 @@ -1,20 +1,34 @@ /**************************************************************************** - Microsoft RPC Version 1.0 - Copyright Microsoft Corp. 1992 - Auto Example - - FILE: autos.c - USAGE: autos - PURPOSE: Server side of RPC distributed application Auto + Microsoft RPC Version 1.0 + Copyright Microsoft Corp. 1992 + Auto Example + + FILE: autos.c + + USAGE: autos -p protocol_sequence + -e endpoint + -m maxcalls + -n mincalls + -f flag for RpcServerListen wait + -a auto_sample_nsi_entry_name + -t name_syntax_type + + PURPOSE: Server side of RPC distributed application Auto + FUNCTIONS: main() - registers server as RPC server - COMMENTS: Server side of auto handle example program. + + COMMENTS: This distributed application (time stamp) is implemented + using an auto handle. The server side of the application + must export its binding information and make it available + to the clients. The auto handle requires a location + service running on a server that is accessible to the client. ****************************************************************************/ + #include -#include #include -#include // RPC data structures and APIs -#include "auto.h" // header file generated by MIDL compiler +#include +#include "auto.h" // header file generated by MIDL compiler void Usage(char * pszProgramName) { @@ -24,7 +38,6 @@ void Usage(char * pszProgramName) 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); @@ -35,119 +48,117 @@ 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 * 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; + 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 + /* allow the user to override settings with command line switches */ for (i = 1; i < argc; i++) { - if ((*argv[i] == '-') || (*argv[i] == '/')) { - switch (tolower(*(argv[i]+1))) { - case 'p': // protocol sequence - pszProtocolSequence = argv[++i]; - break; - 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: - Usage(argv[0]); - } - } - else - Usage(argv[0]); + if ((*argv[i] == '-') || (*argv[i] == '/')) { + switch (tolower(*(argv[i]+1))) { + case 'p': // protocol sequence + pszProtocolSequence = argv[++i]; + break; + 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 'a': + pszAutoEntryName = argv[++i]; + break; + case 't': + fNameSyntaxType = (unsigned int) atoi(argv[++i]); + break; + case 'h': + case '?': + default: + Usage(argv[0]); + } + } + else + Usage(argv[0]); } status = RpcServerUseProtseqEp(pszProtocolSequence, - cMaxCalls, // max concurrent calls + cMaxCalls, pszEndpoint, - pszSecurity); // Security descriptor + pszSecurity); // Security descriptor printf("RpcServerUseProtseqEp returned 0x%x\n", status); if (status) { - exit(status); + exit(status); } - status = RpcServerRegisterIf( - autoh_ServerIfHandle, // interface to register - NULL, // MgrTypeUuid - NULL); // MgrEpv; null means use default + 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(status); + exit(status); } status = RpcServerInqBindings(&pBindingVector); printf("RpcServerInqBindings returned 0x%x\n", status); if (status) { - exit(status); + exit(status); } - status = RpcNsBindingExport(fNameSyntaxType, /* name syntax type */ - pszAutoEntryName, /* nsi entry name */ - autoh_ServerIfHandle, - pBindingVector, /* set in previous call */ - NULL); /* UUID vector */ + status = RpcNsBindingExport(fNameSyntaxType, // name syntax type + pszAutoEntryName, // nsi entry name + autoh_ServerIfHandle, + pBindingVector, // set in previous call + NULL); // UUID vector printf("RpcNsBindingExport returned 0x%x\n", status); if (status) { - exit(status); + exit(status); } + printf("Calling RpcServerListen\n"); status = RpcServerListen(cMinCalls, - cMaxCalls, - fDontWait); /* wait flag */ + cMaxCalls, + fDontWait); // wait flag printf("RpcServerListen returned: 0x%x\n", status); if (status) { - exit(status); + exit(status); } if (fDontWait) { - printf("Calling RpcMgmtWaitServerListen\n"); - status = RpcMgmtWaitServerListen(); // wait operation - printf("RpcMgmtWaitServerListen returned: 0x%x\n", status); - if (status) { - exit(status); - } + printf("Calling RpcMgmtWaitServerListen\n"); + status = RpcMgmtWaitServerListen(); // wait operation + printf("RpcMgmtWaitServerListen returned: 0x%x\n", status); + if (status) { + exit(status); + } } -} /* end main() */ -// ==================================================================== -// MIDL allocate and free -// ==================================================================== +} // end main() + +/*********************************************************************/ +/* MIDL allocate and free */ +/*********************************************************************/ -void * MIDL_user_allocate(size_t len) +void __RPC_FAR * __RPC_API midl_user_allocate(size_t len) { return(malloc(len)); } -void MIDL_user_free(void * ptr) +void __RPC_API midl_user_free(void __RPC_FAR * ptr) { free(ptr); } -/* end autos.c */ +/* end file autos.c */