--- mstools/samples/rpc/dict/server.c 2018/08/09 18:20:01 1.1 +++ mstools/samples/rpc/dict/server.c 2018/08/09 18:22:07 1.1.1.3 @@ -2,7 +2,7 @@ /** **/ /** Microsoft RPC Examples **/ /** Dictionary Application **/ -/** Copyright(c) Microsoft Corp. 1991 **/ +/** Copyright(c) Microsoft Corp. 1992 **/ /** **/ /*************************************************************/ @@ -36,20 +36,23 @@ ************************************************************************* */ +#define INCL_DOS + #include #include #include #include #include -#include #include + #include "dict0.h" #include "replay.h" #include "util0.h" -// char *server = "\\pipe\\rpc\\replay"; -void exit(int); +#ifdef AUTOHANDLE +#include "nsi.h" +#endif void Usage() { @@ -57,14 +60,15 @@ void Usage() exit(1); } -void +void _CRTAPI1 main(int argc, char *argv[]) { int argscan; - char * InterfaceAddress = NULL; - RPC_HANDLE Server, Address, Interface; + 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++) { @@ -83,62 +87,36 @@ main(int argc, char *argv[]) else Usage(); } - if (InterfaceAddress == NULL) -#ifndef OLDOS - InterfaceAddress = "\\device\\namedpipe\\dict"; -#else // OLDOS - InterfaceAddress = "\\pipe\\dict"; -#endif // OLDOS - - status = RpcCreateServer((RPC_EVENT_HANDLERS *) 0, &Server); - printf ("server created\n"); - if (status) - { - printf("RpcCreateServer = %lu\n",status); - exit(2); - } - /* Initialize required protocol stack fields */ - dict_ProtocolStack.StackType = RPC_STACK_TYPE_V1; - dict_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE; - dict_ProtocolStack.TransportInfo = InterfaceAddress; - dict_ProtocolStack.TransportInfoLength = strlen(InterfaceAddress)+1; - - status = RpcAddAddress( - Server, - &dict_ProtocolStack, - 0, // Do not prevent deadlock... - &Address, - (void *)0, // Reserved for security information... - RpcNormalResourceUsage, - 0L // No timeout... - ); + if (status = RpcServerRegisterIf(dict_ServerIfHandle, 0, 0)) + { + printf("Error in RpcServerRegisterIf: %x", status); + return; + } - printf ("server address added\n"); + if (status = RpcServerUseProtseqEp((unsigned char *) "ncacn_np", 1, + InterfaceAddress, 0)) + { + printf("Error in RpcServerUseProtseqEp: %x", status); + return; + } - if (status) - { - printf("RpcAddAddress = %lu\n",status); - exit(2); - } - status = RpcAddInterface( - Server, - &dict_ProtocolStack, - &Interface, - (void *)0, // Reserved for security information... - &dict_DispatchTable - ); +#ifdef AUTOHANDLE - printf ("server interface added\n"); + if (status = RpcServerInqBindings(&RpcBindingVector)) + { + printf("Error in RpcServerInqBindings: %x", status); + return; + } - if (status) - { - printf("RpcAddInterface = %lu\n",status); - exit(2); - } + if (status = RpcNsiBindExport(0, 0, dict_ServerIfHandle, + RpcBindingVector, 0)) + { + printf("Error in RpcNsiBindExport: %x", status); + return; + } /* - status = RpcExport(Server, 1, &dict_ProtocolStack); printf ("server exported\n"); * The above is required for advertising that the server is serving @@ -148,19 +126,15 @@ main(int argc, char *argv[]) */ - if (status) - { - printf("RpcExport = %lu\n",status); - exit(2); - } +#endif - while (1) - { -#ifndef OLDOS - Sleep(5000L); -#else // OLDOS - DosSleep(5000L); -#endif // OLDOS - } + printf ("Server Entering Listen Mode...\n"); + + if (status = RpcServerListen(1, 10, 0)) + { + printf("Error in RpcServerListen: %x", status); + return; + } + }