diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-12-30 22:47:49 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-12-30 22:47:49 -0800 |
| commit | 5371a49ce0eda4054cc4dcb73abea351482711c2 (patch) | |
| tree | 7e0142fdd1ce742f49c1dcda51157941834faf7f /entry.h | |
| parent | 18681fa449dc10e408128dbe50c482bfff0ead05 (diff) | |
Refactoring into multiple files better
Diffstat (limited to 'entry.h')
| -rw-r--r-- | entry.h | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +/* + * entry.h - Define types for file entries. + */ +#ifndef FILE_ENTRY__H +#define FILE_ENTRY__H + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#define IS_SELECTED(p) (((p)->selected.atme) != NULL) +#define IS_VIEWED(p) ((p)->index >= 0) +#define IS_LOADED(p) ((p)->hash.atme != NULL) + +/* entry_t uses intrusive linked lists. This means entries can only belong to + * one list at a time, in this case the list of selected entries. 'atme' is an + * indirect pointer to either the 'next' field of the previous list member, or + * the variable that points to the first list member. In other words, + * item->next->atme == &item->next and firstitem->atme == &firstitem. + */ +typedef struct entry_s { + struct { + struct entry_s *next, **atme; + } selected, hash; + char *name, *linkname; + struct stat info; + mode_t linkedmode; + int no_esc : 1; + int link_no_esc : 1; + int shufflepos; + int index; + char fullname[1]; + // ------- fullname must be last! -------------- + // When entries are allocated, extra space on the end is reserved to fill + // in fullname. +} entry_t; + +#endif |
