This set of functions may be used for parsing and checking login and
session times against a predefined list of allowed login times as
The format of allowed and disallowed session times specified in the
capability fields in a login class are comprised of a prefix which
specifies one or more 2- or 3-character day codes, followed by
a start and end time in 24 hour format separated by a hyphen.
Day codes may be concatenated together to select specific days, or
the special mnemonics "Any" and "All" (for any/all days of the week),
"Wk" for any day of the week (excluding Saturdays and Sundays) and
"Wd" for any weekend day may be used.
For example, the following time period:
is interpreted as Monday, Thursday through Saturday between the hours
of 2pm and 10pm.
means Saturday and Sunday, between the hours of 6am through 6pm, and
means any day of the week, between 4am and 4pm.
Note that all time periods reference system local time.
function converts the ASCII representation of a time period into
a structure of type
This is defined as:
typedef struct login_time
u_short lt_start; /* Start time */
u_short lt_end; /* End time */
u_char lt_dow; /* Days of week */
fields contain the number of minutes past midnight at which the
described period begins and ends.
field is a bit field, containing one bit for each day of the week
and one bit unused.
macros may be used for testing bits individually and in combination.
If no bits are set in this field - i.e., it contains the value
- then the entire period is assumed invalid.
This is used as a convention to mark the termination of an array
of login_time_t values.
then a parsing error was encountered.
The remaining functions provide the ability to test a given time_t or
struct tm value against a specific time period or array of time
function determines whether the given time described by the struct tm
passed as the second parameter falls within the period described
by the first parameter.
A boolean value is returned, indicating whether or not the time
specified falls within the period.
If the time does fall within the time period, and the third
parameter to the function is not NULL, the time at which the
period ends relative to the time passed is returned.
function is similar to
except that the first parameter must be a pointer to an array
of login_time_t objects, which is up to LC_MAXTIMES (64)
elements in length, and terminated by an element with its
field set to
functions are equivalent to
respectively, with the second argument set to the current time as