Leaked source code of windows server 2003
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.

87 lines
3.0 KiB

  1. #include <precomp.h>
  2. #include "PrmDescr.h"
  3. #include "ArgParse.h"
  4. #include "CmdFn.h"
  5. // global object storing all the data needed in order to process the wzctool command
  6. PARAM_DESCR_DATA g_PDData;
  7. // global table containing the description of all possible parameters
  8. PARAM_DESCR g_PDTable[] =
  9. {
  10. // param ID ------- param string -- arg parser ---- command function
  11. {PRM_SHOW, L"show", FnPaGuid, FnCmdShow},
  12. {PRM_ADD, L"add", FnPaGuid, FnCmdAdd},
  13. {PRM_DELETE, L"delete", FnPaGuid, FnCmdDelete},
  14. {PRM_SET, L"set", FnPaGuid, FnCmdSet},
  15. {PRM_VISIBLE, L"visible", NULL, NULL},
  16. {PRM_PREFERRED, L"preferred", NULL, NULL},
  17. {PRM_MASK, L"mask", FnPaMask, NULL},
  18. {PRM_ENABLED, L"enabled", FnPaEnabled, NULL},
  19. {PRM_SSID, L"ssid", FnPaSsid, NULL},
  20. {PRM_BSSID, L"bssid", FnPaBssid, NULL},
  21. {PRM_IM, L"im", FnPaIm, NULL},
  22. {PRM_AM, L"am", FnPaAm, NULL},
  23. {PRM_PRIV, L"priv", FnPaPriv, NULL},
  24. {PRM_ONETIME, L"onetime", NULL, NULL},
  25. {PRM_REFRESH, L"refresh", NULL, NULL},
  26. {PRM_KEY, L"key", FnPaKey, NULL},
  27. {PRM_ONEX, L"onex", FnPaOneX, NULL},
  28. {PRM_FILE, L"output", FnPaOutFile, NULL}
  29. };
  30. // global hash used to store all the acceptable parameters
  31. HASH g_PDHash;
  32. //----------------------------------------------------------
  33. // initialize and fill in the hash for the parameter descriptors
  34. // Returns: win32 error
  35. DWORD
  36. PDInitialize()
  37. {
  38. DWORD dwErr;
  39. // initialize the parameter descriptors data
  40. ZeroMemory(&g_PDData, sizeof(PARAM_DESCR_DATA));
  41. g_PDData.pfOut = stdout;
  42. // initialize the parameter descriptors hash
  43. dwErr = HshInitialize(&g_PDHash);
  44. // fill in the parameter descriptors hash
  45. if (dwErr == ERROR_SUCCESS)
  46. {
  47. UINT nPDTableSize = sizeof(g_PDTable) / sizeof(PARAM_DESCR);
  48. UINT i;
  49. for (i=0; dwErr == ERROR_SUCCESS && i < nPDTableSize; i++)
  50. {
  51. PPARAM_DESCR pPDTableEntry = &(g_PDTable[i]);
  52. dwErr = HshInsertObjectRef(
  53. g_PDHash.pRoot,
  54. pPDTableEntry->wszParam,
  55. pPDTableEntry,
  56. &(g_PDHash.pRoot));
  57. }
  58. }
  59. SetLastError(dwErr);
  60. return dwErr;
  61. }
  62. //----------------------------------------------------------
  63. // Clean out resources used for the parameter descriptors
  64. VOID
  65. PDDestroy()
  66. {
  67. // clean out the parameter descriptors data
  68. WZCDeleteIntfObj(&(g_PDData.wzcIntfEntry));
  69. // close the output file
  70. if (g_PDData.pfOut != stdout)
  71. {
  72. fclose(g_PDData.pfOut);
  73. g_PDData.pfOut = stdout;
  74. }
  75. // clean out resources used by the parameter descriptors hash
  76. HshDestroy(&g_PDHash);
  77. }