/****
 *
 * This is an example of using structs and arrays to create a database of
 * student information records.  A student record is a struct, and the database
 * is an array of these structs.
 *
 * For CSC 101, an array is a reasonable approximation of a database.  However,
 * using an array for a database is a significant simplification of how real
 * databases are stored in computer programs.  There are in fact several CSC
 * classes devoted databases, starting with CSC 365.  Databases are a big
 * subject in computer science.
 *
 */
#define MAX_DB_SIZE 100000
#define LARGE_STRING_SIZE 50
#define SMALL_STRING_SIZE 10
#define STATE_STRING_SIZE 3

/**
 * The Address type has the information for a student's home address.  This
 * consists of the number, street, city, state, and zip code.
 */

typedef struct {
    int number;
    char street[LARGE_STRING_SIZE];
    char city[LARGE_STRING_SIZE];
    char state[STATE_STRING_SIZE];
    int zip;
} Address;

/**
 * The Phone type has the information for a phone number.  This consists of the
 * area code and the number itself.
 */
typedef struct {
    int area_code;
    int number;
} Phone;

/**
 * The StudentRecord type has the information for a student stored in the
 * student information database.  A StudentRecord consists the following data
 * fields: last name; first and middle names; EMPL ID; computer user name;
 * major; address; phone number.
 */

typedef struct {
    char last_name[LARGE_STRING_SIZE];
    char first_and_middle_names[LARGE_STRING_SIZE];
    int empl_id;
    char user_name[SMALL_STRING_SIZE];
    char major[SMALL_STRING_SIZE];
    Address address;
    Phone phone;
} StudentRecord;

/**
 * The StudentDB type is a database of student records.   It's an array of
 * MAX_DB_SIZE.
 */
typedef StudentRecord StudentDB[MAX_DB_SIZE];


/**
 * Create an Address containing the values given in the parameters.
 */
Address create_address(
    int number, char* street, char* city, char* state, int zip);

/**
 * Create a Phone number containing the values given in the parameters.
 */
Phone create_phone(int area_code, int number);

/**
 * Create a StudentRecord containing the values given in the parameters.
 */
StudentRecord create_student_record(
	char* last_name, char* first_and_middle_names, int empl_id,
	char* user_name, char* major, Address address, Phone phone);

/**
 * Print a student record to stdout.
 */
void print_student_record(StudentRecord rec);

/**
 * Find a student record by unique empl id.  Return the record of the given
 * empl_id if found, an EMPTY_STUDENT_RECORD otherwise.
 */
StudentRecord find_student_record(StudentDB db, int empl_id);

#define EMPTY_STUDENT_RECORD {"", "", 0, "", "", {0, "", "", "", 0}, {0, 0}}