include/schedule.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  _actionStruct
struct  _actionNode
struct  _valStruct
struct  _scheduleStruct
struct  _scheduleNode
struct  _eventStruct
struct  _scheduledExec

Typedefs

typedef struct _actionStruct actionDef
typedef struct _actionNode actionNode
typedef struct _valStruct valueStruct
typedef struct _scheduleStruct scheduleEntry
typedef struct _scheduleNode scheduleNode
typedef struct _eventStruct eventEntry
typedef struct _scheduledExec scheduledExec
typedef enum BoolEnum Bool

Enumerations

enum  ActionType { ON_DEMAND, DEFAULT, ALWAYS, PRIVATE }
enum  ValType { WILDCARD, SINGLE, LIST, RANGE }
enum  BoolEnum { False, True }

Functions

void displaySchedule (FILE *out)
void displayTodaysSchedule (FILE *out)
void runNotifications ()
time_t calcNextTimeForTask (scheduleEntry *entry)
scheduledExeccalcNextTaskAlarm ()
int addScheduleEntry (int year, int month, int dayOfMonth, int dayOfWeek, int hour, int minute, int duration, const char *task, const char *reminder, actionNode *actionSet)
int addScheduleEntryAdv (valueStruct *year, valueStruct *month, valueStruct *dayOfMonth, valueStruct *dayOfWeek, valueStruct *hour, valueStruct *minute, int duration, const char *task, const char *reminder)
int addScheduleEntryNormalize (valueStruct *year, valueStruct *month, valueStruct *dayOfMonth, valueStruct *dayOfWeek, valueStruct *hour, valueStruct *minute, int duration, const char *task, const char *reminder, actionNode *actionSet)
scheduleEntrycreateScheduleEntry (int year, int month, int dayOfMonth, int dayOfWeek, int hour, int minute, int duration, const char *task, const char *reminder)
scheduleEntrycreateScheduleEntryAdv (valueStruct *year, valueStruct *month, valueStruct *dayOfMonth, valueStruct *dayOfWeek, valueStruct *hour, valueStruct *minute, int duration, const char *task, const char *reminder)
void freeScheduleEntry (scheduleEntry *entry)
void setTestTime (time_t time)
valueStructcreateSingleValue (int value)
valueStructcreateRangeValue (int begin, int end, int step)
valueStructcreateWildcardValue ()
valueStructcreateListValue (valueStruct *value)
void addListValue (valueStruct *list, valueStruct *value)
void freeValueStruct (valueStruct *value)
void freeValueStructList (valueStruct *value)
actionDefcreateActionCommand (char *commandName, char *commandStr, enum ActionType type)
actionDeffindActionCommand (char *commandName)
void addActionCommand (char *commandName, char *commandStr, enum ActionType type)
actionNodecreateActionSet (actionDef *action)
void addActionToActionSet (actionNode *node, actionDef *action)
void executeScheduledEntry (scheduledExec *task)

Typedef Documentation

typedef struct _actionStruct actionDef

Defines an action that is available for scheduling.

typedef struct _actionNode actionNode

Linked list node used to create a list of actions.

typedef enum BoolEnum Bool
typedef struct _eventStruct eventEntry
typedef struct _scheduledExec scheduledExec

Represents a complete schedule entry including:

  • schedule at which action set will be performed
  • expected length of task
  • description of task
  • set of actions to perform
typedef struct _scheduleNode scheduleNode

List of scheduleEntry instances.

typedef struct _valStruct valueStruct

Defines each calendar value: year, day of month, hour, ... Each may be a wildcard or a value. Values include:

  • single value (3)
  • range (3 - 6) with optional interval (3 - 6/2)
  • list of calendar values (3,5-7,9)

Enumeration Type Documentation

enum ActionType

Action Type - Attribute describing execution aspect of Action: ON_DEMAND - Must be specified on task to execute. DEFAULT - Will be executed if no other actions are specified for the task ALWAYS - Will be executed for every task regardless of what other actions are specified. PRIVATE - Non-global action. All actions defined at the task level are unnamed and private.

Enumerator:
ON_DEMAND 
DEFAULT 
ALWAYS 
PRIVATE 
enum BoolEnum
Enumerator:
False 
True 
enum ValType

Calendar entry value types.

  • WILDCARD: Used to allow any value within the applicable range.
  • SINGLE: Value represents a single entry within the applicable range.
  • LIST: Value is a list of SINGLES and/or RANGES
  • RANGE: Value is a inclusive range from x to y with an optional step value.
