mirror of
https://github.com/WCBROW01/zblock.git
synced 2025-12-11 20:18:07 -05:00
Add preliminary code for database (this really needs to be cleaned)
This commit is contained in:
54
feed_info.h
54
feed_info.h
@ -3,42 +3,38 @@
|
||||
|
||||
#include <concord/discord.h>
|
||||
|
||||
// TODO: last_pubDate doesn't actually work properly yet
|
||||
typedef struct feed_info {
|
||||
char *title;
|
||||
#include <postgresql/libpq-fe.h>
|
||||
|
||||
typedef struct {
|
||||
char *url;
|
||||
char *last_pubDate;
|
||||
u64snowflake guild_id;
|
||||
u64snowflake channel_id;
|
||||
unsigned timer_id;
|
||||
unsigned feed_id;
|
||||
} feed_info;
|
||||
} zblock_feed_info_minimal;
|
||||
|
||||
typedef struct {
|
||||
// same definition as feed_info_minimal
|
||||
char *url;
|
||||
char *last_pubDate;
|
||||
u64snowflake channel_id;
|
||||
// extra things
|
||||
char *title;
|
||||
u64snowflake guild_id;
|
||||
} zblock_feed_info;
|
||||
|
||||
typedef enum {
|
||||
FEED_INFO_OK,
|
||||
FEED_INFO_NULL,
|
||||
FEED_INFO_FILEERROR,
|
||||
FEED_INFO_ERRORCOUNT
|
||||
} feed_info_err;
|
||||
ZBLOCK_FEED_INFO_OK,
|
||||
ZBLOCK_FEED_INFO_NULL,
|
||||
ZBLOCK_FEED_INFO_POSTGRES,
|
||||
ZBLOCK_FEED_INFO_ERRORCOUNT
|
||||
} zblock_feed_info_err;
|
||||
|
||||
/*
|
||||
* Free the feed info struct
|
||||
*/
|
||||
void feed_info_free(struct feed_info *feed);
|
||||
// maybe change the function signature so you can actually do error handling with the result?
|
||||
time_t pubDate_to_time_t(char *s);
|
||||
|
||||
/*
|
||||
* Get a string explaining a feed info error
|
||||
*/
|
||||
const char *feed_info_strerror(feed_info_err error);
|
||||
// returns a string about the result of a feed_info function
|
||||
const char *zblock_feed_info_strerror(zblock_feed_info_err error);
|
||||
|
||||
/*
|
||||
* Saves feed info to given file
|
||||
*/
|
||||
feed_info_err feed_info_save_file(feed_info *feed);
|
||||
|
||||
/*
|
||||
* Reads feed info for given information from file and puts it in the provided struct
|
||||
*/
|
||||
feed_info_err feed_info_load_file(u64snowflake guild_id, u64snowflake channel_id, unsigned feed_id, feed_info *feed);
|
||||
// Insert new feed into the database
|
||||
zblock_feed_info_err zblock_feed_info_insert(PGconn *conn, zblock_feed_info *feed);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user