Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

gwcrontab.c File Reference

Handlers for cron-like data for scheduling jobs. More...

#include "gwcrontab.h"
#include "daemon.h"
#include "log.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <syslog.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <assert.h>

Defines

#define debug(prg)   { if (debug_flag) { prg } }
 Run debug code if debugging is enabled.


Functions

gwcron_job * get_first_job (gwcron_job *queue, int time)
 Return the first job in the queue due to be executed from the current time onwards.

int append_job (gwcron_job **queue, int time, const char *cmd)
 Add a job into a job queue, inserting it into the linked list at the right chronological point.

void flush_jobs (gwcron_job *queue)
 Clear up and free all the entries in a job queue.

void dump_jobs (gwcron_job *job)
 Dump a job queue to standard out for debug purposes.

int read_crontab ()
 Read in the jobs file and parse it into a chronologically ordered single linked list.

int read_minutes (struct timeval *tv)
 Calculate the number of minutes into the day the given time is.

int read_day (struct timeval *tv)
 Determine the day of the year we are on.


Variables

const int debug_flag = 0
 Control whether debug code is run.

const char * etc_directory = ETCDIR
 Directory where config files are stored.

const char * crontab_file = "/gwcrontab"
 File name of config file containing jobs list.

gwcron_job * job_queue = NULL
 Pointer to chronologically ordered linked list of daily jobs.


Detailed Description

Handlers for cron-like data for scheduling jobs.

Copyright (C) 2004 Alistair Riddoch, The University of Southampton


Function Documentation

int append_job gwcron_job **  queue,
int  time,
const char *  cmd
 

Add a job into a job queue, inserting it into the linked list at the right chronological point.

Parameters:
queue pointer to pointer to start of the job queue.
time in minutes when the job should be run each day.
cmd string of the commandline to be run to do the job.
Returns:
one if an error occured, zero otherwise.

gwcron_job* get_first_job gwcron_job *  queue,
int  time
 

Return the first job in the queue due to be executed from the current time onwards.

This should be called whenever the config file has been read in.

Parameters:
queue pointer to the start of the job queue.
time the current time of day in minutes.
Returns:
a pointer to the next due job, or NULL is no job is due for the rest of the day.

int read_day struct timeval *  tv  ) 
 

Determine the day of the year we are on.

Used to make sure we have got to the next day when there are no jobs left today.

Parameters:
tv pointer to time structure with the unix time.
Returns:
the day of the year.

int read_minutes struct timeval *  tv  ) 
 

Calculate the number of minutes into the day the given time is.

Parameters:
tv pointer to time structure with the unix time.
Returns:
the time in minutes since midnight.


Variable Documentation

const int debug_flag = 0 [static]
 

Control whether debug code is run.

Set to non-zero if debug code should be run.


Generated on Mon Aug 9 13:41:45 2004 for Glacsweb by doxygen 1.3.5