Lots of changes, bug in read_person...

This commit is contained in:
2015-09-19 11:46:46 +02:00
parent 835c455762
commit a149928996
5 changed files with 132 additions and 86 deletions

View File

@@ -7,8 +7,8 @@
#define NUM_OF_PEOPLE 25
#define NUM_OF_DRINKS 10
#define DRINK_NAME_MAX_LENGTH 13
#define FILE_NAME_LEN 4
#define FILE_EXTENSION_LEN 4
#define FILE_NAME_LEN 8
#define FILE_EXTENSION_LEN 3
#define FILE_EXTENSION "per"
#define NAME_LEN 10
@@ -19,34 +19,25 @@ extern int __drinks_put_in;
extern char tmp_filename[];
typedef struct{
/*Drink spevifier*/
char name[DRINK_NAME_MAX_LENGTH + 1];
/*Value in cents*/
int price;
/*available quantity*/
int quantity;
}Drink;
typedef struct{
Drink drinks[NUM_OF_DRINKS];
int personCount;
}Beerbox;
typedef struct{
char file_name[FILE_NAME_LEN + 1];
char name[NAME_LEN + 1];
char rfid_uuid[13];
uint8_t finger_uuid;
int drinks_taken[NUM_OF_DRINKS];
}Person;
@@ -55,7 +46,8 @@ Beerbox* read_beerbox(Beerbox *box);
Beerbox* add_drink(Beerbox *box);
Person read_person(Beerbox *box, char *filename);
void print_person(Beerbox *box, Person *aperson);
int update_pers_file(Beerbox *box, Person *aperson);
char* read_line_from_file(FILE *stream, char *str, int max_len);
char* read_from_file_until(FILE *stream, char *str, int max_len, char until);
int update_pers_file(Beerbox *box, Person *aperson);
#endif