Enumerator:
WILDCARD 
SINGLE 
LIST 
RANGE 

Function Documentation

void addActionCommand ( char *  commandName,
char *  commandStr,
enum ActionType  type 
)

Create and add to the action set, a new action command.

Add a command string to the current list of reminder commands.

void addActionToActionSet ( actionNode node,
actionDef action 
)

Create and add to the action set, a new action command.

Add an action to a provided set of actions.

void addListValue ( valueStruct list,
valueStruct value 
)

Add a value to an the list provided.

int addScheduleEntry ( int  year,
int  month,
int  dayOfMonth,
int  dayOfWeek,
int  hour,
int  minute,
int  duration,
const char *  task,
const char *  reminder,
actionNode actionSet 
)

Add a schedule entry to the list of entries using the values provided. Args: year 4 digit year or -1 for wildcard month Valid values: 1 - 12 or -1 for wildcard dayOfMonth Valid values: 1 - 31 or -1 for wildcard dayOfWeek Valid values: 1 - 7 or -1 for wildcard 1 is equal to Sunday hour Valid values: 0 - 23 or -1 for wildcard minute Valid values: 0 - 59 duration Duration of task in minutes task Null terminated string containing task description reminder Null terminated string containing reminder message Returns: SUCCESS if entry created. ERROR if error occurred during add. Entry was not created.

int addScheduleEntryAdv ( valueStruct year,
valueStruct month,
valueStruct dayOfMonth,
valueStruct dayOfWeek,
valueStruct hour,
valueStruct minute,
int  duration,
const char *  task,
const char *  reminder 
)

Add a schedule entry to the list of entries using the values provided. Args: year 4 digit year or -1 for wildcard month Valid values: 1 - 12 or -1 for wildcard dayOfMonth Valid values: 1 - 31 or -1 for wildcard dayOfWeek Valid values: 1 - 7 or -1 for wildcard 1 is equal to Sunday hour Valid values: 0 - 23 or -1 for wildcard minute Valid values: 0 - 59 duration Duration of task in minutes task Null terminated string containing task description reminder Null terminated string containing reminder message Returns: SUCCESS if entry created. ERROR if error occurred during add. Entry was not created.

Add a schedule entry to the list of entries using the values provided. Args: year 4 digit year month Valid values: 0 - 11 dayOfMonth Valid values: 1 - 31 dayOfWeek Valid values: 0 - 6 0 is equal to Sunday hour Valid values: 0 - 23 minute Valid values: 0 - 59 duration Duration of task in minutes task Null terminated string containing task description reminder Null terminated string containing reminder message Returns: SUCCESS if entry created. ERROR if error occurred during add. Entry was not created.

int addScheduleEntryNormalize ( valueStruct year,
valueStruct month,
valueStruct dayOfMonth,
valueStruct dayOfWeek,
valueStruct hour,
valueStruct minute,
int  duration,
const char *  task,
const char *  reminder,
actionNode actionSet 
)

Add a schedule entry to the list of entries using the values provided. Args: year 4 digit year month Valid values: 1 - 12 dayOfMonth Valid values: 1 - 31 dayOfWeek Valid values: 1 - 7 1 is equal to Sunday hour Valid values: 0 - 23 minute Valid values: 0 - 59 duration Duration of task in minutes task Null terminated string containing task description reminder Null terminated string containing reminder message actionSet Root node of action set. May be NULL Returns: SUCCESS if entry created. ERROR if error occurred during add. Entry was not created.

scheduledExec* calcNextTaskAlarm (  ) 

Return next scheduled task and the time to execute that task. If no future tasks are scheduled, then a null value will be returned.

Returned value must be freed by caller.

time_t calcNextTimeForTask ( scheduleEntry entry  ) 

Returns the next time that the provided entry should be activated. If in the past, TIME_IN_PAST, a negative value wil be returned.

actionDef* createActionCommand ( char *  commandName,
char *  commandStr,
enum ActionType  type 
)

Create and return an instance of actionDef for the provided values.

Create a command

actionNode* createActionSet ( actionDef action  ) 

Create an action set and initialize using the provided action.

Create a new action set and populate with the provided action.

valueStruct* createListValue ( valueStruct value  ) 

Creates a list value valueStruct instance. Should be freed using freeValueStructList

