aboutsummaryrefslogtreecommitdiff
path: root/include/database_interaction.h
blob: 5ff6f66e1a77198dc8902f68271ddea163bd26b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* SPDX-License-Identifier: Apache-2.0 */

/* Copyright 2026 Thorsten Töpper
 *
 * vim:ts=4:sw=4:expandtab
 */
#ifndef DATABASE_INTERACTION_H
#define DATABASE_INTERACTION_H

#include "file_processor.h"

/*=========== FUNCTIONS ===========*/
bool dbi_open(char *filename);
void dbi_close();

char *dbi_select_filename_by_id(int64_t id);
int64_t dbi_select_filename_by_name(const char *name);
int64_t *dbi_select_filenames_all_ids();
int dbi_insert_filename(const char *filename);

char *dbi_select_path_by_id(int64_t id);
int64_t dbi_select_path_by_pathname(const char *pathname);
int dbi_insert_pathname(const char *path);

struct df_hashstrings *dbi_select_hashes_by_id(int64_t id);
int64_t *dbi_select_hashes_all_ids();
int64_t dbi_select_hashes_by_strings(const char *blake2, const char *sha256, const char *sha512);
int dbi_insert_hashes(const char *blake2, const char *sha256, const char *sha512);

int64_t dbi_select_fileinfo_by_hash_path_filename_ids(int64_t hash_id, int64_t path_id, int64_t filename_id);
int64_t dbi_select_fileinfo_by_path_filename_ids(int64_t pname_id, int64_t fname_id);
int dbi_insert_fileinfo(struct df_fileinfo *fi);

int dbi_update_fileinfo_last_seen(int64_t id);
int dbi_update_fileinfo_complete(struct df_fileinfo *fi, int64_t existing_id);

int dbi_print_fileinfo_resolved(FILE *fd);
int dbi_print_identical_hashes(FILE *fd);
int dbi_print_identical_filenames(FILE *fd);
int dbi_print_fullpaths(FILE *out);
int dbi_print_filenames(FILE *out);

int64_t *dbi_select_hashes_all_ids();

#endif