Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

850 lines
22 KiB

4 years ago
  1. /* --------------------------------------------------------------------
  2. Microsoft OS/2 LAN Manager
  3. Copyright(c) Microsoft Corp., 1990
  4. RPC locator - Written by Steven Zeck
  5. This file contains a test driver for the RPC locator.
  6. -------------------------------------------------------------------- */
  7. #include "test.hxx"
  8. CDEF
  9. // #include "mailslot.hxx"
  10. ENDDEF
  11. int debug = -1; // debug trace level
  12. struct {
  13. BYTE command; // command
  14. BYTE szFrom[32]; // who this message is from
  15. BYTE buff[500]; // mailslot buffer
  16. }mail;
  17. // READ_MAIL_SLOT *hMail;
  18. SZ pSelfName = "\\\\stevez1";
  19. SZ szDomainName = "";
  20. enum { // mailslot communication messages
  21. nilMC,
  22. continueMC
  23. }mailCommand;
  24. // an array of test functions
  25. int test0(int, SZ *), test1(int, SZ *), test2(int, SZ *), test3(int, SZ *);
  26. int test4(int, SZ *), test5(int, SZ *);
  27. #ifdef RPC_CXX_20
  28. #define RpcGetch _getch
  29. #else
  30. #define RpcGetch getch
  31. #endif
  32. int (*pFn[])(int, SZ *) = {
  33. test0, test1, test2, test3, test4, test5
  34. };
  35. //char OSdebug, ClearExclusiveSem, CurrentTime, QueryNetProtoStack, RequestExclusiveSem;
  36. //char maxCacheAge, pESaccess, perf, QueryNetQuery, QueryNetQueryServer;
  37. //char MarshallEntryBaseItem, MarshallEntryGroupItem;
  38. //char MarshallEntryServerItem, QueryNetQueryGroup;
  39. //char FlushBufferConsoleStream, FlushBufferDebugStream;
  40. void RaiseAssert() {}
  41. void ReadMail ( // read mail from the slot
  42. // returns values into global mail
  43. ) //-----------------------------------------------------------------------//
  44. {
  45. int cbReturnName;
  46. int status;
  47. #if 0
  48. if (!hMail) {
  49. printf("No mail slot to Read\n");
  50. exit(-1);
  51. }
  52. printf("Waiting for Mail...");
  53. status = hMail->Read((PB)&mail, cbReturnName);
  54. printf("from: %s\n", mail.szFrom);
  55. #endif
  56. }
  57. void WriteMail ( // write mail from the slot
  58. SZ szMachine // machine to write to
  59. // writes values into global mail
  60. ) //-----------------------------------------------------------------------//
  61. {
  62. #if 0
  63. int status;
  64. unsigned short Mstatus;
  65. char szNamet[100];
  66. WRITE_MAIL_SLOT Mail((SZ) strcat(strcpy(szNamet, szMachine), MAILNAME(t)), 0, &Mstatus);
  67. strcpy((char *) mail.szFrom, pSelfName);
  68. printf("Writing Mail to %s\n", szMachine);
  69. status = Mail.Write((PB)&mail, sizeof(mail));
  70. #endif
  71. }
  72. int CreateMulipleBindings(
  73. ) //-----------------------------------------------------------------------//
  74. {
  75. BindingVectorIn->Count = 1;
  76. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  77. (RPC_IF_HANDLE) &SInterface2, BindingVectorIn, 0)) {
  78. printf("RpcNsBindingExport -> %x\n", Status);
  79. return (1);
  80. }
  81. BindingVectorIn->Count = CountAllBindings;
  82. // for (int i=0; i < 8; i++) {
  83. // SInterface1.InterfaceId.SyntaxVersion.MinorVersion++;
  84. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  85. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, 0)) {
  86. printf("RpcNsBindingExport -> %x\n", Status);
  87. return (1);
  88. }
  89. //}
  90. return(0);
  91. }
  92. int test0 ( // stand alone tests
  93. int cArgs,
  94. SZ *paSZargs
  95. ) //-----------------------------------------------------------------------//
  96. {
  97. USED(paSZargs); USED(cArgs);
  98. // Export a single binding. Then look it up to see that it matched.
  99. BindingVectorIn->Count = 1;
  100. ObjectVector->Count = 1;
  101. // ObjectVector->Count = 2;
  102. // ObjectVector->Uuid[1] = &Object1;
  103. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  104. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, 0)) {
  105. printf("RpcNsBindingExport -> %x\n", Status);
  106. return (1);
  107. }
  108. if (ClientLookup(&SInterface1, StringBinding1, 1))
  109. return(1);
  110. // Check for Version major.minor functionality
  111. SInterface1.InterfaceId.SyntaxVersion.MinorVersion--;
  112. if (ClientImport(EntryName1, &SInterface1, 0, StringBinding1, IMPORT_OK))
  113. return(1);
  114. if (ClientImport(0, &SInterface1, 0, StringBinding1, IMPORT_OK))
  115. return(1);
  116. SInterface1.InterfaceId.SyntaxVersion.MinorVersion++;
  117. // Check for lookup with object functinoality.
  118. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  119. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, ObjectVector)) {
  120. printf("RpcNsBindingExport -> %x\n", Status);
  121. return (1);
  122. }
  123. if (ClientImport(EntryName1, 0, &Object1, StringBinding1, IMPORT_OK))
  124. return(1);
  125. if (ClientImport(EntryName1, &SInterface1, &Object1, StringBinding1, IMPORT_OK))
  126. return(1);
  127. if (ClientImport(0, 0, &Object1, StringBinding1, IMPORT_OK))
  128. return(1);
  129. // Check to make sure no bindings are returned when none are expected.
  130. if (ClientImport(EntryName1, &SInterface2, 0, StringBinding1, IMPORT_FAIL_NEXT))
  131. return(1);
  132. if (ClientImport(EntryName2, &SInterface1, 0, StringBinding1, IMPORT_FAIL_BEGIN))
  133. return(1);
  134. if (ClientImport(EntryName1, &SInterface1, &Object2, StringBinding1, IMPORT_FAIL_NEXT))
  135. return(1);
  136. SInterface1.TransferSyntax.SyntaxVersion.MajorVersion++;
  137. if (ClientImport(EntryName1, &SInterface1, 0, StringBinding1, IMPORT_FAIL_NEXT))
  138. return(1);
  139. SInterface1.TransferSyntax.SyntaxVersion.MajorVersion--;
  140. // Add some more objects to the interface.
  141. ObjectVector->Count = 2;
  142. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  143. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, ObjectVector)) {
  144. printf("RpcNsBindingExport -> %x\n", Status);
  145. return (1);
  146. }
  147. // See if the second object is there.
  148. if (ClientImport(EntryName1, &SInterface1, &Object2, StringBinding1, IMPORT_OK))
  149. return(1);
  150. // Now remove the first object.
  151. ObjectVector->Count = 1;
  152. if (Status = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  153. 0, ObjectVector)) {
  154. printf("RpcNsBindingUnexport -> %x\n", Status);
  155. return (1);
  156. }
  157. // The first object should be gone.
  158. if (ClientImport(EntryName1, &SInterface1, &Object1, StringBinding1, IMPORT_FAIL_NEXT))
  159. return(1);
  160. if (ClientImport(EntryName1, &SInterface1, &Object2, StringBinding1, IMPORT_OK))
  161. return(1);
  162. // Remove the first interface. Then make sure it is gone.
  163. if (Status = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  164. (RPC_IF_HANDLE) &SInterface1, 0)) {
  165. printf("RpcNsBindingUnexport -> %x\n", Status);
  166. return (1);
  167. }
  168. if (ClientImport(EntryName1, &SInterface1, 0, StringBinding1, IMPORT_FAIL_BEGIN ))
  169. return(1);
  170. // Create more then one interface. Call Lookup so
  171. // that a lookup handle must be allocated.
  172. if (CreateMulipleBindings())
  173. return(1);
  174. if (MatchMultiple(&SInterface1, BindingVectorIn))
  175. return(1);
  176. if (Status = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  177. (RPC_IF_HANDLE) &SInterface1, 0)) {
  178. printf("RpcNsBindingUnexport -> %x\n", Status);
  179. return (1);
  180. }
  181. if (Status = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  182. (RPC_IF_HANDLE) &SInterface2, 0)) {
  183. printf("RpcNsBindingUnexport -> %x\n", Status);
  184. return (1);
  185. }
  186. return(0);
  187. }
  188. int test1 ( // Test the managment APIs
  189. int cArgs,
  190. SZ *paSZargs
  191. //
  192. ) //-----------------------------------------------------------------------//
  193. {
  194. USED(paSZargs); USED(cArgs);
  195. unsigned long ExpirationAge, ExpirationAgeSecond;
  196. RPC_IF_ID_VECTOR *IfVector;
  197. RPC_NS_HANDLE ObjectContext;
  198. UUID ObjUuid;
  199. BindingVectorIn->Count = 1;
  200. ObjectVector->Count = 1;
  201. // Get and set the global expiration age.
  202. if (Status = RpcNsMgmtInqExpAge(&ExpirationAge)) {
  203. printf("RpcNsMgmtInqExpAge -> %x\n", Status);
  204. return (1);
  205. }
  206. ExpirationAge += 10;
  207. if (Status = RpcNsMgmtSetExpAge(ExpirationAge)) {
  208. printf("RpcNsMgmtSetExpAge -> %x\n", Status);
  209. return (1);
  210. }
  211. if (Status = RpcNsMgmtInqExpAge(&ExpirationAgeSecond)) {
  212. printf("RpcNsMgmtInqExpAge -> %x\n", Status);
  213. return (1);
  214. }
  215. if (ExpirationAge != ExpirationAgeSecond) {
  216. printf("Set ExpAge: %ld == %ld\n", ExpirationAge, ExpirationAgeSecond);
  217. return(1);
  218. }
  219. //----
  220. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  221. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, ObjectVector)) {
  222. printf("RpcNsBindingExport -> %x\n", Status);
  223. return (1);
  224. }
  225. // Get the interfaces assoicated with an entry.
  226. if (Status = RpcNsMgmtEntryInqIfIds(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  227. &IfVector)) {
  228. printf("RpcNsMgmtEntryInqIfIds -> %x\n", Status);
  229. return (1);
  230. }
  231. if (IfVector->Count != 1) {
  232. printf("Bad Vector count %d != 1", IfVector->Count);
  233. return (1);
  234. }
  235. if (memcmp(&SInterface1.InterfaceId, IfVector->IfId[0],
  236. sizeof(RPC_IF_ID)) != 0) {
  237. printf("Inteface mismatch from RpcNsMgmtEntryInqIfIds\n");
  238. return (1);
  239. }
  240. if (Status = RpcIfIdVectorFree(&IfVector)) {
  241. printf("RpcIfIdVectorFree -> %x\n", Status);
  242. return (1);
  243. }
  244. // Remove the interface with managment routine.
  245. SInterface1.InterfaceId.SyntaxVersion.MajorVersion++;
  246. if (Status = RpcNsMgmtBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  247. (RPC_IF_ID*) &SInterface1.InterfaceId, RPC_C_VERS_ALL, 0)) {
  248. printf("RpcNsMgmtBindingUnexport -> %x\n", Status);
  249. return (1);
  250. }
  251. SInterface2.InterfaceId.SyntaxVersion.MajorVersion--;
  252. if (ClientImport(EntryName1, &SInterface1, 0, StringBinding1, IMPORT_FAIL_BEGIN))
  253. return(1);
  254. // ----
  255. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  256. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, ObjectVector)) {
  257. printf("RpcNsBindingExport -> %x\n", Status);
  258. return (1);
  259. }
  260. // Now, get the object when the EntryObject API.
  261. if (Status = RpcNsEntryObjectInqBegin(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  262. &ObjectContext)) {
  263. printf("RpcNsEntryObjectInqBegin -> %x\n", Status);
  264. return (1);
  265. }
  266. if (Status = RpcNsEntryObjectInqNext(ObjectContext, &ObjUuid)) {
  267. printf("RpcNsEntryObjectInqNext -> %x\n", Status);
  268. return (1);
  269. }
  270. if (memcmp(&Object1, &ObjUuid, sizeof(UUID)) != 0) {
  271. printf("Object mismatch from RpcNsEntryObjectInqNext\n");
  272. return (1);
  273. }
  274. if ((Status = RpcNsEntryObjectInqNext(ObjectContext, &ObjUuid)) !=
  275. RPC_S_NO_MORE_MEMBERS) {
  276. printf("RpcNsEntryObjectInqNext didn't return RPC_S_NO_MORE_MEMBERS -> %x\n", Status);
  277. return (1);
  278. }
  279. if (Status = RpcNsEntryObjectInqDone(&ObjectContext)) {
  280. printf("RpcNsEntryObjectInqDone -> %x\n", Status);
  281. return (1);
  282. }
  283. // Remove the entry with managment a routine.
  284. if (Status = RpcNsMgmtEntryDelete(RPC_C_NS_SYNTAX_DEFAULT, EntryName1)) {
  285. printf("RpcNsMgmtEntryDelete -> %x\n", Status);
  286. return (1);
  287. }
  288. if (ClientImport(EntryName1, &SInterface1, 0, StringBinding1, IMPORT_FAIL_BEGIN))
  289. return(1);
  290. return(0);
  291. }
  292. int test2 ( // Test for group APIs
  293. int cArgs,
  294. SZ *paSZargs
  295. //
  296. ) //-----------------------------------------------------------------------//
  297. {
  298. USED(paSZargs); USED(cArgs);
  299. RPC_NS_HANDLE InquiryContext;
  300. unsigned char *Member1;
  301. BindingVectorIn->Count = 1;
  302. ObjectVector->Count = 1;
  303. // ----
  304. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  305. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, ObjectVector)) {
  306. printf("RpcNsBindingExport -> %x\n", Status);
  307. return (1);
  308. }
  309. // Add a group reference to entry1 and see if you can find it.
  310. if (Status = RpcNsGroupMbrAdd(RPC_C_NS_SYNTAX_DEFAULT, GroupName1,
  311. RPC_C_NS_SYNTAX_DEFAULT, EntryName1)) {
  312. printf("RpcNsGroupMbrAdd -> %x\n", Status);
  313. return (1);
  314. }
  315. if (ClientImport(GroupName1, &SInterface1, &Object1, StringBinding1, IMPORT_OK))
  316. return(1);
  317. // Now enumerate the members in the group.
  318. if (Status = RpcNsGroupMbrInqBegin(RPC_C_NS_SYNTAX_DEFAULT, GroupName1,
  319. RPC_C_NS_SYNTAX_DEFAULT, &InquiryContext)) {
  320. printf("RpcNsGroupMbrInqBegin -> %x\n", Status);
  321. return (1);
  322. }
  323. if (Status = RpcNsGroupMbrInqNext(InquiryContext, &Member1)) {
  324. printf("RpcNsGroupMbrInqNext -> %x\n", Status);
  325. return (1);
  326. }
  327. if (strcmp((CONST_CHAR *)Member1, (CONST_CHAR *)EntryName1) != 0) {
  328. printf("GroupInqNext: %s != %s\n", Member1, EntryName1);
  329. return(1);
  330. }
  331. if (Status = RpcStringFree(&Member1)) {
  332. printf("RpcFreeString -> %x\n", Status);
  333. return (1);
  334. }
  335. if ((Status = RpcNsGroupMbrInqNext(InquiryContext, &Member1))
  336. != RPC_S_NO_MORE_MEMBERS) {
  337. printf("RpcNsGroupMbrInqNext didn't return NSI_S_NO_MORE_MEMBERS -> %x\n", Status);
  338. return (1);
  339. }
  340. if (Status = RpcNsGroupMbrInqDone(&InquiryContext)) {
  341. printf("RpcNsGroupMbrInqDone -> %x\n", Status);
  342. return (1);
  343. }
  344. // Add a second element and then remove the first element.
  345. if (Status = RpcNsGroupMbrAdd(RPC_C_NS_SYNTAX_DEFAULT, GroupName1,
  346. RPC_C_NS_SYNTAX_DEFAULT, EntryName2)) {
  347. printf("RpcNsGroupMbrAdd -> %x\n", Status);
  348. return (1);
  349. }
  350. if ((Status = RpcNsGroupMbrRemove(RPC_C_NS_SYNTAX_DEFAULT, GroupName1,
  351. RPC_C_NS_SYNTAX_DEFAULT, EntryName1))) {
  352. printf("RpcNsGroupMbrRemove -> %x\n", Status);
  353. return (1);
  354. }
  355. // First group member gone, this should fail.
  356. if (ClientImport(GroupName1, &SInterface1, &Object1, StringBinding1, IMPORT_FAIL_NEXT))
  357. return(1);
  358. // Finally remove the whole group.
  359. if ((Status = RpcNsGroupDelete(RPC_C_NS_SYNTAX_DEFAULT, GroupName1))) {
  360. printf("RpcNsGroupDelete -> %x\n", Status);
  361. return (1);
  362. }
  363. if (Status = RpcNsGroupMbrInqBegin(RPC_C_NS_SYNTAX_DEFAULT, GroupName1,
  364. RPC_C_NS_SYNTAX_DEFAULT, &InquiryContext) != RPC_S_ENTRY_NOT_FOUND) {
  365. printf("RpcNsGroupMbrInqBegin didn't return RPC_S_ENTRY_NOT_FOUND -> %x\n", Status);
  366. return (1);
  367. }
  368. if (Status = RpcNsMgmtEntryDelete(RPC_C_NS_SYNTAX_DEFAULT, EntryName1)) {
  369. printf("RpcNsMgmtEntryDelete -> %x\n", Status);
  370. return (1);
  371. }
  372. return(0);
  373. }
  374. int test3 ( // Test for unimplemented APIs
  375. int cArgs,
  376. SZ *paSZargs
  377. //
  378. ) //-----------------------------------------------------------------------//
  379. {
  380. USED(paSZargs); USED(cArgs);
  381. unsigned char *ExpandedName;
  382. RPC_NS_HANDLE InquiryContext;
  383. if ((Status = RpcNsEntryExpandName(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  384. &ExpandedName)) != RPC_S_CANNOT_SUPPORT) {
  385. printf("RpcNsEntryExpandName didn't return RPC_S_CANNOT_SUPPORT-> %x\n", Status);
  386. return (1);
  387. }
  388. if ((Status = RpcNsMgmtEntryCreate(RPC_C_NS_SYNTAX_DEFAULT, EntryName1))
  389. != RPC_S_CANNOT_SUPPORT) {
  390. printf("RpcNsMgmEntryCreate didn't return RPC_S_CANNOT_SUPPORT-> %x\n", Status);
  391. return (1);
  392. }
  393. if ((Status = RpcNsProfileDelete(RPC_C_NS_SYNTAX_DEFAULT, EntryName1))
  394. != RPC_S_CANNOT_SUPPORT) {
  395. printf("RpcNsProfileDelete didn't return RPC_S_CANNOT_SUPPORT-> %x\n", Status);
  396. return (1);
  397. }
  398. if ((Status = RpcNsProfileEltAdd(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  399. 0, RPC_C_NS_SYNTAX_DEFAULT, EntryName2, 1, EntryName2))
  400. != RPC_S_CANNOT_SUPPORT) {
  401. printf("RpcNsProfileEltAdd didn't return RPC_S_CANNOT_SUPPORT-> %x\n", Status);
  402. return (1);
  403. }
  404. if ((Status = RpcNsProfileEltRemove(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  405. 0, RPC_C_NS_SYNTAX_DEFAULT, EntryName2)) != RPC_S_CANNOT_SUPPORT) {
  406. printf("RpcNsProfileEltRemoveA didn't return RPC_S_CANNOT_SUPPORT-> %x\n", Status);
  407. return (1);
  408. }
  409. if ((Status = RpcNsProfileEltInqBegin(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  410. RPC_C_PROFILE_DEFAULT_ELT, 0, RPC_C_VERS_ALL, RPC_C_NS_SYNTAX_DEFAULT,
  411. EntryName2, &InquiryContext))
  412. != RPC_S_CANNOT_SUPPORT) {
  413. printf("RpcNsProfileEltInqBeginA didn't return RPC_S_CANNOT_SUPPORT-> %x\n", Status);
  414. return (1);
  415. }
  416. // No tests for ProfileEltInq Next & Done because lack of context handle
  417. return(0);
  418. }
  419. int test4 ( // enter a single stack and wait
  420. int cArgs,
  421. SZ *paSZargs
  422. // This is used in a multi machine test. This part exports a multiple
  423. // stacks and waits for a message or key stroke to finish.
  424. ) //-----------------------------------------------------------------------//
  425. {
  426. USED(paSZargs); USED(cArgs);
  427. if (CreateMulipleBindings())
  428. return(1);
  429. printf("Press enter to finish...");
  430. RpcGetch();
  431. if (Status = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  432. (RPC_IF_HANDLE) &SInterface1, 0)) {
  433. printf("RpcNsBindingUnexport -> %x\n", Status);
  434. return (1);
  435. }
  436. if (Status = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  437. (RPC_IF_HANDLE) &SInterface2, 0)) {
  438. printf("RpcNsBindingUnexport -> %x\n", Status);
  439. return (1);
  440. }
  441. return(0);
  442. }
  443. int test5 ( // enter a single stack and wait
  444. int cArgs,
  445. SZ *paSZargs
  446. // This is used in a multi machine test. This part exports a single
  447. // stack and waits for a message or key stroke to finish.
  448. ) //-----------------------------------------------------------------------//
  449. {
  450. RPC_NS_HANDLE LookupContext;
  451. if (!cArgs) {
  452. printf("usage: 5 client | server");
  453. return(-1);
  454. }
  455. if (strcmp(*paSZargs, "server") == 0) {
  456. BindingVectorIn->Count = 1;
  457. ObjectVector->Count = 1;
  458. if (Status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, EntryName1,
  459. (RPC_IF_HANDLE) &SInterface1, BindingVectorIn, ObjectVector)) {
  460. printf("RpcNsBindingExport -> %x\n", Status);
  461. return (1);
  462. }
  463. // Add a group reference to entry1 and see if you can find it.
  464. if (Status = RpcNsGroupMbrAdd(RPC_C_NS_SYNTAX_DEFAULT, GroupName1,
  465. RPC_C_NS_SYNTAX_DEFAULT, EntryName1)) {
  466. printf("RpcNsGroupMbrAdd -> %x\n", Status);
  467. return (1);
  468. }
  469. printf("Press enter to finish...");
  470. RpcGetch();
  471. // Now remove the group and entry.
  472. if (Status = RpcNsMgmtEntryDelete(RPC_C_NS_SYNTAX_DEFAULT, EntryName1)) {
  473. printf("RpcNsMgmtEntryDelete -> %x\n", Status);
  474. return (1);
  475. }
  476. if (Status = RpcNsMgmtEntryDelete(RPC_C_NS_SYNTAX_DEFAULT, GroupName1)) {
  477. printf("RpcNsMgmtEntryDelete -> %x\n", Status);
  478. return (1);
  479. }
  480. return(0);
  481. }
  482. if (strcmp(*paSZargs, "client") != 0) {
  483. printf("usage: 5 client | server");
  484. return(-1);
  485. }
  486. // Case 1: verify that the stack is found
  487. if (ClientImport(GroupName1, &SInterface1, &Object1, StringBinding1, IMPORT_OK))
  488. return(1);
  489. // Case 2: send a message to other machine to terminate, thus withdrawing
  490. // the stack. Then lookup again to verify its still in cache.
  491. printf("Press enter on the server...");
  492. RpcGetch();
  493. if (ClientImport(EntryName1, &SInterface1, &Object1, StringBinding1, IMPORT_OK))
  494. return(1);
  495. // Case 3: lookup again requesting that the cache be refreshed. Since
  496. // the exported stack is gone, should return failure.
  497. Status = RpcNsBindingLookupBegin(0, 0,
  498. (RPC_IF_HANDLE) &SInterface1, 0, BindingVectorMax, &LookupContext);
  499. if (Status = RpcNsMgmtHandleSetExpAge (LookupContext, 0)) {
  500. printf("RpcNsMgmtHandleSetExpAge -> %x\n", Status);
  501. return (1);
  502. }
  503. Status = RpcNsBindingLookupNext(LookupContext, &BindingVectorOut);
  504. if (Status != RPC_S_NO_MORE_BINDINGS) {
  505. printf("RpcNsBindingLookupBegin didn't return RPC_S_NO_MORE_BINDINGS -> %x\n",
  506. Status);
  507. return (2);
  508. }
  509. return(0);
  510. }
  511. int main ( // entry point for the test program
  512. int cArgs,
  513. SZ *paSZargs
  514. ) //-----------------------------------------------------------------------//
  515. {
  516. int testNum = 0;
  517. int result = 0;
  518. unsigned short status;
  519. #if 0
  520. hMail = new READ_MAIL_SLOT(MAILNAME(t), sizeof(mail), &status);
  521. #endif
  522. CreateBindingHandles();
  523. #ifndef NTENV
  524. static BYTE wiBuff[sizeof(wksta_info_0) + 200];
  525. struct wksta_info_0 *pWI = (struct wksta_info_0 *) wiBuff;
  526. unsigned short cbT, cbWI = sizeof(wiBuff);
  527. if (!NetWkstaGetInfo(0, 0, (PB) pWI, cbWI, &cbT))
  528. pSelfName = pWI->wki0_computername;
  529. #endif // NTENV
  530. printf("Microsoft RPC Locator test program.\n");
  531. cArgs--; paSZargs++;
  532. if (cArgs && strcmp("-debug", *paSZargs) == 0) {
  533. debug = 10;
  534. cArgs--; paSZargs++;
  535. }
  536. if (cArgs && strcmp("-?", *paSZargs) == 0) {
  537. printf("Usage: test [-debug] digit [arguments]\n");
  538. printf(" test 0 -- stand alone binding object tests\n");
  539. printf(" test 1 Test the management APIs\n");
  540. printf(" test 2 Test for group APIs\n");
  541. printf(" test 3 Test for unimplemented APIs\n");
  542. printf(" test 4 Used to with client only test\n");
  543. printf(" test 5 client | server\n");
  544. exit(-1);
  545. }
  546. #ifndef MIPS
  547. RpcTryExcept
  548. #endif
  549. {
  550. if (cArgs) {
  551. testNum = atoi(*paSZargs);
  552. cArgs--; paSZargs++;
  553. result = (pFn[testNum])(cArgs, paSZargs);
  554. }
  555. else {
  556. result |= test0(cArgs, paSZargs);
  557. result |= test1(cArgs, paSZargs);
  558. result |= test2(cArgs, paSZargs);
  559. result |= test3(cArgs, paSZargs);
  560. }
  561. }
  562. #ifndef MIPS
  563. RpcExcept(1)
  564. {
  565. printf("FAILED: exception: %x\n", RpcExceptionCode());
  566. exit(1);
  567. }
  568. RpcEndExcept
  569. #endif
  570. if (result) {
  571. printf("Fail status: %x\n", result);
  572. printf("Locator BVT: FAILED\n");
  573. }
  574. else
  575. printf("Locator BVT: PASSED\n");
  576. return(result);
  577. }