valueStruct* createRangeValue ( int  begin,
int  end,
int  step 
)

Creates a range value valueStruct instance. Should be freed using freeValueStruct

scheduleEntry* createScheduleEntry ( int  year,
int  month,
int  dayOfMonth,
int  dayOfWeek,
int  hour,
int  minute,
int  duration,
const char *  task,
const char *  reminder 
)

Create a schedule entry using the values provided. Must be freed using freeScheduleEntry(entry *) Args: year 4 digit year or -1 for wildcard month Valid values: 0 - 11 or -1 for wildcard dayOfMonth Valid values: 1 - 31 or -1 for wildcard dayOfWeek Valid values: 0 - 6 or -1 for wildcard 0 is equal to Sunday hour Valid values: 0 - 23 or -1 for wildcard minute Valid values: 0 - 59 duration Duration of task in minutes task Null terminated string containing task description reminder Null terminated string containing reminder message Returns: Newly allocated and popluated schedule entry NULL if error occurred during creation

scheduleEntry* createScheduleEntryAdv ( valueStruct year,
valueStruct month,
valueStruct dayOfMonth,
valueStruct dayOfWeek,
valueStruct hour,
valueStruct minute,
int  duration,
const char *  task,
const char *  reminder 
)

Create a schedule entry using valueStruct entries for each of the time values. See valueStruct for more informaton regarding how values are specified.

Must be freed using freeScheduleEntry(entry *)

Args: year 4 digit year or wildcard month Valid values: 0 - 11 or wildcard dayOfMonth Valid values: 1 - 31 or wildcard dayOfWeek Valid values: 0 - 6 or wildcard 0 is equal to Sunday hour Valid values: 0 - 23 or wildcard minute Valid values: 0 - 59 duration Duration of task in minutes task Null terminated string containing task description reminder Null terminated string containing reminder message Returns: Newly allocated and popluated schedule entry NULL if error occurred during creation

Create a schedule entry using the values contained within valueStruct elements. This allows for more advanced scheduling by providing additional methods for specifying values. In addition to wildcard and single values, the following types may be used:

  • Ranges: start-end Example for hour: 9-17 is from 9am to 5pm Ranges may also include an interval
    • Intervals: start-stop/interval Example for day of month: 1/2 is every odd day
  • Lists: value,value,... Example for hour: 9,12,14-16 is 9,12,and between 2 and 4

NOTE: Must be freed using freeScheduleEntry(entry *)

Args: year - minute are valueStructs with the values constrained as shown below: year 4 digit year month Valid values: 0 - 11 dayOfMonth Valid values: 1 - 31 dayOfWeek Valid values: 0 - 6 0 is equal to Sunday hour Valid values: 0 - 23 minute Valid values: 0 - 59 duration Duration of task in minutes: 0 - max int. task Null terminated string containing task description reminder Null terminated string containing reminder message Returns: Newly allocated and popluated schedule entry NULL if error occurred during creation

valueStruct* createSingleValue ( int  value  ) 

Creates a single value valueStruct instance. Should be freed using freeValueStruct

valueStruct* createWildcardValue (  ) 

Creates a wildcard value valueStruct instance. Should be freed using freeValueStruct

void displaySchedule ( FILE *  out  ) 
void displayTodaysSchedule ( FILE *  out  ) 
void executeScheduledEntry ( scheduledExec task  ) 

Execute all actions associated with the scheduled task.

actionDef* findActionCommand ( char *  commandName  ) 

Find an exsiting actionDef given the command name.

Find an existing action command for the provided name.

void freeScheduleEntry ( scheduleEntry entry  ) 

Free the schedule entry and all associated allocations.

void freeValueStruct ( valueStruct value  ) 

Free the memory allocated for the valueStruct.

This will free the valueStruct and if it is a list, then it will recursively free all list members. If the top level List is allocated on the stack, then use freeValueStructList instead as it will not attempt to free the top level node.

void freeValueStructList ( valueStruct value  ) 

Free the memory allocated for a list valueStruct. This will free the list as well as all valueStruct instances within the list.

This will recursively free the members of the list, but not the top level item.

NOTE: If the top level List is allocated on the heap, then use freeValueStruct instead.

void runNotifications (  ) 
void setTestTime ( time_t  time  ) 

Set the current time for testing purposes.

Set fixed test time. Should be used for testing only.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Fri Mar 23 07:16:08 2012 for schedule by  doxygen 1.6.3