Finally fixed the mem issuecd beerbox/! Basic Reading,writing and counting now working

This commit is contained in:
2015-09-24 20:01:51 +02:00
parent e96cf8e996
commit 7e482344d2
3 changed files with 60 additions and 73 deletions

View File

@@ -6,11 +6,7 @@
#define FILE_EXTENSION "per"
#define NAME_LEN 10
extern int __drinks_taken;
extern int __drinks_put_in;
//Beware! Only valid inside the function it has been set in!
extern char tmp_filename[];
typedef struct{
/*Drink spevifier*/
@@ -21,25 +17,17 @@ typedef struct{
typedef struct{
Drink drinks[NUM_OF_DRINKS];
int waiting;
}Beerbox;
//this shall always just exist in a short term!
typedef struct{
char file_name[FILE_NAME_LEN + 1];
int drinks_taken[NUM_OF_DRINKS];
char name[NAME_LEN + 1];
char rfid_uuid[13];
uint8_t finger_uuid;
uint8_t credits_left;
int drinks_taken[NUM_OF_DRINKS];
}Person;
Beerbox* read_beerbox(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);