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.

213 lines
7.9 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_CREATE_OPTIONS 15 // Total Number of sub-options in -create option.
  26. #define MAX_JOB_LEN 239 //Maximum length of task name
  27. #define MAX_TASK_LEN 262 //Max.length of task run
  28. #define MAX_BUF_SIZE 128 //Maximum buffer size for format message
  29. #define MINUTES_PER_HOUR 60 // Minutes per hour
  30. #define SECS_PER_MINUTE 60 // Minutes per hour
  31. #define HOURS_PER_DAY 24 // Minutes per hour
  32. #define HOURS_PER_DAY_MINUS_ONE 23 // Minutes per hour minus one
  33. #define MAX_MONTH_STR_LEN 60 // Maximum length of months
  34. #define MIN_YEAR 1752 // Minimum year
  35. #define MAX_YEAR 9999 // Maximum year
  36. #define CASE_SENSITIVE_VAL 0 // case sensitive.
  37. #define BASE_TEN 10 // Base value for AsLong ()function.
  38. #define MAX_DATE_STR_LEN 50
  39. #define MAX_TIME_STR_LEN 5
  40. #define MAX_ERROR_STRLEN 2056 // max string len for error messages.
  41. #define OPTION_COUNT 1 // No of times an option can be repeated.(Max)
  42. #define DEFAULT_MODIFIER 1 // Default value for the modifier value.
  43. #define DEFAULT_MODIFIER_SZ _T("1") // Default value[string] for the modifier value.
  44. #define DATE_SEPARATOR_CHAR _T('/')
  45. #define DATE_SEPARATOR_STR _T("/")
  46. #define FIRST_DATESEPARATOR_POS 2
  47. #define SECOND_DATESEPARATOR_POS 5
  48. #define FOURTH_DATESEPARATOR_POS 4
  49. #define SEVENTH_DATESEPARATOR_POS 7
  50. #define SCHEDULER_NOT_RUNNING_ERROR_CODE 0x80041315
  51. #define UNABLE_TO_ESTABLISH_ACCOUNT 0x80041310
  52. #define RPC_SERVER_NOT_AVAILABLE 0x800706B5
  53. #define DATESTR_LEN 10
  54. #define MAX_TOKENS_LENGTH 60
  55. #define TIME_SEPARATOR_CHAR _T(':')
  56. #define TIME_SEPARATOR_STR _T(":")
  57. #define FIRST_TIMESEPARATOR_POS 2
  58. #define SECOND_TIMESEPARATOR_POS 5
  59. #define TIMESTR_LEN 8
  60. #define HOURSPOS_IN_TIMESTR 1
  61. #define MINSPOS_IN_TIMESTR 2
  62. #define SECSPOS_IN_TIMESTR 3
  63. #define EXE_LENGTH 4
  64. #define OI_SERVER 1 // Index of -s option in cmdOptions structure.
  65. #define OI_RUNASUSERNAME 2 // Index of -ru option in cmdOptions structure.
  66. #define OI_RUNASPASSWORD 3 // Index of -rp option in cmdOptions structure.
  67. #define OI_USERNAME 4 // Index of -u option in cmdOptions structure.
  68. #define OI_PASSWORD 5 // Index of -p option in cmdOptions structure.
  69. #define OI_SCHEDTYPE 6 // Index of -scheduletype option in cmdOptions structure.
  70. #define OI_MODIFIER 7 // Index of -modifier option in cmdOptions structure.
  71. #define OI_DAY 8 // Index of -day option in cmdOptions structure.
  72. #define OI_MONTHS 9 // Index of -months option in cmdOptions structure.
  73. #define OI_IDLETIME 10 // Index of -idletime option in cmdOptions structure.
  74. #define OI_TASKNAME 11 // Index of -taskname option in cmdOptions structure.
  75. #define OI_TASKRUN 12 // Index of -taskrun option in cmdOptions structure.
  76. #define OI_STARTTIME 13 // Index of -starttime option in cmdOptions structure.
  77. #define OI_STARTDATE 14 // Index of -startdate option in cmdOptions structure.
  78. #define OI_ENDDATE 15 // Index of -enddate option in cmdOptions structure.
  79. #define OI_USAGE 16 // Index of -? option in cmdOptions structure.
  80. #define OI_RUNANDUSER 6
  81. // Schedule Types
  82. #define SCHED_TYPE_MINUTE 1
  83. #define SCHED_TYPE_HOURLY 2
  84. #define SCHED_TYPE_DAILY 3
  85. #define SCHED_TYPE_WEEKLY 4
  86. #define SCHED_TYPE_MONTHLY 5
  87. #define SCHED_TYPE_ONETIME 6
  88. #define SCHED_TYPE_ONSTART 7
  89. #define SCHED_TYPE_ONLOGON 8
  90. #define SCHED_TYPE_ONIDLE 9
  91. // Months Indices.
  92. #define IND_JAN 1 // January
  93. #define IND_FEB 2 // February
  94. #define IND_MAR 3 // March
  95. #define IND_APR 4 // April
  96. #define IND_MAY 5 // May
  97. #define IND_JUN 6 // June
  98. #define IND_JUL 7 // July
  99. #define IND_AUG 8 // August
  100. #define IND_SEP 9 // September
  101. #define IND_OCT 10 // October
  102. #define IND_NOV 11 // November
  103. #define IND_DEC 12 // December
  104. // Return Values
  105. #define RETVAL_SUCCESS 0
  106. #define RETVAL_FAIL 1
  107. typedef struct __tagCreateSubOps
  108. {
  109. TCHAR szServer [ _MAX_PATH ]; // Server Name
  110. TCHAR szRunAsUser [ MAX_STRING_LENGTH ] ; //Run As User Name
  111. TCHAR szRunAsPassword [ MAX_STRING_LENGTH ]; // Run As Password
  112. TCHAR szUser [ MAX_STRING_LENGTH ] ; // User Name
  113. TCHAR szPassword [ MAX_STRING_LENGTH ]; // Password
  114. TCHAR szSchedType [ MAX_TASKNAME_LEN ]; // Schedule Type
  115. TCHAR szModifier [ MAX_SCHEDTYPE_LEN ]; // Modifier Value
  116. TCHAR szDays [ MAX_DATE_STR_LEN ]; // Days
  117. TCHAR szMonths [ MAX_DATE_STR_LEN]; // Months
  118. TCHAR szIdleTime [ MAX_TIMESTR_LEN]; // Idle Time
  119. TCHAR szTaskName [ MAX_TASKNAME_LEN]; // Task Name
  120. TCHAR szStartTime [ MAX_STRING_LENGTH ]; // Task start time
  121. TCHAR szStartDate [ MAX_STRING_LENGTH]; // Task start date
  122. TCHAR szEndDate [ MAX_STRING_LENGTH ]; // End Date of the Task
  123. TCHAR szTaskRun [ _MAX_PATH ]; // executable name of task
  124. DWORD bCreate; // Create option
  125. DWORD bUsage; // Usage option.
  126. } TCREATESUBOPTS;
  127. typedef struct __tagCreateOpsVals
  128. {
  129. BOOL bSetStartDateToCurDate; // Is start date to be set to current date
  130. BOOL bSetStartTimeToCurTime; // Is start date to be set to current date
  131. BOOL bPassword;
  132. BOOL bRunAsPassword;
  133. } TCREATEOPVALS;
  134. DWORD DisplayCreateUsage();
  135. HRESULT CreateTask(TCREATESUBOPTS tcresubops, TCREATEOPVALS &tcreoptvals,
  136. DWORD dwScheduleType, WORD wUserStatus);
  137. DWORD ProcessCreateOptions(DWORD argc, LPCTSTR argv[],TCREATESUBOPTS &tcresubops,
  138. TCREATEOPVALS &tcreoptvals, DWORD* pdwRetScheType, WORD *pwUserStatus);
  139. DWORD ValidateSuboptVal(TCREATESUBOPTS& tcresubops, TCREATEOPVALS &tcreoptvals,
  140. TCMDPARSER cmdOptions[], DWORD dwScheduleType);
  141. DWORD ValidateRemoteSysInfo(LPTSTR szServer, LPTSTR szUser, LPTSTR szPassword,
  142. TCMDPARSER cmdOptions[] , TCREATESUBOPTS& tcresubops, TCREATEOPVALS &tcreoptvals);
  143. DWORD ValidateModifierVal(LPCTSTR szModifier, DWORD dwScheduleType,
  144. DWORD dwModOptActCnt, DWORD dwDayOptCnt,
  145. DWORD dwMonOptCnt, BOOL &bIsDefltValMod);
  146. DWORD ValidateDayAndMonth(LPTSTR szDay, LPTSTR szMonths, DWORD dwSchedType,
  147. DWORD dwDayOptCnt, DWORD dwMonOptCnt, DWORD dwModifier,LPTSTR szModifier);
  148. DWORD ValidateStartDate(LPTSTR szStartDate, DWORD dwSchedType, DWORD dwStDtOptCnt,
  149. BOOL &bIsCurrentDate);
  150. DWORD ValidateEndDate(LPTSTR szEndDate, DWORD dwSchedType, DWORD dwEndDtOptCnt);
  151. DWORD ValidateStartTime(LPTSTR szStartTime, DWORD dwSchedType, DWORD dwStTimeOptCnt,
  152. BOOL &bIsCurrentTime);
  153. DWORD ValidateIdleTimeVal(LPTSTR szIdleTime, DWORD dwSchedType,
  154. DWORD dwIdlTimeOptCnt);
  155. DWORD ValidateDateString(LPTSTR szDate);
  156. DWORD ValidateTimeString(LPTSTR szTime);
  157. DWORD GetDateFieldEntities(LPTSTR szDate, WORD* pdwDate, WORD* pdwMon,
  158. WORD* pdwYear);
  159. DWORD ValidateDateFields( DWORD dwDate, DWORD dwMon, DWORD dwyear);
  160. DWORD GetTimeFieldEntities(LPTSTR szTime, WORD* pdwHours, WORD* pdwMins,
  161. WORD* pdwSecs);
  162. DWORD ValidateTimeFields( DWORD dwHours, DWORD dwMins, DWORD dwSecs);
  163. WORD GetTaskTrigwDayForDay(LPTSTR szDay);
  164. WORD GetTaskTrigwMonthForMonth(LPTSTR szMonth);
  165. DWORD ValidateMonth(LPTSTR szMonths);
  166. DWORD ValidateDay(LPTSTR szDays);
  167. WORD GetMonthId(DWORD dwMonthId);
  168. DWORD GetNumDaysInaMonth(TCHAR* szMonths, WORD wStartYear);
  169. BOOL VerifyJobName(_TCHAR* pszJobName);
  170. DWORD GetDateFieldFormat(WORD* pdwDate);
  171. DWORD GetDateFormatString(LPTSTR szFormat);
  172. DWORD ProcessFilePath(LPTSTR szInput,LPTSTR szFirstString,LPTSTR szSecondString);
  173. #endif // __CREATE_H