diff --git a/src/config_rmw.h b/src/config_rmw.h
index f74a96dc..4c8ad049 100644
--- a/src/config_rmw.h
+++ b/src/config_rmw.h
@@ -32,12 +32,15 @@ extern const char *expire_age_str;
typedef struct
{
- char uid[10];
- st_waste *st_waste_folder_props_head;
- bool force_required;
- int expire_age;
+ st_waste *st_waste_folder_props_head; // Pointer with high alignment requirements
+
+ int expire_age; // 4-byte alignment, placed next
+
+ bool force_required; // Minimal alignment, placed after the int
+ char uid[10]; // Character array, lower alignment, placed last
} st_config;
+
void print_config(FILE * restrict stream);
void
diff --git a/src/main.h b/src/main.h
index 23a9b4e5..7fa8e4ae 100644
--- a/src/main.h
+++ b/src/main.h
@@ -46,8 +46,11 @@ struct st_loc
const char *home_dir;
const char *config_dir;
const char *config_file;
+
const char *data_dir;
const char *purge_time_file;
const char *mrl_file;
- const st_dir *st_directory;
+
+ const st_dir *st_directory; // Pointer to another struct, placed at the end for clarity
};
+
diff --git a/src/parse_cli_options.h b/src/parse_cli_options.h
index 40007fba..79f82ba1 100644
--- a/src/parse_cli_options.h
+++ b/src/parse_cli_options.h
@@ -25,8 +25,13 @@ along with this program. If not, see .
/** CLI option switches for rmw. */
typedef struct
{
- bool want_restore;
int want_purge;
+ int force;
+
+ /*! Alternate configuration file given at the command line with -c */
+ const char *alt_config_file;
+
+ bool want_restore;
bool want_empty_trash;
bool want_top_level_bypass;
bool want_orphan_chk;
@@ -34,14 +39,13 @@ typedef struct
bool want_undo;
bool most_recent_list;
bool want_dry_run;
- int force;
+
/*! list waste folder option */
bool list;
- /*! Alternate configuration file given at the command line with -c */
- const char *alt_config_file;
} rmw_options;
+
void init_rmw_options(rmw_options * options);
void
diff --git a/src/time_rmw.h b/src/time_rmw.h
index 6d2d54f6..9de4fc4b 100644
--- a/src/time_rmw.h
+++ b/src/time_rmw.h
@@ -42,12 +42,13 @@ along with this program. If not, see .
*/
typedef struct
{
- char suffix_added_dup_exists[LEN_MAX_TIME_STR_SUFFIX];
+ time_t now; // Largest member, placed first to avoid alignment padding issues.
+ char deletion_date[LEN_MAX_DELETION_DATE]; // Grouped char arrays together.
char t_fmt[LEN_MAX_DELETION_DATE];
- char deletion_date[LEN_MAX_DELETION_DATE];
- time_t now;
+ char suffix_added_dup_exists[LEN_MAX_TIME_STR_SUFFIX];
} st_time;
+
void init_time_vars(st_time * st_time_var);
#endif
diff --git a/src/trashinfo.h b/src/trashinfo.h
index 7e26a933..52144bee 100644
--- a/src/trashinfo.h
+++ b/src/trashinfo.h
@@ -41,14 +41,23 @@ struct st_waste
/** The parent directory, e.g. $HOME/.local/share/Trash */
char *parent;
- /*! The info directory (where .trashinfo files are written) will be appended to the parent directory */
+ /** The info directory (where .trashinfo files are written) will be appended to the parent directory */
char *info;
- int len_info;
- /** Appended to the parent directory, where files are moved to when they are rmw'ed
- */
+ /** Appended to the parent directory, where files are moved to when they are rmw'ed */
char *files;
- int len_files;
+
+ /** If a waste folder is at the top level, a relative path will be
+ * used (per the Freedesktop trash spec). See
+ * https://github.com/theimpossibleastronaut/rmw/issues/299 for more
+ * info */
+ char *media_root;
+
+ /** Points to the previous WASTE directory in the linked list */
+ st_waste *prev_node;
+
+ /** Points to the next WASTE directory in the linked list */
+ st_waste *next_node;
/** The device number of the filesystem on which the file resides. rmw does
* not copy files from one filesystem to another, but rather only moves them.
@@ -57,29 +66,18 @@ struct st_waste
*/
dev_t dev_num;
- /** set to true if the parent directory is on a removable device,
+ int len_info;
+ int len_files;
+
+ /** Set to true if the parent directory is on a removable device,
* false otherwise.
*/
bool removable;
- /*
- * If a waste folder is at the top level, a relative path will be
- * used (per the Freedesktop trash spec). See
- https://github.com/theimpossibleastronaut/rmw/issues/299 for more
- info */
- char *media_root;
-
bool is_btrfs;
-
- /** Points to the previous WASTE directory in the linked list
- */
- st_waste *prev_node;
-
- /** Points to the next WASTE directory in the linked list
- */
- st_waste *next_node;
};
+
/** Holds information about a file that was specified for rmw'ing
*/
typedef struct
@@ -87,16 +85,17 @@ typedef struct
/** The absolute path to the file, stored later in a .trashinfo file */
char *real_path;
- /** The basename of the target file, and used for the basename of it's corresponding
+ /** The basename of the target file, and used for the basename of its corresponding
* .trashinfo file */
const char *base_name;
+ /** The device number of the filesystem on which the file resides */
+ dev_t dev_num;
+
/** The destination file name. This may be different if a file of the same name already
- * exists in the WASTE folder */
+ * exists in the WASTE folder */
char waste_dest_name[PATH_MAX];
- dev_t dev_num;
-
/** Is true if the file exists in the destination WASTE/files folder,
* false otherwise. If it's a duplicate, a string based on the current time
* will be appended to \ref dest_name
@@ -104,6 +103,7 @@ typedef struct
bool is_duplicate;
} rmw_target;
+
extern const char *lit_info;
extern const char *path_key;
extern const char *deletion_date_key;