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.

226 lines
7.5 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1997
  4. *
  5. * TITLE: PARSE.H
  6. *
  7. * VERSION: 2.0
  8. *
  9. * AUTHOR: ReedB
  10. *
  11. * DATE: 1 Jan, 1997
  12. *
  13. * DESCRIPTION:
  14. *
  15. * Declarations and definitions for the parse helper.
  16. *
  17. *******************************************************************************/
  18. #include <nt.h>
  19. #include <ntrtl.h>
  20. #include <nturtl.h>
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <malloc.h>
  24. #include <string.h>
  25. #include <memory.h>
  26. #include <windows.h>
  27. #include <regstr.h>
  28. #include <ntpoapi.h>
  29. #include "powrprofp.h"
  30. #define MAX_LINES 256
  31. #define MAX_STR 128
  32. #define DELIMITERS ","
  33. #define LINE_DELIMITERS "\n\r"
  34. // The following defines determine which zero based line of the spread sheet
  35. // a given data will appear on. These are one based line indicies which match
  36. // the spreadsheet line numbers as long as no blank lines are included.
  37. #define SKU_LINE 1
  38. #define NAME_LINE 2
  39. #define DESCRIPTION_LINE 3
  40. #define PLATFORM_LINE 4
  41. #define INSTALL_ON_LINE 5
  42. #define SYSTEM_IDLE_LINE SKU_LINE + 7
  43. #define SYSTEM_IDLE_TIMEOUT_LINE SYSTEM_IDLE_LINE + 1
  44. #define SYSTEM_IDLE_SLEEP_ACTION_FLAGS_LINE SYSTEM_IDLE_LINE + 2
  45. #define SYSTEM_IDLE_SENSITIVITY_LINE SYSTEM_IDLE_LINE + 8
  46. #define MIN_SLEEP_LINE SKU_LINE + 17
  47. #define MAX_SLEEP_LINE MIN_SLEEP_LINE + 1
  48. #define REDUCED_LATENCY_SLEEP_LINE MIN_SLEEP_LINE + 2
  49. #define DOZE_TIMEOUT_LINE MIN_SLEEP_LINE + 3
  50. #define DOZE_S4_TIMEOUT_LINE MIN_SLEEP_LINE + 4
  51. #define VIDEO_TIMEOUT_LINE SKU_LINE + 23
  52. #define SPINDOWN_TIMEOUT_LINE VIDEO_TIMEOUT_LINE + 1
  53. #define OPTIMIZE_FOR_POWER_LINE SKU_LINE + 26
  54. #define FAN_THROTTLE_TOL_LINE OPTIMIZE_FOR_POWER_LINE + 1
  55. #define FORCED_THROTTLE_LINE OPTIMIZE_FOR_POWER_LINE + 2
  56. #define MIN_THROTTLE_LINE OPTIMIZE_FOR_POWER_LINE + 3
  57. #define OVERTHROTTLED_LINE OPTIMIZE_FOR_POWER_LINE + 4
  58. #define OVERTHROTTLED_SLEEP_ACTION_FLAGS_LINE OPTIMIZE_FOR_POWER_LINE + 5
  59. #define DYNAMIC_THROTTLE_LINE OPTIMIZE_FOR_POWER_LINE + 11
  60. #define C1_THRESHOLDS_LINE DYNAMIC_THROTTLE_LINE + 1
  61. #define C2_THRESHOLDS_LINE C1_THRESHOLDS_LINE + 8
  62. #define C3_THRESHOLDS_LINE C2_THRESHOLDS_LINE + 8
  63. // Global
  64. #define ADVANCED_LINE 64
  65. #define LOCK_ON_SLEEP_LINE ADVANCED_LINE + 1
  66. #define WAKE_ON_RING_LINE ADVANCED_LINE + 2
  67. #define VIDEO_DIM_DISPLAY_LINE ADVANCED_LINE + 3
  68. #define POWER_BUTTON_LINE ADVANCED_LINE + 5
  69. #define POWER_BUTTON_SLEEP_ACTION_FLAGS_LINE ADVANCED_LINE + 6
  70. #define POWER_BUTTON_SLEEP_EVENT_CODE_LINE ADVANCED_LINE + 12
  71. #define SLEEP_BUTTON_LINE ADVANCED_LINE + 14
  72. #define SLEEP_BUTTON_SLEEP_ACTION_FLAGS_LINE ADVANCED_LINE + 15
  73. #define SLEEP_BUTTON_SLEEP_EVENT_CODE_LINE ADVANCED_LINE + 21
  74. #define LID_CLOSE_LINE ADVANCED_LINE + 23
  75. #define LID_CLOSE_SLEEP_ACTION_FLAGS_LINE ADVANCED_LINE + 24
  76. #define LID_OPEN_WAKE_LINE ADVANCED_LINE + 30
  77. #define BROADCAST_CAP_RES_LINE 96
  78. #define BATMETER_ENABLE_SYSTRAY_FLAG_LINE BROADCAST_CAP_RES_LINE + 2
  79. #define BATMETER_ENABLE_MULTI_FLAG_LINE BROADCAST_CAP_RES_LINE + 3
  80. #define DISCHARGE_POLICY_1_LINE BROADCAST_CAP_RES_LINE + 4
  81. #define DISCHARGE_POLICY_2_LINE BROADCAST_CAP_RES_LINE + 18
  82. // Handy line offsets, for sleep action flags.
  83. #define QUERY_APPS 1
  84. #define ALLOW_UI 2
  85. #define IGNORE_NON_RESP 3
  86. #define IGNORE_WAKE 4
  87. #define IGNORE_CRITICAL 5
  88. // offsets for sleep action event codes
  89. #define NOTIFY_USER_CODE 1
  90. // Handy line offsets for DISCHARGE_POLICIES
  91. #define DP_ENABLE 1
  92. #define DP_BAT_LEVEL 2
  93. #define DP_POWER_POLICY 3
  94. #define DP_MIN_SLEEP_STATE 4
  95. #define DP_TEXT_NOTIFY 6
  96. #define DP_SOUND_NOTIFY 7
  97. #define DP_SLEEP_ACT_FLAGS 8
  98. // Handy line offsets for C-state thresholds
  99. #define C_TIME_CHECK 1
  100. #define C_PROMOTE_LIMIT 2
  101. #define C_DEMOTE_LIMIT 3
  102. #define C_PROMOTE_PERCENT 4
  103. #define C_DEMOTE_PERCENT 5
  104. #define C_ALLOW_PROMOTION 6
  105. #define C_ALLOW_DEMOTION 7
  106. // Memphis INF types:
  107. #define TYPICAL 0x01
  108. #define COMPACT 0x02
  109. #define CUSTOM 0x04
  110. #define PORTABLE 0x08
  111. #define SERVER 0x10
  112. #define NUM_INF_TYPES 5
  113. // OS types:
  114. #define WIN_95 1
  115. #define WIN_NT 2
  116. // file locations
  117. #define MACHINE_INF_NAME "..\\winnt\\POWERSYS.INF"
  118. #define USER_INF_NAME "..\\winnt\\POWERSFT.INF"
  119. #define INI_NAME "POWERCFG.INI"
  120. #define MAX_SKUS 6
  121. #define MAX_PROFILES 16
  122. #define MAX_LINE_SIZE 1024
  123. #define DATA_REV 1
  124. extern char *g_pszSrc[MAX_SKUS];
  125. extern char *g_pszLines[MAX_SKUS][MAX_LINES];
  126. extern char *g_pszSkuNames[MAX_SKUS];
  127. extern char g_pszSkuDecoration[MAX_SKUS];
  128. extern UINT g_uiPoliciesCount[MAX_SKUS];
  129. extern PMACHINE_POWER_POLICY g_pmpp[MAX_SKUS][MAX_PROFILES];
  130. extern PUSER_POWER_POLICY g_pupp[MAX_SKUS][MAX_PROFILES];
  131. extern PMACHINE_PROCESSOR_POWER_POLICY g_ppmpp[MAX_SKUS][MAX_PROFILES];
  132. extern GLOBAL_USER_POWER_POLICY g_gupp[MAX_SKUS];
  133. extern GLOBAL_MACHINE_POWER_POLICY g_gmpp[MAX_SKUS];
  134. // Function prototypes implemented in MAKEINI.C or MAKEINF.C:
  135. VOID CDECL DefFatalExit(BOOLEAN, char*, ... );
  136. // Function prototypes implemented in PARSE.C:
  137. void StrToUpper(char*, char*);
  138. UINT GetTokens(char*, UINT, char**, UINT, char*);
  139. VOID GetCheckLabelToken(UINT uiLine, char *pszCheck, UINT uiSku);
  140. UINT GetFlagToken(UINT);
  141. UINT GetPowerStateToken(VOID);
  142. UINT GetIntToken(char*);
  143. VOID GetNAToken(VOID);
  144. POWER_ACTION GetPowerActionToken(VOID);
  145. UINT GetOSTypeToken(VOID);
  146. UINT GetINFTypeToken(VOID);
  147. void StrTrimTrailingBlanks(char *);
  148. UINT GetThrottleToken(VOID);
  149. VOID CDECL DefFatalExit(BOOLEAN bGetLastError, char *pszFormat, ... );
  150. BOOLEAN ReadSource(void);
  151. UINT BuildLineArray(void);
  152. VOID GetSleepActionFlags(
  153. UINT uiStartLine,
  154. UINT uiFlagsAC[],
  155. UINT uiFlagsDC[],
  156. PUINT puiCount,
  157. UINT sku
  158. );
  159. VOID GetSleepActionFlagsGlobal(
  160. UINT uiStartLine,
  161. PPOWER_ACTION_POLICY ppapAC,
  162. PPOWER_ACTION_POLICY ppapDC,
  163. UINT sku
  164. );
  165. VOID GetSleepActionFlagsUserPolicy(
  166. UINT uiStartLine,
  167. ULONG ulAcPowerPolicyOffset,
  168. ULONG ulDcPowerPolicyOffset,
  169. PUINT puiCount,
  170. UINT sku
  171. );
  172. VOID GetSleepActionFlagsMachinePolicy(
  173. UINT uiStartLine,
  174. ULONG ulAcPowerPolicyOffset,
  175. ULONG ulDcPowerPolicyOffset,
  176. PUINT puiCount,
  177. UINT sku
  178. );
  179. VOID GetCStateThresholds(
  180. UINT uiStartLine,
  181. UINT uiCState,
  182. PUINT puiCount,
  183. UINT sku
  184. );
  185. VOID GetDischargePolicies(
  186. UINT uiLine,
  187. UINT uiNum,
  188. UINT uiIndex,
  189. UINT sku
  190. );
  191. BOOLEAN GetGlobalPolicies(void);
  192. BOOLEAN GetPolicies(void);
  193. VOID GetPolicyInf(void);