#ifndef DATA_STRUCT_H_SENTRY #define DATA_STRUCT_H_SENTRY #include /* * data_struct.h * * This module provides basic data structures and helper functions * for handling file information, directory/file arguments, and * transforming them between linked lists and arrays. * */ enum { buffer_size = 512 }; /* * Stores separated command-line arguments: * dirs is array of directory paths * files is array of file paths */ struct arg_arrays { const char **dirs; const char **files; }; /* * Single-linked list node containing file entry: * info_line -- formatted string with file information * filename used for sorting */ struct file_item { char *info_line; char *filename; struct file_item *next; }; /* * array-based representation of file_item list: * array -- dynamic array of pointers to file_item */ struct file_item_array { struct file_item **array; size_t length; }; void init_arg_arrays(struct arg_arrays *split, int argc); void init_item_array(struct file_item_array *arr); void add_new_item(struct file_item **list, struct file_item **entry, const char *file_name); void copy_list_to_array(struct file_item *list, struct file_item_array *arr); void free_file_item_array(struct file_item_array *arr, struct file_item **list); void free_arg_arrays(struct arg_arrays *split); int is_empty_array(const char **paths_array, int argc); int is_last_arr_element(const char **paths_array, int argc, size_t pos); void sort_array_by_names(struct file_item_array *arr); #endif