diff options
author | Louie S <louie@example.com> | 2023-07-03 11:30:38 -0700 |
---|---|---|
committer | Louie S <louie@example.com> | 2023-07-03 11:30:38 -0700 |
commit | ded510aedc6d1df4b34e1cca07847098fd94198b (patch) | |
tree | d0f089e68e94cccca9cd3e1bf23e274505f710c1 /src | |
parent | a3c635bc459ea6e05c62868ddd0ef3a097ae05dc (diff) |
Add id to structs
Diffstat (limited to 'src')
-rw-r--r-- | src/db/sqlite3/db.c | 8 | ||||
-rw-r--r-- | src/db/sqlite3/db.h | 8 | ||||
-rw-r--r-- | src/entry.c | 8 | ||||
-rw-r--r-- | src/entry.h | 3 | ||||
-rw-r--r-- | src/group.c | 10 | ||||
-rw-r--r-- | src/group.h | 3 |
6 files changed, 40 insertions, 0 deletions
diff --git a/src/db/sqlite3/db.c b/src/db/sqlite3/db.c index 30e74a0..aa8485b 100644 --- a/src/db/sqlite3/db.c +++ b/src/db/sqlite3/db.c @@ -32,6 +32,14 @@ int db_init() { return 0; } +Group *db_load_groups() { + // TODO +} + +Entry *db_load_entries() { + // TODO +} + int create_tables(const char *path) { sqlite3 *db; char queries[2][BUF_LEN]; diff --git a/src/db/sqlite3/db.h b/src/db/sqlite3/db.h index c6279f9..44f61b7 100644 --- a/src/db/sqlite3/db.h +++ b/src/db/sqlite3/db.h @@ -7,6 +7,14 @@ * 1 -> failure: could not create directory * 2 -> failure: could not create file */ + +#include "entry.h" +#include "group.h" + int db_init(); +Group *db_load_groups(); + +Entry *db_load_entries(); + #endif diff --git a/src/entry.c b/src/entry.c index f996a00..af4b8f4 100644 --- a/src/entry.c +++ b/src/entry.c @@ -3,6 +3,10 @@ #include "entry.h" // getters +int entry_get_id(Entry *e) { + return e->id; +} + struct tm entry_get_due_date(Entry *e) { return e->due_date; } @@ -33,6 +37,10 @@ char *entry_get_url(Entry *e) { // setters +void entry_set_id(Entry *e, int id) { + e->id = id; +} + void entry_set_due_date(Entry *e, struct tm due_date) { e->due_date = due_date; } diff --git a/src/entry.h b/src/entry.h index 298b9b4..e22a737 100644 --- a/src/entry.h +++ b/src/entry.h @@ -8,6 +8,7 @@ // a group/category for entries to be put in typedef struct { + int id; // id from database struct tm due_date; char alt_due_date[BUF_LEN]; char title[BUF_LEN]; @@ -18,6 +19,7 @@ typedef struct { } Entry; // getters +int entry_get_id(Entry *e); struct tm entry_get_due_date(Entry *e); char *entry_get_alt_due_date(Entry *e); char *entry_get_title(Entry *e); @@ -27,6 +29,7 @@ bool entry_get_done(Entry *e); char *entry_get_url(Entry *e); // setters +void entry_set_id(Entry *e, int id); void entry_set_due_date(Entry *e, struct tm due_date); void entry_set_alt_due_date(Entry *e, char *alt_due_date); void entry_set_title(Entry *e, char *title); diff --git a/src/group.c b/src/group.c index db387e0..33307ee 100644 --- a/src/group.c +++ b/src/group.c @@ -2,6 +2,11 @@ #include "group.h" +// getters +int group_get_id(Group *g) { + return g->id; +} + char *group_get_name(Group *g) { return g->name; } @@ -14,6 +19,11 @@ char *group_get_url(Group *g) { return g->url; } +// setters +void group_set_id(Group *g, int id) { + g->id = id; +} + void group_set_name(Group *g, char *name) { strcpy(g->name, name); } diff --git a/src/group.h b/src/group.h index 2d626b7..2a4d116 100644 --- a/src/group.h +++ b/src/group.h @@ -5,6 +5,7 @@ // a group/category for entries to be put in typedef struct { + int id; // id from database char name[BUF_LEN]; char desc[BUF_LEN]; char url[BUF_LEN]; @@ -12,11 +13,13 @@ typedef struct { } Group; // getters +int group_get_id(Group *g); char *group_get_name(Group *g); char *group_get_desc(Group *g); char *group_get_url(Group *g); // setters +void group_set_id(Group *g, int id); void group_set_name(Group *g, char *name); void group_set_desc(Group *g, char *desc); void group_set_url(Group *g, char *url); |