#ifndef HEALTH_H
#define HEALTH_H

#include <sys/types.h>
#include "utils.h"

/*
 * path - Path of the directory without trailing slash
 * warn_at - How large is the directory allowed to be before a warning is
 *      issued. In human readable form (see utils.c:pretty_bytes)
 * children - List of all watched sub-directories
 * n_children - Number of elements in children
 * size - Size of directory, this is filled in by disk_usage()
 */
struct dir_status {
    char * const path;
    char * const warn_at;
    struct dir_status *children;
    int n_children;
    off_t size;
};

#define WATCH_DIR(pth,wrn) {.path = pth, .warn_at = wrn, .n_children=0, .size=0}
#define WATCH_DIR_SUBS(pth,wrn,subs) {.path = pth, .warn_at = wrn, .size=0 \
    , .children=subs, .n_children=sizeof(subs)/sizeof(struct dir_status)}

off_t traverse_nochildren(FTS *file_system, const short dir_level);
void traverse_children(FTS *file_system, struct dir_status *dir, const short dir_level);
int disk_usage(struct dir_status *top_dir);

//ustring ok_ustr = {.str = "OK", .bytes = 2, .chars = 2};
//NEW_USTRING(ok_str, "OK");
//NEW_USTRING(warn_str, "WARN");
//NEW_USTRING(arrow_str, "├─");
//NEW_USTRING(arrow_last_str,"└─");
//INIT_USTRING(ok_str);
//INIT_USTRING(warn_str);
//INIT_USTRING(arrow_str);
//INIT_USTRING(arrow_last_str);
void format_directory_entry(char *buf, struct dir_status *dir, int level, int last_subdir);
int directory_ok(off_t size, char *warn_at);

#endif
