.cal calendar file format

this topic describes the binary file format used by microsoft windows calendar (calendar.exe). a calendar binary file
contains information about file content, dates, days, and appointments.

calendar-file header

the first 8 bytes of a calendar file are a character array identifying the file as a calendar file. following are the contents of the

'c' + 'r' = b5
'a' + 'a' = a2
'l' + 'd' = b0
'e' + 'n' = b3
'n' + 'e' = b3
'd' + 'l' = b0
'a' + 'a' = a2
'r' + 'c' = b5

the next 2 bytes (cdatedescriptors) contain the integer count of dates described in the file.
the next 12 bytes contain six 2-byte fields of information that is global to the entire file. these variables are normally set by the
user through the alarm controls and options day dialog boxes. the header information has the following form:

word minearlyring
bool fsound
int interval
int mininterval
bool f24hourformat
int starttime

following are the members in the header structure:

minearlyring    specifies an early ring, in minutes.
fsound    specifies whether alarms should be audible.
interval    specifies the interval between appointments: 0 = 15 minutes, 1 = 30 minutes, 2 = 60 minutes.
mininterval    specifies the interval, in minutes.
f24hourformat    specifies the time format: nonzero=24-hour format.
starttime    specifies the starting time in day mode--that is, the time that normally appears first in the display, in minutes
past midnight.

the rest of the first 64 bytes are reserved.

date descriptors

a date-descriptor array appears next. each entry in the array describes one day. the number of entries in the array is
cdatedescriptors (described in the preceding section). each element in the array consists of 12 bytes, in six 2-byte fields.
the date-descriptor array has the following form:

unsigned date
int fmarked
int calarms
unsigned fileblockoffset
int reserved
unsigned reserved

following are the members in the date-descriptor array:

date    specifies the date, in days past 1/1/1980.
fmarked    specifies which mark(s) are set for the date: box = 128, parentheses = 256, circle = 512, cross = 1024,
underscore = 2048.
calarms    specifies the number of alarms set for the day.
fileblockoffset    specifies the file offset, in 64-byte blocks, to the day's information. only the low 15 bits are used (the high bit
will be zero). thus, if this offset is 6, the day's information is stored at byte 6*64 in the file.
reserved    reserved; must be 0xfff.
reserved    reserved; must be 0xfff.

day-specific information

all day information is stored after the date-descriptor array, on even 64-byte boundaries. the day-information structure has the
following form:

unsigned reserved
unsigned date
unsigned reserved
unsigned cbnotes
unsigned cbappointment
char notes[cbnotes]
byte apptinfo[]

following are the members in the day-information structure:

reserved    reserved; must be zero.
date    specifies the date, in days past 1/1/1980.
reserved    reserved; must be 1.
cbnotes    specifies the number of bytes of note information, including null bytes. this information appears in the note
array below the appointment list.
cbappointment    specifies the count of bytes of appointment information.
notes    contains the text of the note.
apptinfo    contains the block of appointments.

appointment-specific information

the information in the appointment block is stored as a list of single appointments. each appointment consists of a structure
similar to the following:

struct {
char cb;
char flags;
int time;
char szapptdesc[];

following are the members in each appointment structure:

cb    specifies the size, in bytes, of the structure containing the appointment. the structure address of the next
appointment is the current appointment plus the value of the cb member.
flags    contains various flags. this member can have one or more of the following values:

value    meaning

1    alarm will go off at the specified time of the appointment.
2    appointment is a special time.

time    specifies the number of minutes past midnight.
szapptdesc    contains a null-terminated string consisting of text associated with an appointment.