|
|
//+-------------------------------------------------------------------------
//
// Microsoft Windows
//
// Copyright (C) Microsoft Corporation, 1997 - 1999
//
// File: drtc.orig.cxx
//
//--------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "drt.h" // header file generated by MIDL compiler
void __cdecl main(int argc, char **argv) { unsigned char * pszString = (unsigned char *)"drt"; WCHAR * pszEntryName = L"/.:/drtsrv_01"; WCHAR * pszGrpEntryName1 = L"/.:/drtgrp_01"; WCHAR * pszPrfEntryName1 = L"/.:/drtprf_01"; WCHAR * pszStrBinding = NULL; RPC_NS_HANDLE hdrt; RPC_BINDING_HANDLE bhdrt; RPC_IF_ID ifid; unsigned long fNameSyntaxType = RPC_C_NS_SYNTAX_DEFAULT; RPC_STATUS status; unsigned long ulCode; short fSuccess = 0; short fContinue = 1; short i; WCHAR *pMemberName; WCHAR *pAnnotation; ULONG dwPriority = 0;
RpcTryExcept { status = RpcNsProfileEltInqBegin( fNameSyntaxType, pszPrfEntryName1, RPC_C_PROFILE_ALL_ELT, NULL, 0, fNameSyntaxType, NULL, &hdrt ); printf(" RpcNsProfileEltInqBegin returned 0x%x\n", status); } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
RpcTryExcept { status = RpcNsProfileEltInqNext( hdrt, &ifid, &pMemberName, &dwPriority, &pAnnotation ); printf("RpcNsProfileEltInqNext returned 0x%x\n", status); if (!status) { wprintf(L"Annotation: %s\n", pAnnotation); wprintf(L"MemberName: %s, Priority %d\n", pMemberName, dwPriority); } } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
RpcTryExcept { status = RpcNsProfileEltInqNext( hdrt, &ifid, &pMemberName, &dwPriority, &pAnnotation ); printf("RpcNsProfileEltInqNext returned 0x%x\n", status); if (!status) { wprintf(L"Annotation: %s\n", pAnnotation); wprintf(L"MemberName: %s, Priority %d\n", pMemberName, dwPriority); } } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
RpcTryExcept { status = RpcNsProfileEltInqDone( &hdrt ); printf("RpcNsProfileEltInqDone returned 0x%x\n", status); } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
RpcTryExcept { status = RpcNsGroupMbrInqBegin( fNameSyntaxType, pszGrpEntryName1, fNameSyntaxType, &hdrt ); printf(" RpcNsGroupMbrInqBegin returned 0x%x\n", status); } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
*pMemberName = '\0'; RpcTryExcept { status = RpcNsGroupMbrInqNext( hdrt, &pMemberName ); printf("RpcNsGroupMbrInqNext returned 0x%x\n", status); if (!status) { wprintf(L"MemberName: %s\n", pMemberName); } } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
RpcTryExcept { status = RpcNsGroupMbrInqDone( &hdrt ); printf("RpcNsGroupMbrInqDone returned 0x%x\n", status); } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
RpcTryExcept { status = RpcNsBindingImportBegin(fNameSyntaxType, pszGrpEntryName1, drtsrv_01_v1_0_c_ifspec, NULL, &hdrt); printf("RpcNsBindingImportBegin returned 0x%x\n", status); } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
if ( status != RPC_S_OK ) fContinue = 0;
/* The loop is present because the name service may contain "stale" */ /* and unusable binding handlers. This is part of the DCE design. */ while( fContinue ) { status = RpcNsBindingImportNext(hdrt, &bhdrt); printf("RpcNsBindingImportNext returned 0x%x\n", status);
if ( (status == RPC_S_NO_MORE_BINDINGS) || (status == RPC_S_NAME_SERVICE_UNAVAILABLE ) ) break;
if (status != RPC_S_OK) continue;
RpcBindingToStringBinding( bhdrt, &pszStrBinding ); printf("StringBinding: %s\n", pszStrBinding ); RpcStringFree(&pszStrBinding);
RpcTryExcept { printf("Calling remote procedure HelloProc with string %s\n", pszString); HelloProc(bhdrt, pszString); fContinue = 0; fSuccess = 1; } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); status = RpcBindingFree(&bhdrt); printf("RpcBindingFree returned 0x%x\n", status); fContinue = 1; } RpcEndExcept
}
RpcTryExcept { status = RpcNsBindingImportDone(&hdrt); printf("RpcNsBindingImportDone returned 0x%x\n", status); } RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC Runtime raised exception 0x%x\n", ulCode); fContinue = 0; } RpcEndExcept
if ( fSuccess ) { RpcTryExcept { Shutdown(bhdrt); // Shutdown is a remote procedure
} RpcExcept(1) { ulCode = RpcExceptionCode(); printf("RPC runtime raised exception 0x%x\n", ulCode); } RpcEndExcept
status = RpcBindingFree(&bhdrt); printf("RpcBindingFree returned 0x%x\n", status); }
exit(0);
} // end main()
/*********************************************************************/ /* MIDL allocate and free */ /*********************************************************************/
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { return(malloc(len)); }
void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { free(ptr); }
/* end file drtc.c */
|