Source code of Windows XP (NT5)
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.

98 lines
2.2 KiB

  1. #include <precomp.h>
  2. #include "ErrCtrl.h"
  3. #include "wzcutil.h"
  4. #include "cmde.h"
  5. #include "cmdq.h"
  6. #include "cmds.h"
  7. #include "cmdr.h"
  8. // define the command handler prototype
  9. typedef void (*pfnCmdHandler)(int argc, char *argv[]);
  10. // dispatch the command
  11. void cmdDispatch(int argc, char *argv[], pfnCmdHandler pCommand)
  12. {
  13. if (argc >= 1 && _stricmp(argv[0], "any") == 0)
  14. {
  15. DWORD rpcStatus = RPC_S_OK;
  16. INTFS_KEY_TABLE IntfsTable;
  17. char * origIntf = argv[0];
  18. IntfsTable.dwNumIntfs = 0;
  19. IntfsTable.pIntfs = NULL;
  20. rpcStatus = WZCEnumInterfaces(NULL, &IntfsTable);
  21. if (rpcStatus != RPC_S_OK)
  22. {
  23. printf("retrieving intf list failed with rpcStatus=%d.\n", rpcStatus);
  24. }
  25. else
  26. {
  27. UINT i;
  28. CHAR szGuid[64] = "";
  29. // print GUIDs
  30. for (i = 0; i < IntfsTable.dwNumIntfs; i++)
  31. {
  32. WideCharToMultiByte(
  33. CP_ACP,
  34. 0,
  35. IntfsTable.pIntfs[i].wszGuid,
  36. min(wcslen(IntfsTable.pIntfs[i].wszGuid), 64),
  37. szGuid,
  38. 64,
  39. NULL,
  40. NULL);
  41. argv[0] = szGuid;
  42. printf("~~~~~~~~~~~~~~~~~~~ %s\n", argv[0]);
  43. pCommand(argc, argv);
  44. printf("\n");
  45. // free the GUID after being printed
  46. RpcFree(IntfsTable.pIntfs[i].wszGuid);
  47. }
  48. // free table of pointers to GUIDs
  49. RpcFree(IntfsTable.pIntfs);
  50. }
  51. argv[0] = origIntf;
  52. }
  53. else
  54. {
  55. pCommand(argc, argv);
  56. }
  57. }
  58. void _cdecl main(int argc, char *argv[])
  59. {
  60. if (argc < 2)
  61. {
  62. printf("usage: wzctool {e|q|s|r}\n");
  63. exit(-1);
  64. }
  65. switch(argv[1][0])
  66. {
  67. case 'e':
  68. case 'E':
  69. cmdE(argc-2, argv+2);
  70. break;
  71. case 'q':
  72. case 'Q':
  73. cmdDispatch(argc-2, argv+2, cmdQ);
  74. break;
  75. case 's':
  76. case 'S':
  77. cmdDispatch(argc-2, argv+2, cmdS);
  78. break;
  79. case 'r':
  80. case 'R':
  81. cmdDispatch(argc-2, argv+2, cmdR);
  82. break;
  83. default:
  84. printf("usage: wzctool {e|q|s|r}\n");
  85. }
  86. }