2 Unix SMB/Netbios implementation.
4 Samba utility functions
5 Copyright (C) Andrew Tridgell 1992-1999
6 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 static char *get_at_time_str(uint32 t)
27 static fstring timestr;
28 unsigned int hours, minutes, seconds;
36 slprintf(timestr, sizeof(timestr)-1, "%2d:%02d:%02d",
37 hours, minutes, seconds);
42 extern char *daynames_short[];
44 static char *get_at_days_str(uint32 monthdays, uint8 weekdays, uint8 flags)
51 if (monthdays == 0 && weekdays == 0)
54 if (flags & JOB_PERIODIC)
56 if (IS_BITS_SET_ALL(weekdays, 0x7F))
59 fstrcpy(days, "Every ");
63 fstrcpy(days, "Next ");
66 for (day = 1, bit = 1; day < 32; day++, bit <<= 1)
75 slprintf(numstr, sizeof(numstr)-1, "%d", day);
76 fstrcat(days, numstr);
80 for (day = 0, bit = 1; day < 7; day++, bit <<= 1)
89 fstrcat(days, daynames_short[day]);
96 /****************************************************************************
97 display scheduled jobs
98 ****************************************************************************/
99 void display_at_enum_info(FILE *out_hnd, enum action_type action,
100 uint32 num_jobs, const AT_ENUM_INFO *const jobs,
101 char *const *const commands)
109 report(out_hnd, "\tNo Jobs.\n");
113 report(out_hnd, "\tJobs:\n");
114 report(out_hnd, "\t-----\n");
118 case ACTION_ENUMERATE:
122 for (i = 0; i < num_jobs; i++)
124 const AT_JOB_INFO *const job = &jobs[i].info;
126 report(out_hnd, "\t%d\t%s\t%s\t%s\n",
128 get_at_time_str(job->time),
129 get_at_days_str(job->monthdays,
139 report(out_hnd, "\n");
145 /****************************************************************************
146 display information about a scheduled job
147 ****************************************************************************/
148 void display_at_job_info(FILE *out_hnd, enum action_type action,
149 AT_JOB_INFO *const job, fstring command)
155 report(out_hnd, "\tJob Information:\n");
156 report(out_hnd, "\t----------------\n");
159 case ACTION_ENUMERATE:
161 report(out_hnd, "\tTime: %s\n",
162 get_at_time_str(job->time));
164 report(out_hnd, "\tSchedule: %s\n",
165 get_at_days_str(job->monthdays, job->weekdays,
168 report(out_hnd, "\tStatus: %s",
169 (job->flags & JOB_EXEC_ERR) ? "Failed" : "OK");
171 if (job->flags & JOB_RUNS_TODAY)
173 report(out_hnd, ", Runs Today");
176 report(out_hnd, "\n\tInteractive: %s\n",
177 (job->flags & JOB_NONINTERACTIVE) ? "No"
180 report(out_hnd, "\tCommand: %s\n", command);
185 report(out_hnd, "\n");