69 lines
2.1 KiB
C
69 lines
2.1 KiB
C
#ifndef DODO_H
|
|
#define DODO_H
|
|
|
|
#define SQLQUERY_MAX 400
|
|
#define ARG_MAX 100
|
|
#define NUM_TASK_LISTS 3
|
|
#define FIXED_TITLE_WIDTH 20
|
|
#define FIXED_DATE_WIDTH 12
|
|
#define FIXED_ID_WIDTH 4
|
|
#define FIXED_COLUMN_WIDTH (FIXED_ID_WIDTH + FIXED_TITLE_WIDTH +FIXED_DATE_WIDTH)
|
|
#define FIXED_WHITESPACE 2
|
|
#define FIXED_MAX_WIDTH (FIXED_COLUMN_WIDTH)
|
|
#define TODAY_COL_START -1
|
|
#define BACKLOG_COL_START (FIXED_COLUMN_WIDTH + 1)
|
|
#define BLOCKED_COL_START ( 2 * (FIXED_COLUMN_WIDTH + 1) )
|
|
|
|
// TODO maybe I should make another module that is strictly
|
|
|
|
typedef struct{
|
|
int year;
|
|
int month;
|
|
int day;
|
|
}date;
|
|
|
|
// Filters for sql selection
|
|
typedef struct {
|
|
char *selected_columns;
|
|
char *title;
|
|
char *new_title;
|
|
int active_id;
|
|
char *status;
|
|
char *project_tag;
|
|
char *due_date;
|
|
}filtered_tasks;
|
|
|
|
|
|
// FOR DEBUG
|
|
int callback(void *NotUsed, int argc, char **argv, char **azColName);
|
|
int view_all(sqlite3 *db);
|
|
|
|
// filtered_tasks constructor
|
|
void init_filtered_tasks(filtered_tasks* task);
|
|
|
|
// sql generators TODO: might be able to boil this down to 1 func
|
|
int gen_sql_update_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
|
int gen_sql_update_stmt_v2(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
|
int gen_sql_delete_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
|
int gen_sql_insert_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task, char* values);
|
|
int gen_sql_select_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* task);
|
|
|
|
// helpers
|
|
int checksqlerr(int rc, char *errmsg);
|
|
int opendb(sqlite3 **db, char* filename);
|
|
void display_heading();
|
|
int parse_args(int argc, char** argv, filtered_tasks* task);
|
|
int get_num_rows(sqlite3 *db, char* table, char* status);
|
|
int print_fixed_width(const unsigned char* str, int width);
|
|
int display_task_list(int start_col, sqlite3 *db, filtered_tasks*);
|
|
|
|
// main functions
|
|
int view_tasks(sqlite3 *db);
|
|
int add_new_task(sqlite3 *db, int argc, char** argv);
|
|
int update_task_status(sqlite3 *db, int argc, char** argv);
|
|
int complete_task(sqlite3 *db, int argc, char** argv);
|
|
int update_task(sqlite3 *db, int argc, char** argv);
|
|
int del_task(sqlite3 *db, int argc, char** argv);
|
|
|
|
#endif
|