36 lines
626 B
C
36 lines
626 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
|
|
#include "habit.h"
|
|
|
|
int
|
|
add_habit(struct habit_tracker *tracker, char *name, int stati)
|
|
{
|
|
struct habit *first = habit_tracker->first;
|
|
struct habit *new_habit;
|
|
new_habit = malloc(sizeof(struct habit));
|
|
if (new_habit == NULL) {
|
|
return -1;
|
|
}
|
|
new_habit->stati = stati;
|
|
new_habit->name = name;
|
|
new_habit->next = first;
|
|
|
|
habit_tracker->first = new_habit;
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
habit_from_file(struct habit_tracker *tracker, FILE *fp)
|
|
{
|
|
int stat_buf;
|
|
char *ptr, *endptr;
|
|
char linebuf[HABIT_NAME_SIZE];
|
|
|
|
tracker->first = NULL;
|
|
if
|
|
return 0;
|
|
}
|