/* account.h - definition of account records, and functions for mapping arrays of accounts to file.
 */

#ifndef ACCOUNT_H_
#define ACCOUNT_H_

typedef char account_id[8];    // The type for ids of accounts

typedef struct account {
  account_id id;         // id of an account
  unsigned long balance; // balance in cents of this account
} account_t;// The type for records in accounts table.


/* The content of an array of accounts is stored in ascii form in filedat, one record per line.
   If the file filebin exists, it contains the same array in binary form.
   If the file filebin does not exist, it is created. 
   In either case the file filebin is memory mapped into an array and the address of the array is
   returned. The number of records in array is returned through the pointer size.
 */
account_t *readin_accounts (const char * filedat, const char * filebin, int *size);

/* Write out accounts */
void write_accounts (const char * filename, int size, const account_t *accounts);

#endif
