ReactOS 0.4.16-dev-2613-g9533ad7
at.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS AT utility
3 * COPYRIGHT: See COPYING in the top level directory
4 * FILE: base/applications/cmdutils/at/at.c
5 * PURPOSE: ReactOS AT utility
6 * PROGRAMMERS: Eric Kohl <eric.kohl@reactos.org>
7 */
8
9#include <stdlib.h>
10#include <stdio.h>
11
12#include <windef.h>
13#include <winbase.h>
14#include <wincon.h>
15#include <winnls.h>
16#include <lm.h>
17
18#include <conutils.h>
19
20#include "resource.h"
21
22
24
25
26static
27VOID
29{
30 WORD i;
31
32 for (i = 0; i < 7; i++)
33 {
36 }
37}
38
39
40static
41BOOL
43{
44 WORD i;
45
46 for (i = 0; i < 7; i++)
47 {
51 NULL,
52 0);
53
56 nLength * sizeof(WCHAR));
58 {
60 return FALSE;
61 }
62
66 nLength);
67 }
68
69 return TRUE;
70}
71
72
73static
74BOOL
76 PWSTR pszTime,
77 PULONG pulJobHour,
78 PULONG pulJobMinute)
79{
80 WCHAR szHour[3], szMinute[3], szAmPm[5];
81 PWSTR startPtr, endPtr;
82 ULONG ulHour = 0, ulMinute = 0;
84
85 if (pszTime == NULL)
86 return FALSE;
87
88 startPtr = pszTime;
89
90 /* Extract the hour string */
91 nLength = 0;
92 while (*startPtr != L'\0' && iswdigit(*startPtr))
93 {
94 if (nLength >= 2)
95 return FALSE;
96
97 szHour[nLength] = *startPtr;
98 nLength++;
99
100 startPtr++;
101 }
102 szHour[nLength] = L'\0';
103
104 /* Check for a valid time separator */
105 if (*startPtr != L':')
106 return FALSE;
107
108 /* Skip the time separator */
109 startPtr++;
110
111 /* Extract the minute string */
112 nLength = 0;
113 while (*startPtr != L'\0' && iswdigit(*startPtr))
114 {
115 if (nLength >= 2)
116 return FALSE;
117
118 szMinute[nLength] = *startPtr;
119 nLength++;
120
121 startPtr++;
122 }
123 szMinute[nLength] = L'\0';
124
125 /* Extract the optional AM/PM indicator string */
126 nLength = 0;
127 while (*startPtr != L'\0')
128 {
129 if (nLength >= 4)
130 return FALSE;
131
132 if (!iswspace(*startPtr))
133 {
134 szAmPm[nLength] = *startPtr;
135 nLength++;
136 }
137
138 startPtr++;
139 }
140 szAmPm[nLength] = L'\0';
141
142 /* Convert the hour string */
143 ulHour = wcstoul(szHour, &endPtr, 10);
144 if (ulHour == 0 && *endPtr != UNICODE_NULL)
145 return FALSE;
146
147 /* Convert the minute string */
148 ulMinute = wcstoul(szMinute, &endPtr, 10);
149 if (ulMinute == 0 && *endPtr != UNICODE_NULL)
150 return FALSE;
151
152 /* Check for valid AM/PM indicator */
153 if (wcslen(szAmPm) > 0 &&
154 _wcsicmp(szAmPm, L"a") != 0 &&
155 _wcsicmp(szAmPm, L"am") != 0 &&
156 _wcsicmp(szAmPm, L"p") != 0 &&
157 _wcsicmp(szAmPm, L"pm") != 0)
158 {
159 return FALSE;
160 }
161
162 /* Check for the valid minute range [0-59] */
163 if (ulMinute > 59)
164 return FALSE;
165
166 if (wcslen(szAmPm) > 0)
167 {
168 /* 12 hour time format */
169
170 /* Check for the valid hour range [1-12] */
171 if (ulHour == 0 || ulHour > 12)
172 return FALSE;
173
174 /* Convert 12 hour format to 24 hour format */
175 if (_wcsicmp(szAmPm, L"a") == 0 ||
176 _wcsicmp(szAmPm, L"am") == 0)
177 {
178 if (ulHour == 12)
179 ulHour = 0;
180 }
181 else
182 {
183 if (ulHour >= 1 && ulHour <= 11)
184 ulHour += 12;
185 }
186 }
187 else
188 {
189 /* 24 hour time format */
190
191 /* Check for the valid hour range [0-23] */
192 if (ulHour > 23)
193 return FALSE;
194 }
195
196 if (pulJobHour != NULL)
197 *pulJobHour = ulHour;
198
199 if (pulJobMinute != NULL)
200 *pulJobMinute = ulMinute;
201
202 return TRUE;
203}
204
205
206static
207BOOL
209 PWSTR pszId,
210 PULONG pulId)
211{
212 PWSTR startPtr, endPtr;
213 ULONG ulId = 0;
214 BOOL bResult = FALSE;
215
216 startPtr = pszId;
217 endPtr = NULL;
218 ulId = wcstoul(startPtr, &endPtr, 10);
219 if (endPtr != NULL && *endPtr == UNICODE_NULL)
220 {
221 bResult = TRUE;
222
223 if (pulId != NULL)
224 *pulId = ulId;
225 }
226
227 return bResult;
228}
229
230
231static
232BOOL
234 PWSTR pszBuffer,
235 PULONG pulDaysOfMonth)
236{
237 PWSTR startPtr, endPtr;
238 ULONG ulValue;
239
240 if (wcslen(pszBuffer) == 0)
241 return FALSE;
242
243 startPtr = pszBuffer;
244 endPtr = NULL;
245 for (;;)
246 {
247 ulValue = wcstoul(startPtr, &endPtr, 10);
248 if (ulValue == 0)
249 return FALSE;
250
251 if (ulValue > 0 && ulValue <= 31)
252 *pulDaysOfMonth |= (1 << (ulValue - 1));
253
254 if (endPtr != NULL && *endPtr == UNICODE_NULL)
255 return TRUE;
256
257 startPtr = endPtr + 1;
258 endPtr = NULL;
259 }
260
261 return FALSE;
262}
263
264
265static
266BOOL
268 PWSTR pszBuffer,
269 PUCHAR pucDaysOfWeek)
270{
271 PWSTR startPtr, endPtr;
272 size_t nLength;
273 WORD i;
274
275 if (wcslen(pszBuffer) == 0)
276 return FALSE;
277
278 startPtr = pszBuffer;
279 endPtr = NULL;
280 for (;;)
281 {
282 endPtr = wcschr(startPtr, L',');
283 if (endPtr == NULL)
284 nLength = wcslen(startPtr);
285 else
286 nLength = ((ULONG_PTR)endPtr - (ULONG_PTR)startPtr) / sizeof(WCHAR);
287
288 for (i = 0; i < 7; i++)
289 {
291 _wcsnicmp(startPtr, pszDaysOfWeekArray[i], nLength) == 0)
292 {
293 *pucDaysOfWeek |= (1 << i);
294 break;
295 }
296 }
297
298 if (endPtr == NULL)
299 return TRUE;
300
301 startPtr = endPtr + 1;
302 endPtr = NULL;
303 }
304
305 return FALSE;
306}
307
308
309static
310VOID
312 DWORD dwError)
313{
315}
316
317
318static
319VOID
321{
322 WCHAR szBuffer[80];
323 WORD i;
324
325 for (i = 0; i < 79; i++)
326 szBuffer[i] = L'-';
327 szBuffer[79] = UNICODE_NULL;
328
329 ConPrintf(StdOut, L"%s\n", szBuffer);
330}
331
332
333static
334BOOL
336{
337 WCHAR szYesBuffer[8];
338 WCHAR szNoBuffer[8];
339 WCHAR szInput[80];
340 DWORD dwOldMode;
341 DWORD dwRead = 0;
342 BOOL ret = FALSE;
344
345 LoadStringW(NULL, IDS_CONFIRM_YES, szYesBuffer, _countof(szYesBuffer));
346 LoadStringW(NULL, IDS_CONFIRM_NO, szNoBuffer, _countof(szNoBuffer));
347
348 ZeroMemory(szInput, sizeof(szInput));
349
351 GetConsoleMode(hFile, &dwOldMode);
352
354
355 for (;;)
356 {
358
359 ReadConsoleW(hFile, szInput, _countof(szInput), &dwRead, NULL);
360
361 szInput[0] = towupper(szInput[0]);
362 if (szInput[0] == szYesBuffer[0])
363 {
364 ret = TRUE;
365 break;
366 }
367 else if (szInput[0] == 13 || szInput[0] == szNoBuffer[0])
368 {
369 ret = FALSE;
370 break;
371 }
372
374 }
375
376 SetConsoleMode(hFile, dwOldMode);
377
378 return ret;
379}
380
381
382static
385{
387 DWORD_PTR JobTime;
388
390
391 JobTime = (DWORD_PTR)Time.wHour * 3600000 +
392 (DWORD_PTR)Time.wMinute * 60000;
393
394 return JobTime;
395}
396
397
398static
399ULONG
401{
403
405
406 return 1UL << (Time.wDay - 1);
407}
408
409
410static
411VOID
413 PWSTR pszBuffer,
415 WORD wHour,
416 WORD wMinute)
417{
418 SYSTEMTIME Time = {0, 0, 0, 0, 0, 0, 0, 0};
419
420 Time.wHour = wHour;
421 Time.wMinute = wMinute;
422
425 &Time,
426 NULL,
427 pszBuffer,
428 cchBuffer);
429}
430
431
432static
433INT
435 PWSTR pszComputerName,
436 ULONG ulJobId)
437{
439 DWORD_PTR CurrentTime;
440 WCHAR szStatusBuffer[16];
441 WCHAR szScheduleBuffer[60];
442 WCHAR szTimeBuffer[16];
443 WCHAR szInteractiveBuffer[16];
444 WCHAR szDateBuffer[8];
445 size_t nDateLength, nScheduleLength;
446 WORD i;
448
449 Status = NetScheduleJobGetInfo(pszComputerName,
450 ulJobId,
451 (PBYTE*)&pBuffer);
452 if (Status != NERR_Success)
453 {
455 return 1;
456 }
457
458 if (pBuffer->Flags & JOB_EXEC_ERROR)
459 LoadStringW(NULL, IDS_ERROR, szStatusBuffer, _countof(szStatusBuffer));
460 else
461 LoadStringW(NULL, IDS_OK, szStatusBuffer, _countof(szStatusBuffer));
462
463 if (pBuffer->DaysOfMonth != 0)
464 {
465 if (pBuffer->Flags & JOB_RUN_PERIODICALLY)
466 LoadStringW(NULL, IDS_EVERY, szScheduleBuffer, _countof(szScheduleBuffer));
467 else
468 LoadStringW(NULL, IDS_NEXT, szScheduleBuffer, _countof(szScheduleBuffer));
469
470 nScheduleLength = wcslen(szScheduleBuffer);
471 for (i = 0; i < 31; i++)
472 {
473 if (pBuffer->DaysOfMonth & (1 << i))
474 {
475 swprintf(szDateBuffer, L" %d", i + 1);
476 nDateLength = wcslen(szDateBuffer);
477 if (nScheduleLength + nDateLength <= 55)
478 {
479 wcscat(szScheduleBuffer, szDateBuffer);
480 nScheduleLength += nDateLength;
481 }
482 else
483 {
484 wcscat(szScheduleBuffer, L"...");
485 break;
486 }
487 }
488 }
489 }
490 else if (pBuffer->DaysOfWeek != 0)
491 {
492 if (pBuffer->Flags & JOB_RUN_PERIODICALLY)
493 LoadStringW(NULL, IDS_EVERY, szScheduleBuffer, _countof(szScheduleBuffer));
494 else
495 LoadStringW(NULL, IDS_NEXT, szScheduleBuffer, _countof(szScheduleBuffer));
496
497 nScheduleLength = wcslen(szScheduleBuffer);
498 for (i = 0; i < 7; i++)
499 {
500 if (pBuffer->DaysOfWeek & (1 << i))
501 {
502 swprintf(szDateBuffer, L" %s", pszDaysOfWeekArray[i]);
503 nDateLength = wcslen(szDateBuffer);
504 if (nScheduleLength + nDateLength <= 55)
505 {
506 wcscat(szScheduleBuffer, szDateBuffer);
507 nScheduleLength += nDateLength;
508 }
509 else
510 {
511 wcscat(szScheduleBuffer, L"...");
512 break;
513 }
514 }
515 }
516 }
517 else
518 {
519 CurrentTime = GetTimeAsJobTime();
520 if (CurrentTime > pBuffer->JobTime)
521 LoadStringW(NULL, IDS_TOMORROW, szScheduleBuffer, _countof(szScheduleBuffer));
522 else
523 LoadStringW(NULL, IDS_TODAY, szScheduleBuffer, _countof(szScheduleBuffer));
524 }
525
526 JobTimeToTimeString(szTimeBuffer,
527 _countof(szTimeBuffer),
528 (WORD)(pBuffer->JobTime / 3600000),
529 (WORD)((pBuffer->JobTime % 3600000) / 60000));
530
531 if (pBuffer->Flags & JOB_NONINTERACTIVE)
532 LoadStringW(NULL, IDS_NO, szInteractiveBuffer, _countof(szInteractiveBuffer));
533 else
534 LoadStringW(NULL, IDS_YES, szInteractiveBuffer, _countof(szInteractiveBuffer));
535
536 ConResPrintf(StdOut, IDS_TASKID, ulJobId);
537 ConResPrintf(StdOut, IDS_STATUS, szStatusBuffer);
538 ConResPrintf(StdOut, IDS_SCHEDULE, szScheduleBuffer);
539 ConResPrintf(StdOut, IDS_TIME, szTimeBuffer);
540 ConResPrintf(StdOut, IDS_INTERACTIVE, szInteractiveBuffer);
542
544
545 return 0;
546}
547
548
549static
550INT
552 PWSTR pszComputerName)
553{
555 DWORD dwRead = 0, dwTotal = 0;
556 DWORD dwResume = 0, i;
557 DWORD_PTR CurrentTime;
559 WCHAR szScheduleBuffer[32];
560 WCHAR szTimeBuffer[16];
561 WCHAR szDateBuffer[8];
562 size_t nDateLength, nScheduleLength;
563 WORD j;
564
565 Status = NetScheduleJobEnum(pszComputerName,
566 (PBYTE*)&pBuffer,
568 &dwRead,
569 &dwTotal,
570 &dwResume);
571 if (Status != NERR_Success)
572 {
574 return 1;
575 }
576
577 if (dwTotal == 0)
578 {
580 return 0;
581 }
582
585
586 for (i = 0; i < dwRead; i++)
587 {
588 if (pBuffer[i].DaysOfMonth != 0)
589 {
591 LoadStringW(NULL, IDS_EVERY, szScheduleBuffer, _countof(szScheduleBuffer));
592 else
593 LoadStringW(NULL, IDS_NEXT, szScheduleBuffer, _countof(szScheduleBuffer));
594
595 nScheduleLength = wcslen(szScheduleBuffer);
596 for (j = 0; j < 31; j++)
597 {
598 if (pBuffer[i].DaysOfMonth & (1 << j))
599 {
600 swprintf(szDateBuffer, L" %d", j + 1);
601 nDateLength = wcslen(szDateBuffer);
602 if (nScheduleLength + nDateLength <= 19)
603 {
604 wcscat(szScheduleBuffer, szDateBuffer);
605 nScheduleLength += nDateLength;
606 }
607 else
608 {
609 wcscat(szScheduleBuffer, L"...");
610 break;
611 }
612 }
613 }
614 }
615 else if (pBuffer[i].DaysOfWeek != 0)
616 {
618 LoadStringW(NULL, IDS_EVERY, szScheduleBuffer, _countof(szScheduleBuffer));
619 else
620 LoadStringW(NULL, IDS_NEXT, szScheduleBuffer, _countof(szScheduleBuffer));
621
622 nScheduleLength = wcslen(szScheduleBuffer);
623 for (j = 0; j < 7; j++)
624 {
625 if (pBuffer[i].DaysOfWeek & (1 << j))
626 {
627 swprintf(szDateBuffer, L" %s", pszDaysOfWeekArray[j]);
628 nDateLength = wcslen(szDateBuffer);
629 if (nScheduleLength + nDateLength <= 55)
630 {
631 wcscat(szScheduleBuffer, szDateBuffer);
632 nScheduleLength += nDateLength;
633 }
634 else
635 {
636 wcscat(szScheduleBuffer, L"...");
637 break;
638 }
639 }
640 }
641 }
642 else
643 {
644 CurrentTime = GetTimeAsJobTime();
645 if (CurrentTime > pBuffer[i].JobTime)
646 LoadStringW(NULL, IDS_TOMORROW, szScheduleBuffer, _countof(szScheduleBuffer));
647 else
648 LoadStringW(NULL, IDS_TODAY, szScheduleBuffer, _countof(szScheduleBuffer));
649 }
650
651 JobTimeToTimeString(szTimeBuffer,
652 _countof(szTimeBuffer),
653 (WORD)(pBuffer[i].JobTime / 3600000),
654 (WORD)((pBuffer[i].JobTime % 3600000) / 60000));
655
657 L" %6lu %-21s %-11s %s\n",
658 pBuffer[i].JobId,
659 szScheduleBuffer,
660 szTimeBuffer,
661 pBuffer[i].Command);
662 }
663
665
666 return 0;
667}
668
669
670static
671INT
673 PWSTR pszComputerName,
674 ULONG ulJobHour,
675 ULONG ulJobMinute,
676 ULONG ulDaysOfMonth,
677 UCHAR ucDaysOfWeek,
678 BOOL bInteractiveJob,
679 BOOL bPeriodicJob,
680 PWSTR pszCommand)
681{
682 AT_INFO InfoBuffer;
683 ULONG ulJobId = 0;
685
686 InfoBuffer.JobTime = (DWORD_PTR)ulJobHour * 3600000 +
687 (DWORD_PTR)ulJobMinute * 60000;
688 InfoBuffer.DaysOfMonth = ulDaysOfMonth;
689 InfoBuffer.DaysOfWeek = ucDaysOfWeek;
690 InfoBuffer.Flags = (bInteractiveJob ? 0 : JOB_NONINTERACTIVE) |
691 (bPeriodicJob ? JOB_RUN_PERIODICALLY : 0);
692 InfoBuffer.Command = pszCommand;
693
694 Status = NetScheduleJobAdd(pszComputerName,
695 (PBYTE)&InfoBuffer,
696 &ulJobId);
697 if (Status != NERR_Success)
698 {
700 return 1;
701 }
702
704
705 return 0;
706}
707
708
709static
710INT
712 PWSTR pszComputerName,
713 ULONG ulJobId,
714 BOOL bForceDelete)
715{
717
718 if (ulJobId == (ULONG)-1 && bForceDelete == FALSE)
719 {
721 if (!Confirm())
722 return 0;
723 }
724
725 Status = NetScheduleJobDel(pszComputerName,
726 (ulJobId == (ULONG)-1) ? 0 : ulJobId,
727 (ulJobId == (ULONG)-1) ? -1 : ulJobId);
728 if (Status != NERR_Success)
729 {
731 return 1;
732 }
733
734 return 0;
735}
736
737
738int wmain(int argc, WCHAR **argv)
739{
740 PWSTR pszComputerName = NULL;
741 PWSTR pszCommand = NULL;
742 ULONG ulJobId = (ULONG)-1;
743 ULONG ulJobHour = (ULONG)-1;
744 ULONG ulJobMinute = (ULONG)-1;
745 BOOL bDeleteJob = FALSE, bForceDelete = FALSE;
746 BOOL bInteractiveJob = FALSE, bPeriodicJob = FALSE;
747 BOOL bPrintUsage = FALSE;
748 ULONG ulDaysOfMonth = 0;
749 UCHAR ucDaysOfWeek = 0;
750 INT nResult = 0;
751 INT i, minIdx;
752
753 /* Initialize the Console Standard Streams */
755
756 if (!InitDaysOfWeekArray())
757 return 1;
758
759 /* Parse the computer name */
760 i = 1;
761 minIdx = 1;
762 if (i < argc &&
763 argv[i][0] == L'\\' &&
764 argv[i][1] == L'\\')
765 {
766 pszComputerName = argv[i];
767 i++;
768 minIdx++;
769 }
770
771 /* Parse the time or job id */
772 if (i < argc && argv[i][0] != L'/')
773 {
774 if (ParseTime(argv[i], &ulJobHour, &ulJobMinute))
775 {
776 i++;
777 minIdx++;
778 }
779 else if (ParseId(argv[i], &ulJobId))
780 {
781 i++;
782 minIdx++;
783 }
784 }
785
786 /* Parse the options */
787 for (; i < argc; i++)
788 {
789 if (argv[i][0] == L'/')
790 {
791 if (_wcsicmp(argv[i], L"/?") == 0)
792 {
793 bPrintUsage = TRUE;
794 goto done;
795 }
796 else if (_wcsicmp(argv[i], L"/delete") == 0)
797 {
798 bDeleteJob = TRUE;
799 }
800 else if (_wcsicmp(argv[i], L"/yes") == 0)
801 {
802 bForceDelete = TRUE;
803 }
804 else if (_wcsicmp(argv[i], L"/interactive") == 0)
805 {
806 bInteractiveJob = TRUE;
807 }
808 else if (_wcsnicmp(argv[i], L"/every:", 7) == 0)
809 {
810 bPeriodicJob = TRUE;
811 if (ParseDaysOfMonth(&(argv[i][7]), &ulDaysOfMonth) == FALSE)
812 {
813 if (ParseDaysOfWeek(&(argv[i][7]), &ucDaysOfWeek) == FALSE)
814 {
815 ulDaysOfMonth = GetCurrentDayOfMonth();
816 }
817 }
818 }
819 else if (_wcsnicmp(argv[i], L"/next:", 6) == 0)
820 {
821 bPeriodicJob = FALSE;
822 if (ParseDaysOfMonth(&(argv[i][6]), &ulDaysOfMonth) == FALSE)
823 {
824 if (ParseDaysOfWeek(&(argv[i][6]), &ucDaysOfWeek) == FALSE)
825 {
826 ulDaysOfMonth = GetCurrentDayOfMonth();
827 }
828 }
829 }
830 else
831 {
832 bPrintUsage = TRUE;
833 nResult = 1;
834 goto done;
835 }
836 }
837 }
838
839 /* Parse the command */
840 if (argc > minIdx && argv[argc - 1][0] != L'/')
841 {
842 pszCommand = argv[argc - 1];
843 }
844
845 if (bDeleteJob == TRUE)
846 {
847 /* Check for invalid options or arguments */
848 if (bInteractiveJob == TRUE ||
849 ulJobHour != (ULONG)-1 ||
850 ulJobMinute != (ULONG)-1 ||
851 ulDaysOfMonth != 0 ||
852 ucDaysOfWeek != 0 ||
853 pszCommand != NULL)
854 {
855 bPrintUsage = TRUE;
856 nResult = 1;
857 goto done;
858 }
859
860 nResult = DeleteJob(pszComputerName,
861 ulJobId,
862 bForceDelete);
863 }
864 else
865 {
866 if (ulJobHour != (ULONG)-1 && ulJobMinute != (ULONG)-1)
867 {
868 /* Check for invalid options or arguments */
869 if (bForceDelete == TRUE ||
870 pszCommand == NULL)
871 {
872 bPrintUsage = TRUE;
873 nResult = 1;
874 goto done;
875 }
876
877 nResult = AddJob(pszComputerName,
878 ulJobHour,
879 ulJobMinute,
880 ulDaysOfMonth,
881 ucDaysOfWeek,
882 bInteractiveJob,
883 bPeriodicJob,
884 pszCommand);
885 }
886 else
887 {
888 /* Check for invalid options or arguments */
889 if (bForceDelete == TRUE ||
890 bInteractiveJob == TRUE ||
891 ulDaysOfMonth != 0 ||
892 ucDaysOfWeek != 0 ||
893 pszCommand != NULL)
894 {
895 bPrintUsage = TRUE;
896 nResult = 1;
897 goto done;
898 }
899
900 if (ulJobId == (ULONG)-1)
901 {
902 nResult = PrintAllJobs(pszComputerName);
903 }
904 else
905 {
906 nResult = PrintJobDetails(pszComputerName,
907 ulJobId);
908 }
909 }
910 }
911
912done:
914
915 if (bPrintUsage == TRUE)
917
918 return nResult;
919}
920
921/* EOF */
static DWORD_PTR GetTimeAsJobTime(VOID)
Definition: at.c:384
static BOOL ParseId(PWSTR pszId, PULONG pulId)
Definition: at.c:208
static BOOL ParseTime(PWSTR pszTime, PULONG pulJobHour, PULONG pulJobMinute)
Definition: at.c:75
static INT PrintJobDetails(PWSTR pszComputerName, ULONG ulJobId)
Definition: at.c:434
static INT PrintAllJobs(PWSTR pszComputerName)
Definition: at.c:551
static BOOL ParseDaysOfWeek(PWSTR pszBuffer, PUCHAR pucDaysOfWeek)
Definition: at.c:267
static VOID JobTimeToTimeString(PWSTR pszBuffer, INT cchBuffer, WORD wHour, WORD wMinute)
Definition: at.c:412
static BOOL Confirm(VOID)
Definition: at.c:335
static VOID PrintHorizontalLine(VOID)
Definition: at.c:320
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:311
static BOOL ParseDaysOfMonth(PWSTR pszBuffer, PULONG pulDaysOfMonth)
Definition: at.c:233
static ULONG GetCurrentDayOfMonth(VOID)
Definition: at.c:400
static VOID FreeDaysOfWeekArray(VOID)
Definition: at.c:28
static INT DeleteJob(PWSTR pszComputerName, ULONG ulJobId, BOOL bForceDelete)
Definition: at.c:711
static BOOL InitDaysOfWeekArray(VOID)
Definition: at.c:42
PWSTR pszDaysOfWeekArray[7]
Definition: at.c:23
#define IDS_NO_ENTRIES
Definition: resource.h:8
#define IDS_EVERY
Definition: resource.h:12
#define IDS_USAGE
Definition: resource.h:3
#define IDS_TASKID
Definition: resource.h:21
#define IDS_TIME
Definition: resource.h:24
#define IDS_ERROR
Definition: resource.h:18
#define IDS_YES
Definition: resource.h:16
#define IDS_NO
Definition: resource.h:17
#define IDS_NEW_JOB
Definition: resource.h:6
#define IDS_CONFIRM_YES
Definition: resource.h:30
#define IDS_STATUS
Definition: resource.h:22
#define IDS_INTERACTIVE
Definition: resource.h:25
#define IDS_CONFIRM_QUESTION
Definition: resource.h:28
#define IDS_TOMORROW
Definition: resource.h:11
#define IDS_TODAY
Definition: resource.h:10
#define IDS_OK
Definition: resource.h:19
#define IDS_CONFIRM_NO
Definition: resource.h:31
#define IDS_SCHEDULE
Definition: resource.h:23
#define IDS_JOBS_LIST
Definition: resource.h:7
#define IDS_CONFIRM_INVALID
Definition: resource.h:29
#define IDS_COMMAND
Definition: resource.h:26
#define IDS_NEXT
Definition: resource.h:13
#define IDS_DELETE_ALL
Definition: resource.h:5
static WORD DaysOfMonth(WORD wMonth, WORD wYear)
Definition: job.c:456
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define ConInitStdStreams()
Definition: conutils_noros.h:5
void ConPrintf(FILE *fp, LPCWSTR psz,...)
#define StdOut
Definition: conutils_noros.h:6
void ConResPrintf(FILE *fp, UINT nID,...)
#define StdErr
Definition: conutils_noros.h:7
void ConResPuts(FILE *fp, UINT nID)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static DWORD cchBuffer
Definition: fusion.c:85
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleW(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1174
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
MonoAssembly int argc
Definition: metahost.c:107
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2912
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:195
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define JOB_EXEC_ERROR
Definition: atsvc.idl:35
#define JOB_NONINTERACTIVE
Definition: atsvc.idl:38
#define JOB_RUN_PERIODICALLY
Definition: atsvc.idl:34
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
#define NERR_Success
Definition: lmerr.h:5
#define ZeroMemory
Definition: minwinbase.h:31
static PLARGE_INTEGER Time
Definition: time.c:105
#define argv
Definition: mplay32.c:18
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
#define LOCALE_USER_DEFAULT
#define UNICODE_NULL
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:835
BYTE * PBYTE
Definition: pedump.c:66
short WCHAR
Definition: pedump.c:58
PVOID pBuffer
int wmain()
NET_API_STATUS WINAPI NetScheduleJobGetInfo(LPCWSTR ServerName, DWORD JobId, LPBYTE *PointerToBuffer)
Definition: schedule.c:174
NET_API_STATUS WINAPI NetScheduleJobAdd(LPCWSTR ServerName, LPBYTE Buffer, LPDWORD JobId)
Definition: schedule.c:76
NET_API_STATUS WINAPI NetScheduleJobDel(LPCWSTR ServerName, DWORD MinJobId, DWORD MaxJobId)
Definition: schedule.c:104
NET_API_STATUS WINAPI NetScheduleJobEnum(LPCWSTR ServerName, LPBYTE *PointerToBuffer, DWORD PreferredMaximumLength, LPDWORD EntriesRead, LPDWORD TotalEntries, LPDWORD ResumeHandle)
Definition: schedule.c:132
#define iswspace(_c)
Definition: ctype.h:669
#define iswdigit(_c)
Definition: ctype.h:667
wcscat
#define LoadStringW
Definition: utils.h:64
#define towupper(c)
Definition: wctype.h:99
#define _countof(array)
Definition: sndvol32.h:70
Definition: shell.h:41
Definition: lmat.h:14
Definition: lmat.h:22
UCHAR Flags
Definition: lmat.h:26
LPWSTR Command
Definition: lmat.h:27
UCHAR DaysOfWeek
Definition: lmat.h:25
DWORD DaysOfMonth
Definition: lmat.h:24
DWORD JobTime
Definition: lmat.h:23
#define DWORD_PTR
Definition: treelist.c:76
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: typedefs.h:53
uint32_t DWORD_PTR
Definition: typedefs.h:65
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STD_INPUT_HANDLE
Definition: winbase.h:291
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
#define ENABLE_ECHO_INPUT
Definition: wincon.h:109
#define ENABLE_LINE_INPUT
Definition: wincon.h:108
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682
#define GetLocaleInfo
Definition: winnls.h:1358
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:91
#define GetTimeFormat
Definition: winnls.h:1361
#define TIME_NOSECONDS
Definition: winnls.h:296
#define AddJob
Definition: winspool.h:942
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170