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.

157 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. locate.c
  5. Abstract:
  6. This module contains the code
  7. for finding, adding, removing, and identifying hid devices.
  8. Environment:
  9. Kernel & user mode
  10. Revision History:
  11. Nov-96 : Created by Kenneth D. Ray
  12. --*/
  13. #include <basetyps.h>
  14. #include <stdlib.h>
  15. #include <wtypes.h>
  16. #include <cfgmgr32.h>
  17. #include <initguid.h>
  18. #include <stdio.h>
  19. #include <winioctl.h>
  20. #include "dock.h"
  21. #define USAGE "Usage: dock [-e] [-v] [-f]\n" \
  22. "\t -e eject dock\n" \
  23. "\t -v verbose\n" \
  24. "\t -f force\n"
  25. VOID
  26. DockStartEject (
  27. BOOLEAN Verbose,
  28. BOOLEAN Force
  29. );
  30. __cdecl
  31. main (
  32. ULONG argc,
  33. CHAR *argv[]
  34. )
  35. /*++
  36. ++*/
  37. {
  38. BOOLEAN eject = FALSE;
  39. BOOLEAN verbose = FALSE;
  40. BOOLEAN force = FALSE;
  41. BOOLEAN error = FALSE;
  42. ULONG i;
  43. char * parameter = NULL;
  44. //
  45. // parameter parsing follows:
  46. //
  47. try {
  48. if (argc < 2) {
  49. leave;
  50. }
  51. for (i = 1; i < argc; i++) {
  52. parameter = argv[i];
  53. if ('-' == *(parameter ++)) {
  54. switch (*parameter) {
  55. case 'e':
  56. eject = TRUE;
  57. break;
  58. case 'v':
  59. verbose = TRUE;
  60. break;
  61. case 'f':
  62. force = TRUE;
  63. break;
  64. default:
  65. error = TRUE;
  66. leave;
  67. }
  68. } else {
  69. error = TRUE;
  70. leave;
  71. }
  72. }
  73. } finally {
  74. if (error || ((!eject) && (!verbose))) {
  75. printf (USAGE);
  76. exit (1);
  77. }
  78. if (verbose) {
  79. printf ("Verbose Mode Requested \n");
  80. }
  81. if (eject) {
  82. printf ("Eject Requested \n");
  83. DockStartEject (verbose, force);
  84. }
  85. }
  86. printf("Done\n");
  87. return 0;
  88. }
  89. VOID
  90. DockStartEject (
  91. BOOLEAN Verbose,
  92. BOOLEAN Force
  93. )
  94. /*++
  95. --*/
  96. {
  97. CONFIGRET status;
  98. BOOL present;
  99. if (Verbose) {
  100. printf("Checking if Dock Present\n");
  101. }
  102. status = CM_Is_Dock_Station_Present (&present);
  103. if (Verbose) {
  104. printf("ret 0x%x, Present %s\n",
  105. status,
  106. (present ? "TRUE" : "FALSE"));
  107. }
  108. if (Force || present) {
  109. if (Verbose) {
  110. printf("Calling eject\n");
  111. }
  112. status = CM_Request_Eject_PC ();
  113. if (Verbose) {
  114. printf("ret 0x%x\n", status);
  115. }
  116. } else {
  117. printf("Skipping eject call\n");
  118. }
  119. }