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.

238 lines
10 KiB

  1. /******************************************************************************
  2. Copyright(c) Microsoft Corporation
  3. Module Name:
  4. create.h
  5. Abstract:
  6. This module contains the macros, user defined structures & function
  7. definitions needed by create.cpp , createvalidations.cpp files.
  8. Author:
  9. B.Raghu Babu 10-oct-2000
  10. Revision History:
  11. B.Raghu Babu 10-oct-2000 : Created it
  12. G.Surender Reddy 25-oct-2000 : Modified it
  13. [ Added macro constants,Function
  14. definitions ]
  15. ******************************************************************************/
  16. #ifndef __CREATE_H
  17. #define __CREATE_H
  18. #pragma once
  19. // Constants declarations
  20. #define MAX_TASKNAME_LEN 512
  21. #define MAX_USERNAME_LEN 300
  22. #define MAX_TIMESTR_LEN 32
  23. #define MAX_SCHEDTYPE_LEN 32
  24. #define MAX_DATESTR_LEN 32
  25. #define MAX_JOB_LEN 238 //Maximum length of task name
  26. #define MAX_TASK_LEN 262 //Max.length of task run
  27. #define MAX_BUF_SIZE 128 //Maximum buffer size for format message
  28. #define MINUTES_PER_HOUR 60 // Minutes per hour
  29. #define SECS_PER_MINUTE 60 // Minutes per hour
  30. #define HOURS_PER_DAY 24 // Minutes per hour
  31. #define HOURS_PER_DAY_MINUS_ONE 23 // Minutes per hour minus one
  32. #define MAX_MONTH_STR_LEN 60 // Maximum length of months
  33. #define MIN_YEAR 1752 // Minimum year
  34. #define MAX_YEAR 9999 // Maximum year
  35. #define CASE_SENSITIVE_VAL 0 // case sensitive.
  36. #define BASE_TEN 10 // Base value for AsLong ()function.
  37. #define MAX_DATE_STR_LEN 50
  38. #define MAX_TIME_STR_LEN 5
  39. #define MAX_ERROR_STRLEN 2056 // max string len for error messages.
  40. #define OPTION_COUNT 1 // No of times an option can be repeated.(Max)
  41. #define DEFAULT_MODIFIER 1 // Default value for the modifier value.
  42. #define DEFAULT_MODIFIER_SZ _T("1") // Default value[string] for the modifier value.
  43. #define DATE_SEPARATOR_CHAR _T('/')
  44. #define DATE_SEPARATOR_STR _T("/")
  45. #define FIRST_DATESEPARATOR_POS 2
  46. #define SECOND_DATESEPARATOR_POS 5
  47. #define FOURTH_DATESEPARATOR_POS 4
  48. #define SEVENTH_DATESEPARATOR_POS 7
  49. #define SCHEDULER_NOT_RUNNING_ERROR_CODE 0x80041315
  50. #define UNABLE_TO_ESTABLISH_ACCOUNT 0x80041310
  51. #define RPC_SERVER_NOT_AVAILABLE 0x800706B5
  52. #define DATESTR_LEN 10
  53. #define MAX_TOKENS_LENGTH 60
  54. #define MIN_REPETITION_INTERVAL 1
  55. #define MAX_REPETITION_INTERVAL 599940
  56. #define TIME_SEPARATOR_CHAR _T(':')
  57. #define TIME_SEPARATOR_STR _T(":")
  58. #define FIRST_TIMESEPARATOR_POS 2
  59. #define SECOND_TIMESEPARATOR_POS 5
  60. #define TIMESTR_LEN 5
  61. #define HOURSPOS_IN_TIMESTR 1
  62. #define MINSPOS_IN_TIMESTR 2
  63. #define SECSPOS_IN_TIMESTR 3
  64. #define EXE_LENGTH 4
  65. #define TIMESTR_OPT_LEN 8
  66. #define MAX_CREATE_OPTIONS 24
  67. #define OI_CREATE_OPTION 0 // Index of -create option in cmdOptions structure.
  68. #define OI_CREATE_USAGE 1 // Index of -? option in cmdOptions structure.
  69. #define OI_CREATE_SERVER 2 // Index of -s option in cmdOptions structure.
  70. #define OI_CREATE_USERNAME 3 // Index of -u option in cmdOptions structure.
  71. #define OI_CREATE_PASSWORD 4 // Index of -p option in cmdOptions structure.
  72. #define OI_CREATE_RUNASUSERNAME 5 // Index of -ru option in cmdOptions structure.
  73. #define OI_CREATE_RUNASPASSWORD 6 // Index of -rp option in cmdOptions structure.
  74. #define OI_CREATE_SCHEDTYPE 7 // Index of -scheduletype option in cmdOptions structure.
  75. #define OI_CREATE_MODIFIER 8 // Index of -modifier option in cmdOptions structure.
  76. #define OI_CREATE_DAY 9 // Index of -day option in cmdOptions structure.
  77. #define OI_CREATE_MONTHS 10// Index of -months option in cmdOptions structure.
  78. #define OI_CREATE_IDLETIME 11 // Index of -idletime option in cmdOptions structure.
  79. #define OI_CREATE_TASKNAME 12 // Index of -taskname option in cmdOptions structure.
  80. #define OI_CREATE_TASKRUN 13 // Index of -taskrun option in cmdOptions structure.
  81. #define OI_CREATE_STARTTIME 14 // Index of -starttime option in cmdOptions structure.
  82. #define OI_CREATE_STARTDATE 15 // Index of -startdate option in cmdOptions structure.
  83. #define OI_CREATE_ENDDATE 16 // Index of -enddate option in cmdOptions structure.
  84. #define OI_CREATE_LOGON_ACTIVE 17 // Index of -it option in cmdOptions structure.
  85. #define OI_CREATE_ENDTIME 18 // Index of -endtime option in cmdOptions structure.
  86. #define OI_CREATE_DUR_END 19 // Index of -k option in cmdOptions structure.
  87. #define OI_CREATE_DURATION 20 // Index of -du option in cmdOptions structure.
  88. #define OI_CREATE_REPEAT_INTERVAL 21 // Index of -ri option in cmdOptions structure.
  89. #define OI_CREATE_DELNOSCHED 22 // Index of -z option in cmdOptions structure.
  90. #define OI_CREATE_FORCE 23 // Index of -f option in cmdOptions structure.
  91. #define OI_RUNANDUSER 6
  92. // Schedule Types
  93. #define SCHED_TYPE_MINUTE 1
  94. #define SCHED_TYPE_HOURLY 2
  95. #define SCHED_TYPE_DAILY 3
  96. #define SCHED_TYPE_WEEKLY 4
  97. #define SCHED_TYPE_MONTHLY 5
  98. #define SCHED_TYPE_ONETIME 6
  99. #define SCHED_TYPE_ONSTART 7
  100. #define SCHED_TYPE_ONLOGON 8
  101. #define SCHED_TYPE_ONIDLE 9
  102. // Months Indices.
  103. #define IND_JAN 1 // January
  104. #define IND_FEB 2 // February
  105. #define IND_MAR 3 // March
  106. #define IND_APR 4 // April
  107. #define IND_MAY 5 // May
  108. #define IND_JUN 6 // June
  109. #define IND_JUL 7 // July
  110. #define IND_AUG 8 // August
  111. #define IND_SEP 9 // September
  112. #define IND_OCT 10 // October
  113. #define IND_NOV 11 // November
  114. #define IND_DEC 12 // December
  115. // Return Values
  116. #define RETVAL_SUCCESS 0
  117. #define RETVAL_FAIL 1
  118. typedef struct __tagCreateSubOps
  119. {
  120. WCHAR *szServer ; // Server Name
  121. WCHAR *szRunAsUser ; //Run As User Name
  122. WCHAR *szRunAsPassword; // Run As Password
  123. WCHAR *szUser ; // User Name
  124. WCHAR *szPassword ; // Password
  125. WCHAR szSchedType[MAX_STRING_LENGTH]; // Schedule Type
  126. WCHAR szModifier[MAX_STRING_LENGTH] ; // Modifier Value
  127. WCHAR szDays[MAX_STRING_LENGTH] ; // Days
  128. WCHAR szMonths [MAX_STRING_LENGTH]; // Months
  129. WCHAR szIdleTime[MAX_STRING_LENGTH] ; // Idle Time
  130. WCHAR szTaskName [ MAX_JOB_LEN]; // Task Name
  131. WCHAR szStartTime[MAX_STRING_LENGTH] ; // Task start time
  132. WCHAR szEndTime [MAX_STRING_LENGTH]; // Task end time
  133. WCHAR szStartDate [MAX_STRING_LENGTH]; // Task start date
  134. WCHAR szEndDate [MAX_STRING_LENGTH]; // End Date of the Task
  135. WCHAR szTaskRun [MAX_TASK_LEN]; // executable name of task
  136. WCHAR szDuration [MAX_STRING_LENGTH]; //duration
  137. WCHAR szRepeat [MAX_STRING_LENGTH]; //duration
  138. DWORD bCreate; // Create option
  139. DWORD bUsage; // Usage option.
  140. BOOL bActive; // /it option
  141. BOOL bIsDurEnd; // /du option
  142. BOOL bIsDeleteNoSched; // /z option
  143. BOOL bForce; // /f option
  144. BOOL bInMinutes; // /it option
  145. BOOL bInHours; // /du option
  146. } TCREATESUBOPTS, *PTCREATESUBOPTS;
  147. typedef struct __tagCreateOpsVals
  148. {
  149. BOOL bSetStartDateToCurDate; // Is start date to be set to current date
  150. BOOL bSetStartTimeToCurTime; // Is start date to be set to current date
  151. BOOL bPassword;
  152. BOOL bRunAsPassword;
  153. } TCREATEOPVALS;
  154. DWORD DisplayCreateUsage();
  155. HRESULT CreateTask(TCREATESUBOPTS tcresubops, TCREATEOPVALS &tcreoptvals,
  156. DWORD dwScheduleType, WORD wUserStatus );
  157. DWORD ProcessCreateOptions(DWORD argc, LPCTSTR argv[],TCREATESUBOPTS &tcresubops,
  158. TCREATEOPVALS &tcreoptvals, DWORD* pdwRetScheType, WORD *pwUserStatus );
  159. DWORD ValidateSuboptVal(TCREATESUBOPTS& tcresubops, TCREATEOPVALS &tcreoptvals,
  160. TCMDPARSER2 cmdOptions[], DWORD dwScheduleType);
  161. DWORD ValidateRemoteSysInfo(
  162. TCMDPARSER2 cmdOptions[] , TCREATESUBOPTS& tcresubops, TCREATEOPVALS &tcreoptvals);
  163. DWORD ValidateModifierVal(LPCTSTR szModifier, DWORD dwScheduleType,
  164. DWORD dwModOptActCnt, DWORD dwDayOptCnt,
  165. DWORD dwMonOptCnt, BOOL &bIsDefltValMod);
  166. DWORD ValidateDayAndMonth(LPWSTR szDay, LPWSTR szMonths, DWORD dwSchedType,
  167. DWORD dwDayOptCnt, DWORD dwMonOptCnt, DWORD dwModifier,LPWSTR szModifier);
  168. DWORD ValidateStartDate(LPWSTR szStartDate, DWORD dwSchedType, DWORD dwStDtOptCnt,
  169. BOOL &bIsCurrentDate);
  170. DWORD ValidateEndDate(LPWSTR szEndDate, DWORD dwSchedType, DWORD dwEndDtOptCnt);
  171. DWORD ValidateStartTime(LPWSTR szStartTime, DWORD dwSchedType, DWORD dwStTimeOptCnt,
  172. BOOL &bIsCurrentTime);
  173. DWORD ValidateEndTime(LPWSTR szEndTime, DWORD dwSchedType, DWORD dwEndTimeOptCnt );
  174. DWORD ValidateIdleTimeVal(LPWSTR szIdleTime, DWORD dwSchedType,
  175. DWORD dwIdlTimeOptCnt);
  176. DWORD ValidateDateString(LPWSTR szDate, BOOL bStartDate );
  177. DWORD ValidateTimeString(LPWSTR szTime);
  178. DWORD GetDateFieldEntities(LPWSTR szDate, WORD* pdwDate, WORD* pdwMon,
  179. WORD* pdwYear);
  180. DWORD ValidateDateFields( DWORD dwDate, DWORD dwMon, DWORD dwyear);
  181. DWORD GetTimeFieldEntities(LPWSTR szTime, WORD* pdwHours, WORD* pdwMins );
  182. DWORD ValidateTimeFields( DWORD dwHours, DWORD dwMins );
  183. WORD GetTaskTrigwDayForDay(LPWSTR szDay);
  184. WORD GetTaskTrigwMonthForMonth(LPWSTR szMonth);
  185. DWORD ValidateMonth(LPWSTR szMonths);
  186. DWORD ValidateDay(LPWSTR szDays);
  187. WORD GetMonthId(DWORD dwMonthId);
  188. DWORD GetNumDaysInaMonth(WCHAR* szMonths, WORD wStartYear);
  189. BOOL VerifyJobName(WCHAR* pszJobName);
  190. DWORD GetDateFieldFormat(WORD* pdwDate);
  191. DWORD GetDateFormatString(LPWSTR szFormat);
  192. DWORD ProcessFilePath(LPWSTR szInput,LPWSTR szFirstString,LPWSTR szSecondString);
  193. BOOL ReleaseMemory(PTCREATESUBOPTS pParams);
  194. DWORD ConfirmInput ( BOOL *bCancel );
  195. #endif // __CREATE_H