first commit!

This commit is contained in:
2025-02-06 12:54:34 +02:00
commit 37f9a3d138
24 changed files with 693 additions and 0 deletions

45
sqlite_ex.h Normal file
View File

@ -0,0 +1,45 @@
#define _GNU_SOURCE 1
#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define SELECT_MEASUREMENTS "select * from measurements order by date;"
#define SELECT_COUNT_MEAS "select count(*) from measurements;"
#define SELECT_ALL_TABLES "select * from sqlite_schema where type = 'table';"
#define SELECT_TWNTH_DAY "select * from twnth_day;"
#define SELECT_CURRENT_COSTS "select * from costs where id = ?;"
#define STR_SIZE 11
typedef struct tm Datetime;
typedef struct {
Datetime *datetime;
/* NOTE: probably should change to union type?
* (to hold both double and int representation, to count the integer cost)
*/
double gas;
double water;
double electricity;
int cost_id;
} meas;
typedef struct {
double gas_c;
double water_c;
double electricity_c;
double housing_c;
} Cost;
int print_tables(void *, int, char **, char **);
void print_measurements();
void free_measurements();
int dates_same(Datetime *, Datetime *);
double communal_difference(meas *, meas *);
int parse_measurements(void *, int, char **, char **);
int count_measurements(void *, int, char **, char **);
int select_twnth_day(void *, int, char **, char **);
void sqlite_list_tables(sqlite3 *db);
void sqlite_exec_query(char *query, void *callback);