#ifndef _APPT_H
#define _APPT_H

/* How long messages can be.*/
#define MAX_MESSAGE_LEN 15
#define LARGE_SIZE 256

/* What an appointment looks like.*/
typedef struct AppType {
    ClockTime startTime;	/* The appointment start time.*/
    ClockTime endTime;		/* The appointment end time.*/
    char message[MAX_MESSAGE_LEN]; /* The appointment message. */
    boolean fixed;		/* Whether the time is fixed.*/
}Appointment;

/* ReadString
 *----------------------------------------------------------------
 * Read a string from an open file (or stdin) and discard the rest of the 
line.
 * It returns EOF if encountered. (We don't use this when reading from stdin,
 * a more robust version of this code would.)
 */
int
ReadString(char *buf, int size, FILE *f);

/* ApptInit
 *----------------------------------------------------------------
 * Initializes an appointment by setting the message to be an
 * empty message.
 */
void
ApptInit(Appointment *app);

/* Empty
 *----------------------------------------------------------------
 * Returns true if the appointment is empty, false otherwise.
 */
boolean
Empty(Appointment app);

/* SetAppt
 *----------------------------------------------------------------
 * Set all the fields of an appointment
 */
void
SetAppt(Appointment *app, ClockTime startTime, ClockTime endTime,
	char *message, boolean fixed);

/* SetStartTime
 *----------------------------------------------------------------
 * Set the start time of an appointment.
 */
void
SetStartTime(Appointment *app, ClockTime startTime);

/* SetEndTime
 *----------------------------------------------------------------
 * Set the end time of an appointment.
 */
void
SetEndTime(Appointment *app, ClockTime endTime);

/* GetStartTime
 *----------------------------------------------------------------
 * Returns the appointment's start time.
 */
ClockTime
GetStartTime(Appointment app);

/* GetEndTime
 *----------------------------------------------------------------
 * Returns the appointment's end time.
 */
ClockTime
GetEndTime(Appointment app);

/* GetMessage
 * Returns the appointment's message.
 * Need to pass the point to an appointment because otherwise we
 * try to return the address of something on the stack.
 */
char *
GetMessage(Appointment *app);

/* ClearAppt
 *----------------------------------------------------------------
 * Clear's an appointment (by setting the message to an empty string).
 */
void
ClearAppt(Appointment *app);

/* PutAppointment
 *----------------------------------------------------------------
 * Print the contents of appointment appt.
 */
void
PutAppointment(Appointment appt);

/* SaveAppt
 *----------------------------------------------------------------
 * Save the appointment to the file savefile.
 */
void
SaveAppt(Appointment app, FILE *savefile);

/* LoadAppt
 *----------------------------------------------------------------
 * Load an appointment from the file savefile.
 * Returns EOF if end of file is encountered.
 */
int
LoadAppt(Appointment *app, FILE *savefile);
#endif
