--- mstools/samples/rpc/data/xmit/xmits.c 2018/08/09 18:22:10 1.1.1.2 +++ mstools/samples/rpc/data/xmit/xmits.c 2018/08/09 18:24:26 1.1.1.3 @@ -1,45 +1,45 @@ /**************************************************************************** - Microsoft RPC Version 1.0 - Copyright Microsoft Corp. 1992 - xmit Example - - FILE: xmits.c - USAGE: xmits -p protocol_sequence - -e endpoint - -m max calls - -n min calls - -s security descriptor - -f flag for RpcServerListen - - PURPOSE: Server side of RPC distributed application xmit - FUNCTIONS: main() - registers server as RPC server - - COMMENTS: This sample program generates a linked list to - demonstrate how the list can be transmitted over - the network more efficiently as a sized array. - The pointers are rebuilt on the server side. - - The [transmit_as] attribute (used in the typedef of - DOUBLE_LINK_TYPE in the file XMIT.IDL) requires the - four user-supplied functions whose names start with - the name of the presented type, DOUBLE_LINK_TYPE. - - The [in, out] attributes applied to remote procedure - parameters require the two user-supplied functions - MIDL_user_allocate and MIDL_user_free. + Microsoft RPC Version 1.0 + Copyright Microsoft Corp. 1992 + xmit Example + + FILE: xmits.c + + USAGE: xmits -p protocol_sequence + -e endpoint + -m max calls + -n min calls + -f flag for RpcServerListen + + PURPOSE: Server side of RPC distributed application xmit + + FUNCTIONS: main() - registers server as RPC server + + COMMENTS: This sample program generates a linked list to + demonstrate how the list can be transmitted over + the network more efficiently as a sized array. + The pointers are rebuilt on the server side. + + The [transmit_as] attribute (used in the typedef of + DOUBLE_LINK_TYPE in the file XMIT.IDL) requires the + four user-supplied functions whose names start with + the name of the presented type, DOUBLE_LINK_TYPE. + + The [in, out] attributes applied to remote procedure + parameters require the two user-supplied functions + midl_user_allocate and midl_user_free. + + The other functions are utilities that are used to + build or display the data structures. - The other functions are utilities that are used to - build or display the data structures. ****************************************************************************/ + #include -#include -#include #include #include -#include // RPC data structures and APIs -#include "xmit.h" // header file generated by MIDL compiler +#include "xmit.h" // header file generated by MIDL compiler +#include "xmitu.h" // Function prototypes for utility functions -#include "xmitu.h" // Function prototypes for utility functions #define PURPOSE \ "This Microsoft RPC Version 1.0 sample program demonstrates\n\ the use of the [transmit_as] attribute. For more information\n\ @@ -55,7 +55,6 @@ void Usage(char * pszProgramName) fprintf(stderr, " -m maxcalls\n"); fprintf(stderr, " -n mincalls\n"); fprintf(stderr, " -f flag_wait_op\n"); - fprintf(stderr, " -s security_descriptor\n"); exit(1); } @@ -64,95 +63,77 @@ void _CRTAPI1 main(int argc, char * argv { RPC_STATUS status; unsigned char * pszProtocolSequence = "ncacn_np"; - unsigned char * pszSecurity = NULL; - unsigned char * pszEndpoint = "\\pipe\\xmit"; - unsigned int cMinCalls = 1; - unsigned int cMaxCalls = 20; - unsigned int fDontWait = FALSE; + unsigned char * pszSecurity = NULL; + unsigned char * pszEndpoint = "\\pipe\\xmit"; + unsigned int cMinCalls = 1; + unsigned int cMaxCalls = 20; + unsigned int fDontWait = FALSE; 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 '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 '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( - xmit_ServerIfHandle, // interface to register - NULL, // MgrTypeUuid - NULL); // MgrEpv; null means use default + status = RpcServerRegisterIf(xmit_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); } printf("Calling RpcServerListen\n"); status = RpcServerListen(cMinCalls, - cMaxCalls, - fDontWait); + cMaxCalls, + fDontWait); 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 -// ==================================================================== - -void * MIDL_user_allocate(size_t len) -{ - return(malloc(len)); -} - -void MIDL_user_free(void * ptr) -{ - free(ptr); -} +} // end main() -/* end xmits.c */ +/* end file xmits.c */