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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
int bless_buffer_new | ( | bless_buffer_t ** | buf | ) |
Creates an empty bless_buffer_t.
[out] | buf | an empty bless_buffer_t |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |