diff options
Diffstat (limited to 'src/dged')
| -rw-r--r-- | src/dged/buffer.h | 6 | ||||
| -rw-r--r-- | src/dged/buffers.h | 12 | ||||
| -rw-r--r-- | src/dged/command.h | 10 | ||||
| -rw-r--r-- | src/dged/path.h | 22 | ||||
| -rw-r--r-- | src/dged/reactor.h | 3 | ||||
| -rw-r--r-- | src/dged/settings-parse.h | 2 | ||||
| -rw-r--r-- | src/dged/settings.h | 33 |
7 files changed, 52 insertions, 36 deletions
diff --git a/src/dged/buffer.h b/src/dged/buffer.h index 417ca03..dad6ef1 100644 --- a/src/dged/buffer.h +++ b/src/dged/buffer.h @@ -221,6 +221,6 @@ void buffer_to_file(struct buffer *buffer); void buffer_write_to(struct buffer *buffer, const char *filename); void buffer_reload(struct buffer *buffer); -void buffer_update(struct buffer_view *view, uint32_t window_id, uint32_t width, uint32_t height, - struct command_list *commands, uint64_t frame_time, - uint32_t *relline, uint32_t *relcol); +void buffer_update(struct buffer_view *view, uint32_t window_id, uint32_t width, + uint32_t height, struct command_list *commands, + uint64_t frame_time, uint32_t *relline, uint32_t *relcol); diff --git a/src/dged/buffers.h b/src/dged/buffers.h index cb37fcb..f4c0a37 100644 --- a/src/dged/buffers.h +++ b/src/dged/buffers.h @@ -20,11 +20,15 @@ void buffers_init(struct buffers *buffers, uint32_t initial_capacity); struct buffer *buffers_add(struct buffers *buffers, struct buffer buffer); struct buffer *buffers_find(struct buffers *buffers, const char *name); -struct buffer *buffers_find_by_filename(struct buffers *buffers, const char *path); +struct buffer *buffers_find_by_filename(struct buffers *buffers, + const char *path); -uint32_t buffers_add_add_hook(struct buffers *buffers, buffers_hook_cb callback, void *userdata); -uint32_t buffers_add_remove_hook(struct buffers *buffers, buffers_hook_cb callback, void *userdata); +uint32_t buffers_add_add_hook(struct buffers *buffers, buffers_hook_cb callback, + void *userdata); +uint32_t buffers_add_remove_hook(struct buffers *buffers, + buffers_hook_cb callback, void *userdata); -void buffers_for_each(struct buffers *buffers, buffers_hook_cb callback, void *userdata); +void buffers_for_each(struct buffers *buffers, buffers_hook_cb callback, + void *userdata); void buffers_destroy(struct buffers *buffers); diff --git a/src/dged/command.h b/src/dged/command.h index bbc57f2..956c10a 100644 --- a/src/dged/command.h +++ b/src/dged/command.h @@ -77,6 +77,16 @@ struct command { }; /** + * Convenience macro for creating a command from a function. + */ +#define COMMAND_FN(name_, command_name, function, userdata_) \ + static struct command command_name##_command = { \ + .fn = function, \ + .name = #name_, \ + .userdata = userdata_, \ + }; + +/** * A command registry */ HASHMAP_ENTRY_TYPE(command_entry, struct command); diff --git a/src/dged/path.h b/src/dged/path.h index d74f723..6e11d6a 100644 --- a/src/dged/path.h +++ b/src/dged/path.h @@ -9,19 +9,19 @@ static char *expanduser(const char *path) { if (tilde_pos != NULL) { char *home = getenv("HOME"); if (home != NULL) { - // allocate a new string based with the new len - size_t home_len = strlen(home); - size_t path_len = strlen(path); - size_t total_len = path_len + home_len; - res = malloc(total_len); - size_t initial_len = tilde_pos - path; - strncpy(res, path, initial_len); + // allocate a new string based with the new len + size_t home_len = strlen(home); + size_t path_len = strlen(path); + size_t total_len = path_len + home_len; + res = malloc(total_len); + size_t initial_len = tilde_pos - path; + strncpy(res, path, initial_len); - strncpy(res + initial_len, home, home_len); + strncpy(res + initial_len, home, home_len); - size_t rest_len = path_len - initial_len - 1; - strncpy(res + initial_len + home_len, path + initial_len + 1, rest_len); - res[total_len-1] = '\0'; + size_t rest_len = path_len - initial_len - 1; + strncpy(res + initial_len + home_len, path + initial_len + 1, rest_len); + res[total_len - 1] = '\0'; } } diff --git a/src/dged/reactor.h b/src/dged/reactor.h index 1fa014d..39a94a9 100644 --- a/src/dged/reactor.h +++ b/src/dged/reactor.h @@ -24,7 +24,8 @@ void reactor_update(struct reactor *reactor); bool reactor_poll_event(struct reactor *reactor, uint32_t ev_id); uint32_t reactor_register_interest(struct reactor *reactor, int fd, enum interest interest); -uint32_t reactor_watch_file(struct reactor *reactor, const char *path, uint32_t mask); +uint32_t reactor_watch_file(struct reactor *reactor, const char *path, + uint32_t mask); void reactor_unwatch_file(struct reactor *reactor, uint32_t id); bool reactor_next_file_event(struct reactor *reactor, struct file_event *out); void reactor_unregister_interest(struct reactor *reactor, uint32_t ev_id); diff --git a/src/dged/settings-parse.h b/src/dged/settings-parse.h index 63a0f1e..0a782eb 100644 --- a/src/dged/settings-parse.h +++ b/src/dged/settings-parse.h @@ -1,6 +1,6 @@ #include <stdbool.h> -#include <stdint.h> #include <stddef.h> +#include <stdint.h> #include "vec.h" diff --git a/src/dged/settings.h b/src/dged/settings.h index 80f6b0f..637844b 100644 --- a/src/dged/settings.h +++ b/src/dged/settings.h @@ -137,23 +137,24 @@ void setting_set_value(struct setting *setting, struct setting_value val); void setting_to_string(struct setting *setting, char *buf, size_t n); /** - * Parse settings from a string in TOML format. - * - * @param toml Pointer to a NULL-terminated string containing TOML settings. - * @param errmsgs Pointer to a string array where error messages will be placed. These - * messages must be freed after use. - * @returns 0 on success, n > 0 where n denotes the number of error messages in - * @ref errmsgs - */ + * Parse settings from a string in TOML format. + * + * @param toml Pointer to a NULL-terminated string containing TOML settings. + * @param errmsgs Pointer to a string array where error messages will be placed. + * These messages must be freed after use. + * @returns 0 on success, n > 0 where n denotes the number of error messages in + * @ref errmsgs + */ int32_t settings_from_string(const char *toml, char **errmsgs[]); /** - * Parse settings from a file in TOML format. - * - * @param toml Pointer to a NULL-terminated string describing a path to a TOML file with settings. - * @param errmsgs Pointer to a string array where error messages will be placed. These - * messages must be freed after use. - * @returns 0 on success, n > 0 where n denotes the number of error messages in - * @ref errmsgs - */ + * Parse settings from a file in TOML format. + * + * @param toml Pointer to a NULL-terminated string describing a path to a TOML + * file with settings. + * @param errmsgs Pointer to a string array where error messages will be placed. + * These messages must be freed after use. + * @returns 0 on success, n > 0 where n denotes the number of error messages in + * @ref errmsgs + */ int32_t settings_from_file(const char *path, char **errmsgs[]); |
