aboutsummaryrefslogtreecommitdiff
path: root/include/list_management.h
blob: a62fe458ce446e5edae226f5131a71ed5bcde213 (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
/* SPDX-License-Identifier: Apache-2.0 */

/* Copyright 2025 Thorsten Töpper
 *
 * vim:ts=4:sw=4:expandtab
 */

#ifndef LIST_MANAGEMENT_H
#define LIST_MANAGEMENT_H

#include <time.h>

/* === DEFINITIONS === */

/* off_t is defined in different headers, on Linux with glibc,
 * stdio.h, unistd.h and types.h
 * output.h requires this struct definition therefore off_t
 * becomes implicitly defined through stdio.h as every source
 * file includes output.h */
struct list_node {
    struct list_node *next;
    off_t fsize;
    char fname[256];
    time_t ftime; /* can be creation, access or modification */
};

struct list_head {
    struct list_node *first;
};

struct list_node *create_node(char *fname, long int fsize, time_t ftime);
struct list_head *create_list_sort_reversed(struct list_head *list);
void destroy_list(struct list_head *list);
int insert_sorted_by_size(struct list_head *list, struct list_node *node);
int insert_sorted_by_time(struct list_head *list, struct list_node *node);


#endif