Typedefs | |
typedef struct bless_buffer | bless_buffer_t |
Opaque data type for a bless buffer. | |
typedef int( | bless_progress_func )(void *info) |
Callback function called to report the progress of long operations. | |
typedef void( | bless_buffer_event_func_t )(bless_buffer_t *buf, struct bless_buffer_event_info *info, void *user_data) |
Callback function called to report a buffer event. | |
Buffer Sources | |
| |
typedef void | bless_buffer_source_t |
Opaque type for a buffer source object. | |
typedef void( | bless_mem_free_func )(void *) |
A function to call to free the memory associated with a memory source object. | |
typedef int( | bless_file_close_func )(int) |
A function to call to close the file associated with a file source object. | |
int | bless_buffer_source_memory (bless_buffer_source_t **src, void *data, size_t length, bless_mem_free_func *mem_free) |
Creates a memory source for bless_buffer_t. | |
int | bless_buffer_source_file (bless_buffer_source_t **src, int fd, bless_file_close_func *file_close) |
Creates a file source for bless_buffer_t. | |
int | bless_buffer_source_unref (bless_buffer_source_t *src) |
Decreases the usage count of a source object. | |
File Operations | |
| |
int | bless_buffer_new (bless_buffer_t **buf) |
Creates an empty bless_buffer_t. | |
int | bless_buffer_save (bless_buffer_t *buf, int fd, bless_progress_func *progress_func) |
Saves the contents of a bless_buffer_t to a file. | |
int | bless_buffer_free (bless_buffer_t *buf) |
Frees a bless_buffer_t. | |
Edit Actions | |
| |
int | bless_buffer_append (bless_buffer_t *buf, bless_buffer_source_t *src, off_t src_offset, off_t length) |
Appends data to a bless_buffer_t. | |
int | bless_buffer_insert (bless_buffer_t *buf, off_t offset, bless_buffer_source_t *src, off_t src_offset, off_t length) |
Inserts data into a bless_buffer_t. | |
int | bless_buffer_delete (bless_buffer_t *buf, off_t offset, off_t length) |
Delete data from a bless_buffer_t. | |
int | bless_buffer_read (bless_buffer_t *src, off_t src_offset, void *dst, size_t dst_offset, size_t length) |
Reads data from a bless_buffer_t. | |
Undo - Redo Operations | |
| |
int | bless_buffer_undo (bless_buffer_t *buf) |
Undoes the last operation in a bless_buffer_t. | |
int | bless_buffer_redo (bless_buffer_t *buf) |
Redoes the last undone operation in a bless_buffer_t. | |
int | bless_buffer_begin_multi_action (bless_buffer_t *buf) |
Marks the beginning of a multi-action. | |
int | bless_buffer_end_multi_action (bless_buffer_t *buf) |
Marks the end of a multi-action. | |
Buffer Information/Options | |
| |
int | bless_buffer_can_undo (bless_buffer_t *buf, int *can_undo) |
Checks whether the last operation in a bless_buffer_t can be undone. | |
int | bless_buffer_can_redo (bless_buffer_t *buf, int *can_redo) |
Checks whether the last undone operation in a bless_buffer_t can be redone. | |
int | bless_buffer_get_size (bless_buffer_t *buf, off_t *size) |
Gets the size of a bless_buffer_t. | |
int | bless_buffer_set_option (bless_buffer_t *buf, bless_buffer_option_t opt, char *val) |
Sets a buffer option. | |
int | bless_buffer_get_option (bless_buffer_t *buf, char **val, bless_buffer_option_t opt) |
Gets a buffer option. | |
int | bless_buffer_set_event_callback (bless_buffer_t *buf, bless_buffer_event_func_t *func, void *user_data) |
Sets the callback function used to report buffer events. |
typedef void( bless_buffer_event_func_t)(bless_buffer_t *buf, struct bless_buffer_event_info *info, void *user_data) |
Callback function called to report a buffer event.
This function is set by bless_buffer_set_event_callback().
buf | the bless_buffer_t responsible for this event | |
info | the event information | |
user_data | user data |
typedef int( bless_progress_func)(void *info) |
Callback function called to report the progress of long operations.
This callback is used by operations that may take a long time to finish. These operations call the callback periodically and pass progress info using the info argument. The return value of the callback function is checked by the operations to decide whether they should continue.
info | operation specific progress info |
int bless_buffer_append | ( | bless_buffer_t * | buf, | |
bless_buffer_source_t * | src, | |||
off_t | src_offset, | |||
off_t | length | |||
) |
Appends data to a bless_buffer_t.
buf | the bless_buffer_t to append data to | |
src | the source of the data | |
src_offset | the offset of the data in the source | |
length | the length of the data to append |
Definition at line 95 of file buffer_edit.c.
References action_list_clear(), BLESS_BUFFER_EVENT_EDIT, buffer_action_append_new(), buffer_action_do(), buffer_action_free(), buffer_action_multi_add(), buffer_action_to_event(), buffer_action_undo(), bless_buffer_event_info::event_type, undo_list_append(), and undo_list_enforce_limit().
int bless_buffer_begin_multi_action | ( | bless_buffer_t * | buf | ) |
Marks the beginning of a multi-action.
A multi-action is a compound action consisting of multiple simple actions. In terms of undo-redo it is treated as a single action.
buf | the bless_buffer_t on which following actions are to be treated as part of a single action |
Definition at line 195 of file buffer_undo.c.
References action_list_clear(), buffer_action_free(), buffer_action_multi_new(), undo_list_append(), and undo_list_enforce_limit().
int bless_buffer_can_redo | ( | bless_buffer_t * | buf, | |
int * | can_redo | |||
) |
Checks whether the last undone operation in a bless_buffer_t can be redone.
buf | the bless_buffer_t to check | |
[out] | can_redo | 1 if the last undone operation can be undone, 0 otherwise |
Definition at line 69 of file buffer_info.c.
References list_head().
Referenced by bless_buffer_redo().
int bless_buffer_can_undo | ( | bless_buffer_t * | buf, | |
int * | can_undo | |||
) |
Checks whether the last operation in a bless_buffer_t can be undone.
buf | the bless_buffer_t to check | |
[out] | can_undo | 1 if the last operation can be undone, 0 otherwise |
Definition at line 49 of file buffer_info.c.
References list_head().
Referenced by bless_buffer_undo().
int bless_buffer_delete | ( | bless_buffer_t * | buf, | |
off_t | offset, | |||
off_t | length | |||
) |
Delete data from a bless_buffer_t.
buf | the bless_buffer_t to delete data from | |
offset | the offset in the bless_buffer_t to delete data from | |
length | the length of the data to delete |
Definition at line 277 of file buffer_edit.c.
References action_list_clear(), BLESS_BUFFER_EVENT_EDIT, buffer_action_delete_new(), buffer_action_do(), buffer_action_free(), buffer_action_multi_add(), buffer_action_to_event(), buffer_action_undo(), bless_buffer_event_info::event_type, undo_list_append(), and undo_list_enforce_limit().
int bless_buffer_end_multi_action | ( | bless_buffer_t * | buf | ) |
Marks the end of a multi-action.
A multi-action is a compound action consisting of multiple simple actions. In terms of undo-redo it is treated as a single action.
buf | the bless_buffer_t on which following actions will stop being treated as part of a single action |
Definition at line 249 of file buffer_undo.c.
References bless_buffer_event_info::action_type, BLESS_BUFFER_ACTION_MULTI, BLESS_BUFFER_EVENT_EDIT, buffer_action_to_event(), bless_buffer_event_info::event_type, bless_buffer_event_info::range_length, bless_buffer_event_info::range_start, and bless_buffer_event_info::save_fd.
int bless_buffer_free | ( | bless_buffer_t * | buf | ) |
Frees a bless_buffer_t.
Freeing a bless_buffer_t frees all related resources.
buf | the bless_buffer_t to close |
Definition at line 806 of file buffer_file.c.
References buffer_action_free(), buffer_options_free(), list_entry, list_for_each_safe, list_free(), list_head(), and segcol_free().
int bless_buffer_get_option | ( | bless_buffer_t * | buf, | |
char ** | val, | |||
bless_buffer_option_t | opt | |||
) |
Gets a buffer option.
The returned option value is the char * which is used internally so it must not be altered.
buf | the buffer to get the option of | |
[out] | val | the returned value of the option |
opt | the option to get |
Definition at line 205 of file buffer_info.c.
References BLESS_BUF_TMP_DIR, BLESS_BUF_UNDO_AFTER_SAVE, and BLESS_BUF_UNDO_LIMIT.
int bless_buffer_get_size | ( | bless_buffer_t * | buf, | |
off_t * | size | |||
) |
Gets the size of a bless_buffer_t.
buf | the bless_buffer_t | |
[out] | size | the size in bytes |
Definition at line 89 of file buffer_info.c.
References segcol_get_size().
int bless_buffer_insert | ( | bless_buffer_t * | buf, | |
off_t | offset, | |||
bless_buffer_source_t * | src, | |||
off_t | src_offset, | |||
off_t | length | |||
) |
Inserts data into a bless_buffer_t.
buf | the bless_buffer_t to insert data into | |
offset | the offset in the bless_buffer_t to insert data into | |
src | the data source to insert data from | |
src_offset | the offset in the source to insert data from | |
length | the length of the data to insert |
Definition at line 186 of file buffer_edit.c.
References action_list_clear(), BLESS_BUFFER_EVENT_EDIT, buffer_action_do(), buffer_action_free(), buffer_action_insert_new(), buffer_action_multi_add(), buffer_action_to_event(), buffer_action_undo(), bless_buffer_event_info::event_type, undo_list_append(), and undo_list_enforce_limit().
int bless_buffer_new | ( | bless_buffer_t ** | buf | ) |
Creates an empty bless_buffer_t.
[out] | buf | an empty bless_buffer_t |
Definition at line 526 of file buffer_file.c.
References buffer_options_free(), buffer_options_new(), list_free(), list_new, segcol_free(), and segcol_list_new().
int bless_buffer_read | ( | bless_buffer_t * | buf, | |
off_t | src_offset, | |||
void * | dst, | |||
size_t | dst_offset, | |||
size_t | length | |||
) |
Reads data from a bless_buffer_t.
buf | the bless_buffer_t to read data from | |
src_offset | the offset in the bless_buffer_t to start reading from | |
dst | a pointer to the start of the memory to store the data into | |
dst_offset | the offset in dst to the start storing data into | |
length | the length of the data to read |
Definition at line 368 of file buffer_edit.c.
References read_foreach_func(), and segcol_foreach().
int bless_buffer_redo | ( | bless_buffer_t * | buf | ) |
Redoes the last undone operation in a bless_buffer_t.
buf | the bless_buffer_t to redo the operation in |
Definition at line 115 of file buffer_undo.c.
References bless_buffer_can_redo(), BLESS_BUFFER_EVENT_REDO, buffer_action_do(), buffer_action_to_event(), buffer_action_undo(), bless_buffer_event_info::event_type, list_delete_chain(), list_entry, list_insert_before(), and list_tail().
int bless_buffer_save | ( | bless_buffer_t * | buf, | |
int | fd, | |||
bless_progress_func * | progress_func | |||
) |
Saves the contents of a bless_buffer_t to a file.
buf | the bless_buffer_t whose contents to save | |
fd | the file descriptor of the file to save the contents to | |
progress_func | the bless_progress_func to call to report the progress of the operation or NULL to disable reporting |
Definition at line 585 of file buffer_file.c.
References action_list_clear(), bless_buffer_event_info::action_type, actions_make_private_copy(), BLESS_BUFFER_EVENT_SAVE, break_edge(), create_overlap_graph(), data_object_file_new(), data_object_free(), data_object_update_usage(), bless_buffer_event_info::event_type, free_edge_list(), free_vertex_list(), is_fd_resizable(), list_entry, list_for_each, list_head(), overlap_graph_free(), overlap_graph_get_removed_edges(), overlap_graph_get_vertices_topo(), overlap_graph_remove_cycles(), bless_buffer_event_info::range_length, bless_buffer_event_info::range_start, reserve_disk_space(), bless_buffer_event_info::save_fd, segcol_append(), segcol_free(), segcol_get_size(), segcol_list_new(), segment_free(), segment_new(), write_segcol_rest(), and write_segment().
int bless_buffer_set_event_callback | ( | bless_buffer_t * | buf, | |
bless_buffer_event_func_t * | func, | |||
void * | user_data | |||
) |
Sets the callback function used to report buffer events.
The callback function can be set to NULL to disable event reporting.
buf | the bless_buffer_t to set the callback function of | |
func | the function to set | |
user_data | user data to be supplied to the callback function |
Definition at line 244 of file buffer_info.c.
int bless_buffer_set_option | ( | bless_buffer_t * | buf, | |
bless_buffer_option_t | opt, | |||
char * | val | |||
) |
Sets a buffer option.
buf | the buffer to set an option of | |
opt | the option to set | |
val | the value to set the option to |
Definition at line 106 of file buffer_info.c.
References action_list_clear(), BLESS_BUF_TMP_DIR, BLESS_BUF_UNDO_AFTER_SAVE, BLESS_BUF_UNDO_LIMIT, and undo_list_enforce_limit().
int bless_buffer_source_file | ( | bless_buffer_source_t ** | src, | |
int | fd, | |||
bless_file_close_func * | file_close | |||
) |
Creates a file source for bless_buffer_t.
If the data_free function is NULL the file won't be closed when this source object is freed.
[out] | src | the created bless_buffer_source_t. |
fd | the file descriptor associated with this source object | |
file_close | the function to call to close the file |
Definition at line 98 of file buffer_source.c.
References data_object_file_new(), data_object_file_set_close_func(), data_object_free(), and data_object_update_usage().
int bless_buffer_source_memory | ( | bless_buffer_source_t ** | src, | |
void * | data, | |||
size_t | length, | |||
bless_mem_free_func * | mem_free | |||
) |
Creates a memory source for bless_buffer_t.
If the mem_free function is NULL the data won't be freed when this source object is freed.
[out] | src | the created bless_buffer_source_t. |
data | the data related to the source | |
length | the length of the data | |
mem_free | the function to call to free the data |
Definition at line 51 of file buffer_source.c.
References data_object_free(), data_object_memory_new(), data_object_memory_set_free_func(), and data_object_update_usage().
int bless_buffer_source_unref | ( | bless_buffer_source_t * | src | ) |
Decreases the usage count of a source object.
This function should be called when the user is done using a source object. Failing to do so will lead to a memory leak.
src | the source object to decrease the usage count of |
Definition at line 144 of file buffer_source.c.
References data_object_update_usage().
int bless_buffer_undo | ( | bless_buffer_t * | buf | ) |
Undoes the last operation in a bless_buffer_t.
buf | the bless_buffer_t to undo the operation in |
Definition at line 45 of file buffer_undo.c.
References bless_buffer_can_undo(), BLESS_BUFFER_EVENT_UNDO, buffer_action_do(), buffer_action_to_event(), buffer_action_undo(), bless_buffer_event_info::event_type, list_delete_chain(), list_entry, list_insert_before(), and list_tail().