--- mstools/samples/rpc/dict/server.c 2018/08/09 18:22:07 1.1.1.3 +++ mstools/samples/rpc/dict/server.c 2018/08/09 18:24:22 1.1.1.4 @@ -8,11 +8,8 @@ /* ************************************************************************* - * Remote dictionary example: server side * * * - * Created: Dov Harel 12/??/1990 * - * Modified to use context_handle Donna Liu 3/??/1991 * - * Further modifications / documentation Dov Harel 5/1/1991 * + * Remote dictionary example: server side * * * * Description: * * This is the driver for the server side remote dictionary * @@ -36,105 +33,76 @@ ************************************************************************* */ -#define INCL_DOS - -#include -#include #include -#include +#include #include -#include - +#include "replay.h" // header file generated by MIDL compiler #include "dict0.h" -#include "replay.h" #include "util0.h" -#ifdef AUTOHANDLE -#include "nsi.h" -#endif void Usage() { - printf("Usage : server -a
\n"); + printf("Usage : server -e \n"); exit(1); } void _CRTAPI1 main(int argc, char *argv[]) { - int argscan; - unsigned char * InterfaceAddress = "\\pipe\\dict"; - RPC_STATUS status; - RPC_BINDING_VECTOR * RpcBindingVector; - - printf ("Microsoft RPC demo Server - Splay (Binary) Tree DataBase\n"); - - for (argscan = 1; argscan < argc; argscan++) - { - if (argv[argscan][0] == '-') - { - switch (argv[argscan][1]) - { - case 'a': - case 'A': - InterfaceAddress = &(argv[argscan][2]); + RPC_STATUS status; + unsigned char * pszProtocolSequence = "ncacn_np"; + unsigned char * pszSecurity = NULL; + unsigned char * pszEndpoint = "\\pipe\\dict"; + unsigned int cMinCalls = 1; + unsigned int cMaxCalls = 20; + unsigned int fDontWait = FALSE; + int i; + + printf ("Microsoft RPC demo Server - Splay (Binary) Tree DataBase\n"); + + /* 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 'e': + pszEndpoint = argv[++i]; break; - default: + case 'h': + case '?': + default: Usage(); } } - else - Usage(); + else + Usage(); } - if (status = RpcServerRegisterIf(dict_ServerIfHandle, 0, 0)) - { - printf("Error in RpcServerRegisterIf: %x", status); - return; - } - - if (status = RpcServerUseProtseqEp((unsigned char *) "ncacn_np", 1, - InterfaceAddress, 0)) - { - printf("Error in RpcServerUseProtseqEp: %x", status); - return; - } - -#ifdef AUTOHANDLE - - if (status = RpcServerInqBindings(&RpcBindingVector)) - { - printf("Error in RpcServerInqBindings: %x", status); - return; - } - - if (status = RpcNsiBindExport(0, 0, dict_ServerIfHandle, - RpcBindingVector, 0)) - { - printf("Error in RpcNsiBindExport: %x", status); - return; - } - -/* - printf ("server exported\n"); - - * The above is required for advertising that the server is serving - * a particular interface (using a locator or alternatively a - * directory service / name service). Strictly equired for clients - * using auto_handle. - -*/ - -#endif - + status = RpcServerUseProtseqEp(pszProtocolSequence, + cMaxCalls, + pszEndpoint, + pszSecurity); // Security descriptor + if (status) { + printf("RpcServerUseProtseqEp returned 0x%x\n", status); + exit(status); + } - printf ("Server Entering Listen Mode...\n"); + status = RpcServerRegisterIf(dict_ServerIfHandle, // interface to register + NULL, // MgrTypeUuid + NULL); // MgrEpv; null means use default + if (status) { + printf("RpcServerRegisterIf returned 0x%x\n", status); + exit(status); + } - if (status = RpcServerListen(1, 10, 0)) - { - printf("Error in RpcServerListen: %x", status); - return; - } + printf("Calling RpcServerListen\n"); + status = RpcServerListen(cMinCalls, + cMaxCalls, + fDontWait); + if (status) { + printf("RpcServerListen returned: 0x%x\n", status); + exit(status); + } }