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.

268 lines
6.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. posix.C
  5. Abstract:
  6. functions to used to determine if the OS/2 subsystem is present
  7. on the current system.
  8. Author:
  9. Bob Watson (a-robw)
  10. Revision History:
  11. 23 Dec 94
  12. --*/
  13. #include <windows.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <c2dll.h>
  17. #include <c2inc.h>
  18. #include <c2utils.h>
  19. #include "c2funcs.h"
  20. #include "c2funres.h"
  21. // define action codes here. They are only meaningful in the
  22. // context of this module.
  23. #define SECURE C2DLL_C2
  24. static
  25. BOOL
  26. IsPosixOnSystem (
  27. )
  28. {
  29. BOOL bFileFound;
  30. LPCTSTR szFileToCheck;
  31. TCHAR szPosixPath[MAX_PATH];
  32. SET_WAIT_CURSOR;
  33. szFileToCheck = GetStringResource(GetDllInstance(), IDS_POSIX_FILE);
  34. GetExpandedFileName (
  35. (LPTSTR)szFileToCheck,
  36. MAX_PATH,
  37. szPosixPath,
  38. NULL);
  39. bFileFound = FileExists(szPosixPath);
  40. if (bFileFound) {
  41. // check to see if it's really there
  42. if (GetFileSizeFromPath(szPosixPath) == 0) {
  43. // just a name so reset flag
  44. bFileFound = FALSE;
  45. }
  46. }
  47. SET_ARROW_CURSOR;
  48. return bFileFound;
  49. }
  50. LONG
  51. C2QueryPosix (
  52. IN LPARAM lParam
  53. )
  54. /*++
  55. Routine Description:
  56. Function called to find out if the OS/2 subsystem is installed
  57. on the system. For C2 compliance, OS/2 must not be
  58. allowed on the system.
  59. Arguments:
  60. Pointer to the Dll data block passed as an LPARAM.
  61. ReturnValue:
  62. ERROR_SUCCESS if the function succeeds otherwise a
  63. WIN32 error is returned if an error occurs
  64. --*/
  65. {
  66. PC2DLL_DATA pC2Data;
  67. if (lParam != 0) {
  68. pC2Data = (PC2DLL_DATA)lParam;
  69. pC2Data->lC2Compliance = SECURE; // assume true for now
  70. // check for DOS files found on system
  71. if (IsPosixOnSystem()) {
  72. pC2Data->lC2Compliance = C2DLL_NOT_SECURE;
  73. lstrcpy (pC2Data->szStatusName,
  74. GetStringResource (GetDllInstance(), IDS_POSIX_ON_SYSTEM));
  75. }
  76. if (pC2Data->lC2Compliance == SECURE) {
  77. lstrcpy (pC2Data->szStatusName,
  78. GetStringResource (GetDllInstance(), IDS_POSIX_NOT_ON_SYSTEM));
  79. }
  80. } else {
  81. return ERROR_BAD_ARGUMENTS;
  82. }
  83. return ERROR_SUCCESS;
  84. }
  85. LONG
  86. C2SetPosix (
  87. IN LPARAM lParam
  88. )
  89. /*++
  90. Routine Description:
  91. Function called to change the current state of this configuration
  92. item based on an action code passed in the DLL data block. If
  93. this function successfully sets the state of the configuration
  94. item, then the C2 Compliance flag and the Status string to reflect
  95. the new value of the configuration item.
  96. Arguments:
  97. Pointer to the Dll data block passed as an LPARAM.
  98. ReturnValue:
  99. ERROR_SUCCESS if the function succeeds otherwise a
  100. WIN32 error is returned if an error occurs
  101. --*/
  102. {
  103. PC2DLL_DATA pC2Data;
  104. LPCTSTR szFileToCheck;
  105. TCHAR szOldPath[MAX_PATH];
  106. TCHAR szNewPath[MAX_PATH];
  107. BOOL bReturn;
  108. LONG lReturn = ERROR_SUCCESS;
  109. if (lParam != 0) {
  110. pC2Data = (PC2DLL_DATA)lParam;
  111. if (pC2Data->lActionCode == 1) {
  112. if (DisplayDllMessageBox (
  113. pC2Data->hWnd,
  114. IDS_POSIX_CONFIRM,
  115. IDS_POSIX_CAPTION,
  116. MBOKCANCEL_EXCLAIM | MB_DEFBUTTON2) == IDOK) {
  117. SET_WAIT_CURSOR;
  118. szFileToCheck = GetStringResource(
  119. GetDllInstance(), IDS_POSIX_FILE);
  120. GetExpandedFileName (
  121. (LPTSTR)szFileToCheck,
  122. MAX_PATH,
  123. szOldPath,
  124. NULL);
  125. if (FileExists (szOldPath)) {
  126. szFileToCheck = GetStringResource(
  127. GetDllInstance(), IDS_NEW_POSIX_FILE);
  128. GetExpandedFileName (
  129. (LPTSTR)szFileToCheck,
  130. MAX_PATH,
  131. szNewPath,
  132. NULL);
  133. bReturn = DeleteFile (szOldPath);
  134. } else {
  135. // if the file does not exist, then that's ok too.
  136. bReturn = TRUE;
  137. }
  138. SET_ARROW_CURSOR;
  139. if (bReturn) {
  140. // then all files have been renamed so update message
  141. pC2Data->lC2Compliance = SECURE;
  142. lstrcpy (pC2Data->szStatusName,
  143. GetStringResource (GetDllInstance(),
  144. IDS_POSIX_NOT_ON_SYSTEM));
  145. return ERROR_SUCCESS;
  146. } else {
  147. DisplayDllMessageBox (
  148. pC2Data->hWnd,
  149. IDS_POSIX_ERROR_MOVING,
  150. IDS_POSIX_CAPTION,
  151. MBOK_EXCLAIM);
  152. return ERROR_CAN_NOT_COMPLETE;
  153. }
  154. }
  155. pC2Data->lActionCode = 0;
  156. }
  157. } else {
  158. return ERROR_BAD_ARGUMENTS;
  159. }
  160. }
  161. LONG
  162. C2DisplayPosix (
  163. IN LPARAM lParam
  164. )
  165. /*++
  166. Routine Description:
  167. Function called to display more information on the configuration
  168. item and provide the user with the option to change the current
  169. setting (if appropriate). If the User "OK's" out of the UI,
  170. then the action code field in the DLL data block is set to the
  171. appropriate (and configuration item-specific) action code so the
  172. "Set" function can be called to perform the desired action. If
  173. the user Cancels out of the UI, then the Action code field is
  174. set to 0 (no action) and no action is performed.
  175. Arguments:
  176. Pointer to the Dll data block passed as an LPARAM.
  177. ReturnValue:
  178. ERROR_SUCCESS if the function succeeds otherwise a
  179. WIN32 error is returned if an error occurs
  180. --*/
  181. {
  182. PC2DLL_DATA pC2Data;
  183. if (lParam != 0) {
  184. pC2Data = (PC2DLL_DATA)lParam;
  185. // check the C2 Compliance flag to see if the list box or
  186. // message box should be displayed
  187. if (pC2Data->lC2Compliance == SECURE) {
  188. // all volumes are OK so just pop a message box
  189. DisplayDllMessageBox (
  190. pC2Data->hWnd,
  191. IDS_POSIX_NOT_ON_SYSTEM,
  192. IDS_POSIX_CAPTION,
  193. MBOK_INFO);
  194. pC2Data->lActionCode = 0;
  195. } else {
  196. if (DisplayDllMessageBox (
  197. pC2Data->hWnd,
  198. IDS_POSIX_DISPLAY_MESSAGE,
  199. IDS_POSIX_CAPTION,
  200. MBOKCANCEL_EXCLAIM) == IDOK) {
  201. pC2Data->lActionCode = 1;
  202. } else {
  203. pC2Data->lActionCode = 0;
  204. }
  205. }
  206. } else {
  207. return ERROR_BAD_ARGUMENTS;
  208. }
  209. return ERROR_SUCCESS;
  210. }
  211. 
  212.