From 880957ad4e3fc0ff681025f5e29c5eccf797c564 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 10 May 2014 00:53:36 +0400 Subject: Move documentation from function declarations to definitions Uses a perl script to move it (scripts/movedocs.pl) --- src/nvim/os/channel.c | 25 +++++++++++++++ src/nvim/os/channel.h | 27 +--------------- src/nvim/os/env.c | 7 +++++ src/nvim/os/fs.c | 76 ++++++++++++++++++++++++++++++++++++++++++++- src/nvim/os/input.c | 4 +++ src/nvim/os/input.h | 4 --- src/nvim/os/job.c | 40 ++++++++++++++++++++++++ src/nvim/os/job.h | 41 ------------------------ src/nvim/os/mem.c | 4 ++- src/nvim/os/os.h | 81 ------------------------------------------------ src/nvim/os/rstream.c | 47 ++++++++++++++++++++++++++++ src/nvim/os/rstream.h | 47 ---------------------------- src/nvim/os/server.c | 14 +++++++++ src/nvim/os/server.h | 14 --------- src/nvim/os/shell.c | 60 ++++++++++++++++++++++------------- src/nvim/os/shell.h | 18 ----------- src/nvim/os/time.c | 17 ++++++++++ src/nvim/os/time.h | 17 ---------- src/nvim/os/uv_helpers.c | 24 ++++++++++++++ src/nvim/os/uv_helpers.h | 24 -------------- src/nvim/os/wstream.c | 28 +++++++++++++++++ src/nvim/os/wstream.h | 28 ----------------- 22 files changed, 324 insertions(+), 323 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index 6fd7cdbb7e..5886620990 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -49,6 +49,7 @@ static void close_cb(uv_handle_t *handle); static WBuffer *serialize_event(char *type, typval_T *data); static Channel *register_channel(void); +/// Initializes the module void channel_init() { channels = pmap_new(uint64_t)(); @@ -56,6 +57,7 @@ void channel_init() msgpack_sbuffer_init(&msgpack_event_buffer); } +/// Teardown the module void channel_teardown() { if (!channels) { @@ -69,6 +71,10 @@ void channel_teardown() }); } +/// Creates an API channel by starting a job and connecting to its +/// stdin/stdout. stderr is forwarded to the editor error stream. +/// +/// @param argv The argument vector for the process void channel_from_job(char **argv) { Channel *channel = register_channel(); @@ -76,6 +82,10 @@ void channel_from_job(char **argv) channel->data.job_id = job_start(argv, channel, job_out, job_err, NULL); } +/// Creates an API channel from a libuv stream representing a tcp or +/// pipe/socket client connection +/// +/// @param stream The established connection void channel_from_stream(uv_stream_t *stream) { Channel *channel = register_channel(); @@ -91,6 +101,13 @@ void channel_from_stream(uv_stream_t *stream) channel->data.streams.uv = stream; } +/// Sends event/data to channel +/// +/// @param id The channel id. If 0, the event will be sent to all +/// channels that have subscribed to the event type +/// @param type The event type, an arbitrary string +/// @param obj The event data +/// @return True if the data was sent successfully, false otherwise. bool channel_send_event(uint64_t id, char *type, typval_T *data) { Channel *channel = NULL; @@ -107,6 +124,10 @@ bool channel_send_event(uint64_t id, char *type, typval_T *data) return true; } +/// Subscribes to event broadcasts +/// +/// @param id The channel id +/// @param event The event type string void channel_subscribe(uint64_t id, char *event) { Channel *channel; @@ -125,6 +146,10 @@ void channel_subscribe(uint64_t id, char *event) pmap_put(cstr_t)(channel->subscribed_events, event_string, event_string); } +/// Unsubscribes to event broadcasts +/// +/// @param id The channel id +/// @param event The event type string void channel_unsubscribe(uint64_t id, char *event) { Channel *channel; diff --git a/src/nvim/os/channel.h b/src/nvim/os/channel.h index b88cd2445f..47182594b1 100644 --- a/src/nvim/os/channel.h +++ b/src/nvim/os/channel.h @@ -2,49 +2,24 @@ #define NVIM_OS_CHANNEL_H #include +#include #include "nvim/vim.h" #define EVENT_MAXLEN 512 -/// Initializes the module void channel_init(void); -/// Teardown the module void channel_teardown(void); -/// Creates an API channel from a libuv stream representing a tcp or -/// pipe/socket client connection -/// -/// @param stream The established connection void channel_from_stream(uv_stream_t *stream); -/// Creates an API channel by starting a job and connecting to its -/// stdin/stdout. stderr is forwarded to the editor error stream. -/// -/// @param argv The argument vector for the process void channel_from_job(char **argv); -/// Sends event/data to channel -/// -/// @param id The channel id. If 0, the event will be sent to all -/// channels that have subscribed to the event type -/// @param type The event type, an arbitrary string -/// @param obj The event data -/// @return True if the data was sent successfully, false otherwise. bool channel_send_event(uint64_t id, char *type, typval_T *data); -/// Subscribes to event broadcasts -/// -/// @param id The channel id -/// @param event The event type string void channel_subscribe(uint64_t id, char *event); -/// Unsubscribes to event broadcasts -/// -/// @param id The channel id -/// @param event The event type string void channel_unsubscribe(uint64_t id, char *event); #endif // NVIM_OS_CHANNEL_H - diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index e7cfb8b176..6d20028c05 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -51,6 +51,9 @@ char *os_getenvname_at_index(size_t index) } +/// Get the process ID of the Neovim process. +/// +/// @return the process ID. int64_t os_get_pid() { #ifdef _WIN32 @@ -60,6 +63,10 @@ int64_t os_get_pid() #endif } +/// Get the hostname of the machine runing Neovim. +/// +/// @param hostname Buffer to store the hostname. +/// @param len Length of `hostname`. void os_get_hostname(char *hostname, size_t len) { #ifdef HAVE_SYS_UTSNAME_H diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 861e1b46c5..a67e13ead1 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -14,7 +14,11 @@ static bool is_executable_in_path(const char_u *name); // Many fs functions from libuv return that value on success. static const int kLibuvSuccess = 0; -int os_chdir(const char *path) { +/// Change to the given directory. +/// +/// @return `0` on success, a libuv error code on failure. +int os_chdir(const char *path) +{ if (p_verbose >= 5) { verbose_enter(); smsg((char_u *)"chdir(%s)", path); @@ -23,6 +27,11 @@ int os_chdir(const char *path) { return uv_chdir(path); } +/// Get the name of current directory. +/// +/// @param buf Buffer to store the directory name. +/// @param len Length of `buf`. +/// @return `OK` for success, `FAIL` for failure. int os_dirname(char_u *buf, size_t len) { assert(buf && len); @@ -35,6 +44,9 @@ int os_dirname(char_u *buf, size_t len) return OK; } +/// Check if the given path is a directory or not. +/// +/// @return `true` if `fname` is a directory. bool os_isdir(const char_u *name) { int32_t mode = os_getperm(name); @@ -49,6 +61,14 @@ bool os_isdir(const char_u *name) return true; } +/// Check if the given path represents an executable file. +/// +/// @return `true` if `name` is executable and +/// - can be found in $PATH, +/// - is relative to current dir or +/// - is absolute. +/// +/// @return `false` otherwise. bool os_can_exe(const char_u *name) { // If it's an absolute or relative path don't need to use $PATH. @@ -125,6 +145,9 @@ static bool is_executable_in_path(const char_u *name) return false; } +/// Get stat information for a file. +/// +/// @return OK on success, FAIL if an failure occured. int os_stat(const char_u *name, uv_stat_t *statbuf) { uv_fs_t request; @@ -140,6 +163,9 @@ int os_stat(const char_u *name, uv_stat_t *statbuf) return FAIL; } +/// Get the file permissions for a given file. +/// +/// @return `-1` when `name` doesn't exist. int32_t os_getperm(const char_u *name) { uv_stat_t statbuf; @@ -150,6 +176,9 @@ int32_t os_getperm(const char_u *name) } } +/// Set the permission of a file. +/// +/// @return `OK` for success, `FAIL` for failure. int os_setperm(const char_u *name, int perm) { uv_fs_t request; @@ -164,6 +193,9 @@ int os_setperm(const char_u *name, int perm) return FAIL; } +/// Check if a file exists. +/// +/// @return `true` if `name` exists. bool os_file_exists(const char_u *name) { uv_stat_t statbuf; @@ -174,11 +206,19 @@ bool os_file_exists(const char_u *name) return false; } +/// Check if a file is readonly. +/// +/// @return `true` if `name` is readonly. bool os_file_is_readonly(const char *name) { return access(name, W_OK) != 0; } +/// Check if a file is writable. +/// +/// @return `0` if `name` is not writable, +/// @return `1` if `name` is writable, +/// @return `2` for a directory which we have rights to write into. int os_file_is_writable(const char *name) { if (access(name, W_OK) == 0) { @@ -190,6 +230,10 @@ int os_file_is_writable(const char *name) return 0; } +/// Get the size of a file in bytes. +/// +/// @param[out] size pointer to an off_t to put the size into. +/// @return `true` for success, `false` for failure. bool os_get_file_size(const char *name, off_t *size) { uv_stat_t statbuf; @@ -200,6 +244,9 @@ bool os_get_file_size(const char *name, off_t *size) return false; } +/// Rename a file or directory. +/// +/// @return `OK` for success, `FAIL` for failure. int os_rename(const char_u *path, const char_u *new_path) { uv_fs_t request; @@ -214,6 +261,9 @@ int os_rename(const char_u *path, const char_u *new_path) return FAIL; } +/// Make a directory. +/// +/// @return `0` for success, non-zero for failure. int os_mkdir(const char *path, int32_t mode) { uv_fs_t request; @@ -222,6 +272,9 @@ int os_mkdir(const char *path, int32_t mode) return result; } +/// Remove a directory. +/// +/// @return `0` for success, non-zero for failure. int os_rmdir(const char *path) { uv_fs_t request; @@ -230,6 +283,9 @@ int os_rmdir(const char *path) return result; } +/// Remove a file. +/// +/// @return `0` for success, non-zero for failure. int os_remove(const char *path) { uv_fs_t request; @@ -238,6 +294,11 @@ int os_remove(const char *path) return result; } +/// Get the file information for a given path +/// +/// @param file_descriptor File descriptor of the file. +/// @param[out] file_info Pointer to a FileInfo to put the information in. +/// @return `true` on sucess, `false` for failure. bool os_get_file_info(const char *path, FileInfo *file_info) { if (os_stat((char_u *)path, &(file_info->stat)) == OK) { @@ -246,6 +307,11 @@ bool os_get_file_info(const char *path, FileInfo *file_info) return false; } +/// Get the file information for a given path without following links +/// +/// @param path Path to the file. +/// @param[out] file_info Pointer to a FileInfo to put the information in. +/// @return `true` on sucess, `false` for failure. bool os_get_file_info_link(const char *path, FileInfo *file_info) { uv_fs_t request; @@ -258,6 +324,11 @@ bool os_get_file_info_link(const char *path, FileInfo *file_info) return false; } +/// Get the file information for a given file descriptor +/// +/// @param file_descriptor File descriptor of the file. +/// @param[out] file_info Pointer to a FileInfo to put the information in. +/// @return `true` on sucess, `false` for failure. bool os_get_file_info_fd(int file_descriptor, FileInfo *file_info) { uv_fs_t request; @@ -270,6 +341,9 @@ bool os_get_file_info_fd(int file_descriptor, FileInfo *file_info) return false; } +/// Compare the inodes of two FileInfos +/// +/// @return `true` if the two FileInfos represent the same file. bool os_file_info_id_equal(FileInfo *file_info_1, FileInfo *file_info_2) { return file_info_1->stat.st_ino == file_info_2->stat.st_ino diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index a673a6c8b8..95afa95d61 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -124,6 +124,10 @@ void os_breakcheck() fill_input_buf(false); } +/// Test whether a file descriptor refers to a terminal. +/// +/// @param fd File descriptor. +/// @return `true` if file descriptor refers to a terminal. bool os_isatty(int fd) { return uv_guess_handle(fd) == UV_TTY; diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h index 298df04578..57602336d5 100644 --- a/src/nvim/os/input.h +++ b/src/nvim/os/input.h @@ -13,10 +13,6 @@ int os_inchar(uint8_t *, int, int32_t, int); bool os_char_avail(void); void os_breakcheck(void); -/// Test whether a file descriptor refers to a terminal. -/// -/// @param fd File descriptor. -/// @return `true` if file descriptor refers to a terminal. bool os_isatty(int fd); #endif // NVIM_OS_INPUT_H diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c index c4a9c85d1d..d19e009421 100644 --- a/src/nvim/os/job.c +++ b/src/nvim/os/job.c @@ -69,12 +69,14 @@ static void exit_cb(uv_process_t *proc, int64_t status, int term_signal); static void close_cb(uv_handle_t *handle); static void emit_exit_event(Job *job); +/// Initializes job control resources void job_init() { uv_disable_stdio_inheritance(); uv_prepare_init(uv_default_loop(), &job_prepare); } +/// Releases job control resources and terminates running jobs void job_teardown() { // 20 tries will give processes about 1 sec to exit cleanly @@ -121,6 +123,19 @@ void job_teardown() } } +/// Tries to start a new job. +/// +/// @param argv Argument vector for the process. The first item is the +/// executable to run. +/// @param data Caller data that will be associated with the job +/// @param stdout_cb Callback that will be invoked when data is available +/// on stdout +/// @param stderr_cb Callback that will be invoked when data is available +/// on stderr +/// @param exit_cb Callback that will be invoked when the job exits +/// @return The job id if the job started successfully. If the the first item / +/// of `argv`(the program) could not be executed, -1 will be returned. +// 0 will be returned if the job table is full. int job_start(char **argv, void *data, rstream_cb stdout_cb, @@ -212,6 +227,12 @@ int job_start(char **argv, return job->id; } +/// Terminates a job. This is a non-blocking operation, but if the job exists +/// it's guaranteed to succeed(SIGKILL will eventually be sent) +/// +/// @param id The job id +/// @return true if the stop request was successfully sent, false if the job +/// id is invalid(probably because it has already stopped) bool job_stop(int id) { Job *job = find_job(id); @@ -225,6 +246,14 @@ bool job_stop(int id) return true; } +/// Writes data to the job's stdin. This is a non-blocking operation, it +/// returns when the write request was sent. +/// +/// @param id The job id +/// @param data Buffer containing the data to be written +/// @param len Size of the data +/// @return true if the write request was successfully sent, false if the job +/// id is invalid(probably because it has already stopped) bool job_write(int id, char *data, uint32_t len) { Job *job = find_job(id); @@ -242,6 +271,9 @@ bool job_write(int id, char *data, uint32_t len) return true; } +/// Runs the read callback associated with the job exit event +/// +/// @param event Object containing data necessary to invoke the callback void job_exit_event(Event event) { Job *job = event.data.job; @@ -265,11 +297,19 @@ void job_exit_event(Event event) } } +/// Get the job id +/// +/// @param job A pointer to the job +/// @return The job id int job_id(Job *job) { return job->id; } +/// Get data associated with a job +/// +/// @param job A pointer to the job +/// @return The job data void *job_data(Job *job) { return job->data; diff --git a/src/nvim/os/job.h b/src/nvim/os/job.h index 4ddbc75807..3d4c14a14a 100644 --- a/src/nvim/os/job.h +++ b/src/nvim/os/job.h @@ -13,65 +13,24 @@ #include "nvim/os/event_defs.h" #include "nvim/os/rstream_defs.h" -/// Initializes job control resources void job_init(void); -/// Releases job control resources and terminates running jobs void job_teardown(void); -/// Tries to start a new job. -/// -/// @param argv Argument vector for the process. The first item is the -/// executable to run. -/// @param data Caller data that will be associated with the job -/// @param stdout_cb Callback that will be invoked when data is available -/// on stdout -/// @param stderr_cb Callback that will be invoked when data is available -/// on stderr -/// @param exit_cb Callback that will be invoked when the job exits. This is -/// optional. -/// @return The job id if the job started successfully. If the the first item / -/// of `argv`(the program) could not be executed, -1 will be returned. -// 0 will be returned if the job table is full. int job_start(char **argv, void *data, rstream_cb stdout_cb, rstream_cb stderr_cb, job_exit_cb exit_cb); -/// Terminates a job. This is a non-blocking operation, but if the job exists -/// it's guaranteed to succeed(SIGKILL will eventually be sent) -/// -/// @param id The job id -/// @return true if the stop request was successfully sent, false if the job -/// id is invalid(probably because it has already stopped) bool job_stop(int id); -/// Writes data to the job's stdin. This is a non-blocking operation, it -/// returns when the write request was sent. -/// -/// @param id The job id -/// @param data Buffer containing the data to be written -/// @param len Size of the data -/// @return true if the write request was successfully sent, false if the job -/// id is invalid(probably because it has already stopped) bool job_write(int id, char *data, uint32_t len); -/// Runs the read callback associated with the job exit event -/// -/// @param event Object containing data necessary to invoke the callback void job_exit_event(Event event); -/// Get the job id -/// -/// @param job A pointer to the job -/// @return The job id int job_id(Job *job); -/// Get data associated with a job -/// -/// @param job A pointer to the job -/// @return The job data void *job_data(Job *job); #endif // NVIM_OS_JOB_H diff --git a/src/nvim/os/mem.c b/src/nvim/os/mem.c index 6c8b49d04e..5e483c0c3d 100644 --- a/src/nvim/os/mem.c +++ b/src/nvim/os/mem.c @@ -4,7 +4,9 @@ #include "nvim/os/os.h" -uint64_t os_get_total_mem_kib(void) { +/// Get the total system physical memory in KiB. +uint64_t os_get_total_mem_kib(void) +{ // Convert bytes to KiB. return uv_get_total_memory() >> 10; } diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h index fa040d29bd..73e09e5012 100644 --- a/src/nvim/os/os.h +++ b/src/nvim/os/os.h @@ -4,101 +4,41 @@ #include "nvim/vim.h" -/// Change to the given directory. -/// -/// @return `0` on success, a libuv error code on failure. int os_chdir(const char *path); -/// Get the name of current directory. -/// -/// @param buf Buffer to store the directory name. -/// @param len Length of `buf`. -/// @return `OK` for success, `FAIL` for failure. int os_dirname(char_u *buf, size_t len); -/// Check if the given path is a directory or not. -/// -/// @return `true` if `fname` is a directory. bool os_isdir(const char_u *name); -/// Check if the given path represents an executable file. -/// -/// @return `true` if `name` is executable and -/// - can be found in $PATH, -/// - is relative to current dir or -/// - is absolute. -/// -/// @return `false` otherwise. bool os_can_exe(const char_u *name); -/// Get the file permissions for a given file. -/// -/// @return `-1` when `name` doesn't exist. int32_t os_getperm(const char_u *name); -/// Set the permission of a file. -/// -/// @return `OK` for success, `FAIL` for failure. int os_setperm(const char_u *name, int perm); -/// Check if a file exists. -/// -/// @return `true` if `name` exists. bool os_file_exists(const char_u *name); -/// Check if a file is readonly. -/// -/// @return `true` if `name` is readonly. bool os_file_is_readonly(const char *name); -/// Check if a file is writable. -/// -/// @return `0` if `name` is not writable, -/// @return `1` if `name` is writable, -/// @return `2` for a directory which we have rights to write into. int os_file_is_writable(const char *name); -/// Get the size of a file in bytes. -/// -/// @param[out] size pointer to an off_t to put the size into. -/// @return `true` for success, `false` for failure. bool os_get_file_size(const char *name, off_t *size); -/// Rename a file or directory. -/// -/// @return `OK` for success, `FAIL` for failure. int os_rename(const char_u *path, const char_u *new_path); -/// Make a directory. -/// -/// @return `0` for success, non-zero for failure. int os_mkdir(const char *path, int32_t mode); -/// Remove a directory. -/// -/// @return `0` for success, non-zero for failure. int os_rmdir(const char *path); -/// Remove a file. -/// -/// @return `0` for success, non-zero for failure. int os_remove(const char *path); -/// Get the total system physical memory in KiB. uint64_t os_get_total_mem_kib(void); const char *os_getenv(const char *name); int os_setenv(const char *name, const char *value, int overwrite); char *os_getenvname_at_index(size_t index); -/// Get the process ID of the Neovim process. -/// -/// @return the process ID. int64_t os_get_pid(void); -/// Get the hostname of the machine runing Neovim. -/// -/// @param hostname Buffer to store the hostname. -/// @param len Length of `hostname`. void os_get_hostname(char *hostname, size_t len); int os_get_usernames(garray_T *usernames); @@ -106,9 +46,6 @@ int os_get_user_name(char *s, size_t len); int os_get_uname(uid_t uid, char *s, size_t len); char *os_get_user_directory(const char *name); -/// Get stat information for a file. -/// -/// @return OK on success, FAIL if an failure occured. int os_stat(const char_u *name, uv_stat_t *statbuf); /// Struct which encapsulates stat information. @@ -117,30 +54,12 @@ typedef struct { uv_stat_t stat; } FileInfo; -/// Get the file information for a given path -/// -/// @param file_descriptor File descriptor of the file. -/// @param[out] file_info Pointer to a FileInfo to put the information in. -/// @return `true` on sucess, `false` for failure. bool os_get_file_info(const char *path, FileInfo *file_info); -/// Get the file information for a given path without following links -/// -/// @param path Path to the file. -/// @param[out] file_info Pointer to a FileInfo to put the information in. -/// @return `true` on sucess, `false` for failure. bool os_get_file_info_link(const char *path, FileInfo *file_info); -/// Get the file information for a given file descriptor -/// -/// @param file_descriptor File descriptor of the file. -/// @param[out] file_info Pointer to a FileInfo to put the information in. -/// @return `true` on sucess, `false` for failure. bool os_get_file_info_fd(int file_descriptor, FileInfo *file_info); -/// Compare the inodes of two FileInfos -/// -/// @return `true` if the two FileInfos represent the same file. bool os_file_info_id_equal(FileInfo *file_info_1, FileInfo *file_info_2); #endif // NVIM_OS_OS_H diff --git a/src/nvim/os/rstream.c b/src/nvim/os/rstream.c index 4e6fc55d3b..be37204de6 100644 --- a/src/nvim/os/rstream.c +++ b/src/nvim/os/rstream.c @@ -34,6 +34,18 @@ static void fread_idle_cb(uv_idle_t *); static void close_cb(uv_handle_t *handle); static void emit_read_event(RStream *rstream, bool eof); +/// Creates a new RStream instance. A RStream encapsulates all the boilerplate +/// necessary for reading from a libuv stream. +/// +/// @param cb A function that will be called whenever some data is available +/// for reading with `rstream_read` +/// @param buffer_size Size in bytes of the internal buffer. +/// @param data Some state to associate with the `RStream` instance +/// @param async Flag that specifies if the callback should only be called +/// outside libuv event loop(When processing async events with +/// KE_EVENT). Only the RStream instance reading user input should set +/// this to false +/// @return The newly-allocated `RStream` instance RStream * rstream_new(rstream_cb cb, size_t buffer_size, void *data, @@ -54,6 +66,9 @@ RStream * rstream_new(rstream_cb cb, return rv; } +/// Frees all memory allocated for a RStream instance +/// +/// @param rstream The `RStream` instance void rstream_free(RStream *rstream) { if (rstream->free_handle) { @@ -68,12 +83,21 @@ void rstream_free(RStream *rstream) free(rstream); } +/// Sets the underlying `uv_stream_t` instance +/// +/// @param rstream The `RStream` instance +/// @param stream The new `uv_stream_t` instance void rstream_set_stream(RStream *rstream, uv_stream_t *stream) { handle_set_rstream((uv_handle_t *)stream, rstream); rstream->stream = stream; } +/// Sets the underlying file descriptor that will be read from. Only pipes +/// and regular files are supported for now. +/// +/// @param rstream The `RStream` instance +/// @param file The file descriptor void rstream_set_file(RStream *rstream, uv_file file) { rstream->file_type = uv_guess_handle(file); @@ -111,11 +135,18 @@ void rstream_set_file(RStream *rstream, uv_file file) rstream->free_handle = true; } +/// Tests if the stream is backed by a regular file +/// +/// @param rstream The `RStream` instance +/// @return True if the underlying file descriptor represents a regular file bool rstream_is_regular_file(RStream *rstream) { return rstream->file_type == UV_FILE; } +/// Starts watching for events from a `RStream` instance. +/// +/// @param rstream The `RStream` instance void rstream_start(RStream *rstream) { if (rstream->file_type == UV_FILE) { @@ -126,6 +157,9 @@ void rstream_start(RStream *rstream) } } +/// Stops watching for events from a `RStream` instance. +/// +/// @param rstream The `RStream` instance void rstream_stop(RStream *rstream) { if (rstream->file_type == UV_FILE) { @@ -135,6 +169,12 @@ void rstream_stop(RStream *rstream) } } +/// Reads data from a `RStream` instance into a buffer. +/// +/// @param rstream The `RStream` instance +/// @param buffer The buffer which will receive the data +/// @param count Number of bytes that `buffer` can accept +/// @return The number of bytes copied into `buffer` size_t rstream_read(RStream *rstream, char *buf, size_t count) { size_t read_count = rstream->wpos - rstream->rpos; @@ -167,11 +207,18 @@ size_t rstream_read(RStream *rstream, char *buf, size_t count) return read_count; } +/// Returns the number of bytes available for reading from `rstream` +/// +/// @param rstream The `RStream` instance +/// @return The number of bytes available size_t rstream_available(RStream *rstream) { return rstream->wpos - rstream->rpos; } +/// Runs the read callback associated with the rstream +/// +/// @param event Object containing data necessary to invoke the callback void rstream_read_event(Event event) { RStream *rstream = event.data.rstream.ptr; diff --git a/src/nvim/os/rstream.h b/src/nvim/os/rstream.h index 5afa864f04..b93430ebcf 100644 --- a/src/nvim/os/rstream.h +++ b/src/nvim/os/rstream.h @@ -8,74 +8,27 @@ #include "nvim/os/event_defs.h" #include "nvim/os/rstream_defs.h" -/// Creates a new RStream instance. A RStream encapsulates all the boilerplate -/// necessary for reading from a libuv stream. -/// -/// @param cb A function that will be called whenever some data is available -/// for reading with `rstream_read` -/// @param buffer_size Size in bytes of the internal buffer. -/// @param data Some state to associate with the `RStream` instance -/// @param async Flag that specifies if the callback should only be called -/// outside libuv event loop(When processing async events with -/// KE_EVENT). Only the RStream instance reading user input should set -/// this to false -/// @return The newly-allocated `RStream` instance RStream * rstream_new(rstream_cb cb, size_t buffer_size, void *data, bool async); -/// Frees all memory allocated for a RStream instance -/// -/// @param rstream The `RStream` instance void rstream_free(RStream *rstream); -/// Sets the underlying `uv_stream_t` instance -/// -/// @param rstream The `RStream` instance -/// @param stream The new `uv_stream_t` instance void rstream_set_stream(RStream *rstream, uv_stream_t *stream); -/// Sets the underlying file descriptor that will be read from. Only pipes -/// and regular files are supported for now. -/// -/// @param rstream The `RStream` instance -/// @param file The file descriptor void rstream_set_file(RStream *rstream, uv_file file); -/// Tests if the stream is backed by a regular file -/// -/// @param rstream The `RStream` instance -/// @return True if the underlying file descriptor represents a regular file bool rstream_is_regular_file(RStream *rstream); -/// Starts watching for events from a `RStream` instance. -/// -/// @param rstream The `RStream` instance void rstream_start(RStream *rstream); -/// Stops watching for events from a `RStream` instance. -/// -/// @param rstream The `RStream` instance void rstream_stop(RStream *rstream); -/// Reads data from a `RStream` instance into a buffer. -/// -/// @param rstream The `RStream` instance -/// @param buffer The buffer which will receive the data -/// @param count Number of bytes that `buffer` can accept -/// @return The number of bytes copied into `buffer` size_t rstream_read(RStream *rstream, char *buffer, size_t count); -/// Returns the number of bytes available for reading from `rstream` -/// -/// @param rstream The `RStream` instance -/// @return The number of bytes available size_t rstream_available(RStream *rstream); -/// Runs the read callback associated with the rstream -/// -/// @param event Object containing data necessary to invoke the callback void rstream_read_event(Event event); #endif // NVIM_OS_RSTREAM_H diff --git a/src/nvim/os/server.c b/src/nvim/os/server.c index 4aac2babc6..18a941a264 100644 --- a/src/nvim/os/server.c +++ b/src/nvim/os/server.c @@ -46,6 +46,7 @@ static void connection_cb(uv_stream_t *server, int status); static void free_client(uv_handle_t *handle); static void free_server(uv_handle_t *handle); +/// Initializes the module void server_init() { servers = pmap_new(cstr_t)(); @@ -59,6 +60,7 @@ void server_init() server_start((char *)os_getenv("NEOVIM_LISTEN_ADDRESS")); } +/// Teardown the server module void server_teardown() { if (!servers) { @@ -76,6 +78,15 @@ void server_teardown() }); } +/// Starts listening on arbitrary tcp/unix addresses specified by +/// `endpoint` for API calls. The type of socket used(tcp or unix/pipe) will +/// be determined by parsing `endpoint`: If it's a valid tcp address in the +/// 'ip:port' format, then it will be tcp socket, else it will be a unix +/// socket or named pipe. +/// +/// @param endpoint Address of the server. Either a 'ip:port' string or an +/// arbitrary identifier(trimmed to 256 bytes) for the unix socket or +/// named pipe. void server_start(char *endpoint) { char addr[ADDRESS_MAX_SIZE]; @@ -175,6 +186,9 @@ void server_start(char *endpoint) pmap_put(cstr_t)(servers, addr, server); } +/// Stops listening on the address specified by `endpoint`. +/// +/// @param endpoint Address of the server. void server_stop(char *endpoint) { Server *server; diff --git a/src/nvim/os/server.h b/src/nvim/os/server.h index f6270b42e9..9023dd8b3d 100644 --- a/src/nvim/os/server.h +++ b/src/nvim/os/server.h @@ -1,26 +1,12 @@ #ifndef NVIM_OS_SERVER_H #define NVIM_OS_SERVER_H -/// Initializes the module void server_init(); -/// Teardown the server module void server_teardown(); -/// Starts listening on arbitrary tcp/unix addresses specified by -/// `endpoint` for API calls. The type of socket used(tcp or unix/pipe) will -/// be determined by parsing `endpoint`: If it's a valid tcp address in the -/// 'ip:port' format, then it will be tcp socket, else it will be a unix -/// socket or named pipe. -/// -/// @param endpoint Address of the server. Either a 'ip:port' string or an -/// arbitrary identifier(trimmed to 256 bytes) for the unix socket or -/// named pipe. void server_start(char *endpoint); -/// Stops listening on the address specified by `endpoint`. -/// -/// @param endpoint Address of the server. void server_stop(char *endpoint); #endif // NVIM_OS_SERVER_H diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 8e49f8f2bb..5e02c3504b 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -31,33 +31,12 @@ typedef struct { garray_T ga; } ProcessData; -/// Parses a command string into a sequence of words, taking quotes into -/// consideration. -/// -/// @param str The command string to be parsed -/// @param argv The vector that will be filled with copies of the parsed -/// words. It can be NULL if the caller only needs to count words. -/// @return The number of words parsed. static int tokenize(char_u *str, char **argv); -/// Calculates the length of a shell word. -/// -/// @param str A pointer to the first character of the word -/// @return The offset from `str` at which the word ends. static int word_length(char_u *command); -/// Queues selected range for writing to the child process stdin. -/// -/// @param req The structure containing information to peform the write static void write_selection(uv_write_t *req); -/// Cleanup memory and restore state modified by `os_call_shell`. -/// -/// @param data State shared by all functions collaborating with -/// `os_call_shell`. -/// @param opts Process spawning options, containing some allocated memory -/// @param shellopts Options passed to `os_call_shell`. Used for deciding -/// if/which messages are displayed. static int proc_cleanup_exit(ProcessData *data, uv_process_options_t *opts, int shellopts); @@ -67,6 +46,14 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf); static void write_cb(uv_write_t *req, int status); static void exit_cb(uv_process_t *proc, int64_t status, int term_signal); +/// Builds the argument vector for running the shell configured in `sh` +/// ('shell' option), optionally with a command that will be passed with `shcf` +/// ('shellcmdflag'). +/// +/// @param cmd Command string. If NULL it will run an interactive shell. +/// @param extra_shell_opt Extra argument to the shell. If NULL it is ignored +/// @return A newly allocated argument vector. It must be freed with +/// `shell_free_argv` when no longer needed. char ** shell_build_argv(char_u *cmd, char_u *extra_shell_opt) { int i; @@ -94,6 +81,9 @@ char ** shell_build_argv(char_u *cmd, char_u *extra_shell_opt) return rv; } +/// Releases the memory allocated by `shell_build_argv`. +/// +/// @param argv The argument vector. void shell_free_argv(char **argv) { char **p = argv; @@ -112,6 +102,13 @@ void shell_free_argv(char **argv) free(argv); } +/// Calls the user shell for running a command, interactive session or +/// wildcard expansion. It uses the shell set in the `sh` option. +/// +/// @param cmd The command to be executed. If NULL it will run an interactive +/// shell +/// @param opts Various options that control how the shell will work +/// @param extra_shell_arg Extra argument to be passed to the shell int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg) { uv_stdio_container_t proc_stdio[3]; @@ -247,6 +244,13 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg) return proc_cleanup_exit(&pdata, &proc_opts, opts); } +/// Parses a command string into a sequence of words, taking quotes into +/// consideration. +/// +/// @param str The command string to be parsed +/// @param argv The vector that will be filled with copies of the parsed +/// words. It can be NULL if the caller only needs to count words. +/// @return The number of words parsed. static int tokenize(char_u *str, char **argv) { int argc = 0, len; @@ -270,6 +274,10 @@ static int tokenize(char_u *str, char **argv) return argc; } +/// Calculates the length of a shell word. +/// +/// @param str A pointer to the first character of the word +/// @return The offset from `str` at which the word ends. static int word_length(char_u *str) { char_u *p = str; @@ -296,6 +304,9 @@ static int word_length(char_u *str) /// event loop starts. If we don't(by writing in chunks returned by `ml_get`) /// the buffer being modified might get modified by reading from the process /// before we finish writing. +/// Queues selected range for writing to the child process stdin. +/// +/// @param req The structure containing information to peform the write static void write_selection(uv_write_t *req) { ProcessData *pdata = (ProcessData *)req->data; @@ -429,6 +440,13 @@ static void write_cb(uv_write_t *req, int status) pdata->exited++; } +/// Cleanup memory and restore state modified by `os_call_shell`. +/// +/// @param data State shared by all functions collaborating with +/// `os_call_shell`. +/// @param opts Process spawning options, containing some allocated memory +/// @param shellopts Options passed to `os_call_shell`. Used for deciding +/// if/which messages are displayed. static int proc_cleanup_exit(ProcessData *proc_data, uv_process_options_t *proc_opts, int shellopts) diff --git a/src/nvim/os/shell.h b/src/nvim/os/shell.h index 226ef97579..a63fed7277 100644 --- a/src/nvim/os/shell.h +++ b/src/nvim/os/shell.h @@ -17,28 +17,10 @@ typedef enum { kShellOptHideMess = 128, ///< previously a global variable from os_unix.c } ShellOpts; -/// Builds the argument vector for running the shell configured in `sh` -/// ('shell' option), optionally with a command that will be passed with `shcf` -/// ('shellcmdflag'). -/// -/// @param cmd Command string. If NULL it will run an interactive shell. -/// @param extra_shell_opt Extra argument to the shell. If NULL it is ignored -/// @return A newly allocated argument vector. It must be freed with -/// `shell_free_argv` when no longer needed. char ** shell_build_argv(char_u *cmd, char_u *extra_shell_arg); -/// Releases the memory allocated by `shell_build_argv`. -/// -/// @param argv The argument vector. void shell_free_argv(char **argv); -/// Calls the user shell for running a command, interactive session or -/// wildcard expansion. It uses the shell set in the `sh` option. -/// -/// @param cmd The command to be executed. If NULL it will run an interactive -/// shell -/// @param opts Various options that control how the shell will work -/// @param extra_shell_arg Extra argument to be passed to the shell int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg); #endif // NVIM_OS_SHELL_H diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 2a607de36d..66f9405510 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -13,17 +13,26 @@ static uv_cond_t delay_cond; static void microdelay(uint64_t ms); +/// Initializes the time module void time_init() { uv_mutex_init(&delay_mutex); uv_cond_init(&delay_cond); } +/// Sleeps for a certain amount of milliseconds +/// +/// @param milliseconds Number of milliseconds to sleep +/// @param ignoreinput If true, allow a SIGINT to interrupt us void os_delay(uint64_t milliseconds, bool ignoreinput) { os_microdelay(milliseconds * 1000, ignoreinput); } +/// Sleeps for a certain amount of microseconds +/// +/// @param microseconds Number of microseconds to sleep +/// @param ignoreinput If true, allow a SIGINT to interrupt us void os_microdelay(uint64_t microseconds, bool ignoreinput) { int old_tmode; @@ -61,6 +70,9 @@ static void microdelay(uint64_t microseconds) uv_mutex_unlock(&delay_mutex); } +/// Portable version of POSIX localtime_r() +/// +/// @return NULL in case of error struct tm *os_localtime_r(const time_t *clock, struct tm *result) { #ifdef UNIX @@ -75,6 +87,11 @@ return result; #endif } +/// Obtains the current UNIX timestamp and adjusts it to local time +/// +/// @param result Pointer to a 'struct tm' where the result should be placed +/// @return A pointer to a 'struct tm' in the current time zone (the 'result' +/// argument) or NULL in case of error struct tm *os_get_localtime(struct tm *result) { struct timeval tv; diff --git a/src/nvim/os/time.h b/src/nvim/os/time.h index 02fd77551e..3b185825be 100644 --- a/src/nvim/os/time.h +++ b/src/nvim/os/time.h @@ -4,31 +4,14 @@ #include #include -/// Initializes the time module void time_init(void); -/// Sleeps for a certain amount of milliseconds -/// -/// @param milliseconds Number of milliseconds to sleep -/// @param ignoreinput If true, allow a SIGINT to interrupt us void os_delay(uint64_t milliseconds, bool ignoreinput); -/// Sleeps for a certain amount of microseconds -/// -/// @param microseconds Number of microseconds to sleep -/// @param ignoreinput If true, allow a SIGINT to interrupt us void os_microdelay(uint64_t microseconds, bool ignoreinput); -/// Portable version of POSIX localtime_r() -/// -/// @return NULL in case of error struct tm *os_localtime_r(const time_t *clock, struct tm *result); -/// Obtains the current UNIX timestamp and adjusts it to local time -/// -/// @param result Pointer to a 'struct tm' where the result should be placed -/// @return A pointer to a 'struct tm' in the current time zone (the 'result' -/// argument) or NULL in case of error struct tm *os_get_localtime(struct tm *result); #endif // NVIM_OS_TIME_H diff --git a/src/nvim/os/uv_helpers.c b/src/nvim/os/uv_helpers.c index f8371c04c2..fa81fcdcc6 100644 --- a/src/nvim/os/uv_helpers.c +++ b/src/nvim/os/uv_helpers.c @@ -15,6 +15,10 @@ typedef struct { static HandleData *init(uv_handle_t *handle); +/// Gets the RStream instance associated with a libuv handle +/// +/// @param handle libuv handle +/// @return the RStream pointer RStream *handle_get_rstream(uv_handle_t *handle) { RStream *rv = init(handle)->rstream; @@ -22,11 +26,19 @@ RStream *handle_get_rstream(uv_handle_t *handle) return rv; } +/// Associates a RStream instance with a libuv handle +/// +/// @param handle libuv handle +/// @param rstream the RStream pointer void handle_set_rstream(uv_handle_t *handle, RStream *rstream) { init(handle)->rstream = rstream; } +/// Gets the WStream instance associated with a libuv handle +/// +/// @param handle libuv handle +/// @return the WStream pointer WStream *handle_get_wstream(uv_handle_t *handle) { WStream *rv = init(handle)->wstream; @@ -34,12 +46,20 @@ WStream *handle_get_wstream(uv_handle_t *handle) return rv; } +/// Associates a WStream instance with a libuv handle +/// +/// @param handle libuv handle +/// @param wstream the WStream pointer void handle_set_wstream(uv_handle_t *handle, WStream *wstream) { HandleData *data = init(handle); data->wstream = wstream; } +/// Gets the Job instance associated with a libuv handle +/// +/// @param handle libuv handle +/// @return the Job pointer Job *handle_get_job(uv_handle_t *handle) { Job *rv = init(handle)->job; @@ -47,6 +67,10 @@ Job *handle_get_job(uv_handle_t *handle) return rv; } +/// Associates a Job instance with a libuv handle +/// +/// @param handle libuv handle +/// @param job the Job pointer void handle_set_job(uv_handle_t *handle, Job *job) { init(handle)->job = job; diff --git a/src/nvim/os/uv_helpers.h b/src/nvim/os/uv_helpers.h index 03fd64457f..ea797ba9f0 100644 --- a/src/nvim/os/uv_helpers.h +++ b/src/nvim/os/uv_helpers.h @@ -7,40 +7,16 @@ #include "nvim/os/rstream_defs.h" #include "nvim/os/job_defs.h" -/// Gets the RStream instance associated with a libuv handle -/// -/// @param handle libuv handle -/// @return the RStream pointer RStream *handle_get_rstream(uv_handle_t *handle); -/// Associates a RStream instance with a libuv handle -/// -/// @param handle libuv handle -/// @param rstream the RStream pointer void handle_set_rstream(uv_handle_t *handle, RStream *rstream); -/// Gets the WStream instance associated with a libuv handle -/// -/// @param handle libuv handle -/// @return the WStream pointer WStream *handle_get_wstream(uv_handle_t *handle); -/// Associates a WStream instance with a libuv handle -/// -/// @param handle libuv handle -/// @param wstream the WStream pointer void handle_set_wstream(uv_handle_t *handle, WStream *wstream); -/// Gets the Job instance associated with a libuv handle -/// -/// @param handle libuv handle -/// @return the Job pointer Job *handle_get_job(uv_handle_t *handle); -/// Associates a Job instance with a libuv handle -/// -/// @param handle libuv handle -/// @param job the Job pointer void handle_set_job(uv_handle_t *handle, Job *job); #endif // NVIM_OS_UV_HELPERS_H diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index 57afdd0e8f..b5c396b50c 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -32,6 +32,11 @@ typedef struct { static void write_cb(uv_write_t *req, int status); +/// Creates a new WStream instance. A WStream encapsulates all the boilerplate +/// necessary for writing to a libuv stream. +/// +/// @param maxmem Maximum amount memory used by this `WStream` instance. +/// @return The newly-allocated `WStream` instance WStream * wstream_new(size_t maxmem) { WStream *rv = xmalloc(sizeof(WStream)); @@ -44,6 +49,9 @@ WStream * wstream_new(size_t maxmem) return rv; } +/// Frees all memory allocated for a WStream instance +/// +/// @param wstream The `WStream` instance void wstream_free(WStream *wstream) { if (!wstream->pending_reqs) { @@ -53,12 +61,23 @@ void wstream_free(WStream *wstream) } } +/// Sets the underlying `uv_stream_t` instance +/// +/// @param wstream The `WStream` instance +/// @param stream The new `uv_stream_t` instance void wstream_set_stream(WStream *wstream, uv_stream_t *stream) { handle_set_wstream((uv_handle_t *)stream, wstream); wstream->stream = stream; } +/// Queues data for writing to the backing file descriptor of a `WStream` +/// instance. This will fail if the write would cause the WStream use more +/// memory than specified by `maxmem`. +/// +/// @param wstream The `WStream` instance +/// @param buffer The buffer which contains data to be written +/// @return false if the write failed bool wstream_write(WStream *wstream, WBuffer *buffer) { WriteData *data; @@ -87,6 +106,15 @@ bool wstream_write(WStream *wstream, WBuffer *buffer) return true; } +/// Creates a WBuffer object for holding output data. Instances of this +/// object can be reused across WStream instances, and the memory is freed +/// automatically when no longer needed(it tracks the number of references +/// internally) +/// +/// @param data Data stored by the WBuffer +/// @param size The size of the data array +/// @param copy If true, the data will be copied into the WBuffer +/// @return The allocated WBuffer instance WBuffer *wstream_new_buffer(char *data, size_t size, bool copy) { WBuffer *rv = xmalloc(sizeof(WBuffer)); diff --git a/src/nvim/os/wstream.h b/src/nvim/os/wstream.h index 1f61f6afd0..e133ef1385 100644 --- a/src/nvim/os/wstream.h +++ b/src/nvim/os/wstream.h @@ -7,42 +7,14 @@ #include "nvim/os/wstream_defs.h" -/// Creates a new WStream instance. A WStream encapsulates all the boilerplate -/// necessary for writing to a libuv stream. -/// -/// @param maxmem Maximum amount memory used by this `WStream` instance. -/// @return The newly-allocated `WStream` instance WStream * wstream_new(size_t maxmem); -/// Frees all memory allocated for a WStream instance -/// -/// @param wstream The `WStream` instance void wstream_free(WStream *wstream); -/// Sets the underlying `uv_stream_t` instance -/// -/// @param wstream The `WStream` instance -/// @param stream The new `uv_stream_t` instance void wstream_set_stream(WStream *wstream, uv_stream_t *stream); -/// Queues data for writing to the backing file descriptor of a `WStream` -/// instance. This will fail if the write would cause the WStream use more -/// memory than specified by `maxmem`. -/// -/// @param wstream The `WStream` instance -/// @param buffer The buffer which contains data to be written -/// @return false if the write failed bool wstream_write(WStream *wstream, WBuffer *buffer); -/// Creates a WBuffer object for holding output data. Instances of this -/// object can be reused across WStream instances, and the memory is freed -/// automatically when no longer needed(it tracks the number of references -/// internally) -/// -/// @param data Data stored by the WBuffer -/// @param size The size of the data array -/// @param copy If true, the data will be copied into the WBuffer -/// @return The allocated WBuffer instance WBuffer *wstream_new_buffer(char *data, size_t size, bool copy); #endif // NVIM_OS_WSTREAM_H -- cgit From 70929f7e1616bab2783cc5735c6061981cda8a0f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 10 May 2014 17:24:13 +0400 Subject: Add automatic generation of headers - The 'stripdecls.py' script replaces declarations in all headers by includes to generated headers. `ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'` was used for this. - Add and integrate gendeclarations.lua into the build system to generate the required includes. - Add -Wno-unused-function - Made a bunch of old-style definitions ANSI This adds a requirement: all type and structure definitions must be present before INCLUDE_GENERATED_DECLARATIONS-protected include. Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is the only exception. --- src/nvim/os/channel.c | 13 +++---------- src/nvim/os/channel.h | 17 +++-------------- src/nvim/os/event.c | 5 +++-- src/nvim/os/event.h | 11 +++-------- src/nvim/os/fs.c | 6 +++--- src/nvim/os/input.c | 7 +++---- src/nvim/os/input.h | 15 +++------------ src/nvim/os/job.c | 11 +++-------- src/nvim/os/job.h | 24 +++--------------------- src/nvim/os/job_defs.h | 1 - src/nvim/os/rstream.c | 11 +++++------ src/nvim/os/rstream.h | 27 +++------------------------ src/nvim/os/server.c | 6 +++--- src/nvim/os/server.h | 12 +++--------- src/nvim/os/shell.c | 13 +++---------- src/nvim/os/shell.h | 6 +++--- src/nvim/os/signal.c | 6 +++--- src/nvim/os/signal.h | 8 +++----- src/nvim/os/time.c | 4 +++- src/nvim/os/time.h | 8 +++----- src/nvim/os/uv_helpers.c | 5 ++++- src/nvim/os/uv_helpers.h | 16 +++------------- src/nvim/os/wstream.c | 4 +++- src/nvim/os/wstream.h | 14 +++----------- 24 files changed, 72 insertions(+), 178 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index 5886620990..9a692cf9fe 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -38,16 +38,9 @@ static PMap(uint64_t) *channels = NULL; static PMap(cstr_t) *event_strings = NULL; static msgpack_sbuffer msgpack_event_buffer; -static void job_out(RStream *rstream, void *data, bool eof); -static void job_err(RStream *rstream, void *data, bool eof); -static void parse_msgpack(RStream *rstream, void *data, bool eof); -static void send_event(Channel *channel, char *type, typval_T *data); -static void broadcast_event(char *type, typval_T *data); -static void unsubscribe(Channel *channel, char *event); -static void close_channel(Channel *channel); -static void close_cb(uv_handle_t *handle); -static WBuffer *serialize_event(char *type, typval_T *data); -static Channel *register_channel(void); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/channel.c.generated.h" +#endif /// Initializes the module void channel_init() diff --git a/src/nvim/os/channel.h b/src/nvim/os/channel.h index 47182594b1..240461d22e 100644 --- a/src/nvim/os/channel.h +++ b/src/nvim/os/channel.h @@ -8,18 +8,7 @@ #define EVENT_MAXLEN 512 -void channel_init(void); - -void channel_teardown(void); - -void channel_from_stream(uv_stream_t *stream); - -void channel_from_job(char **argv); - -bool channel_send_event(uint64_t id, char *type, typval_T *data); - -void channel_subscribe(uint64_t id, char *event); - -void channel_unsubscribe(uint64_t id, char *event); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/channel.h.generated.h" +#endif #endif // NVIM_OS_CHANNEL_H diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index a89dcdc2ed..dd2b9ba0d1 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -20,11 +20,12 @@ #define _destroy_event(x) // do nothing KLIST_INIT(Event, Event, _destroy_event) +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/event.c.generated.h" +#endif static klist_t(Event) *event_queue; static uv_timer_t timer; static uv_prepare_t timer_prepare; -static void timer_cb(uv_timer_t *handle); -static void timer_prepare_cb(uv_prepare_t *); void event_init() { diff --git a/src/nvim/os/event.h b/src/nvim/os/event.h index 345ddba27e..29e304adc8 100644 --- a/src/nvim/os/event.h +++ b/src/nvim/os/event.h @@ -7,12 +7,7 @@ #include "nvim/os/event_defs.h" #include "nvim/os/job_defs.h" -void event_init(void); -void event_teardown(void); -bool event_poll(int32_t ms); -bool event_is_pending(void); -void event_push(Event event); -void event_process(void); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/event.h.generated.h" +#endif #endif // NVIM_OS_EVENT_H - diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index a67e13ead1..bdf20f22eb 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -8,8 +8,9 @@ #include "nvim/path.h" #include "nvim/strings.h" -static bool is_executable(const char_u *name); -static bool is_executable_in_path(const char_u *name); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/fs.c.generated.h" +#endif // Many fs functions from libuv return that value on success. static const int kLibuvSuccess = 0; @@ -349,4 +350,3 @@ bool os_file_info_id_equal(FileInfo *file_info_1, FileInfo *file_info_2) return file_info_1->stat.st_ino == file_info_2->stat.st_ino && file_info_1->stat.st_dev == file_info_2->stat.st_dev; } - diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 95afa95d61..3e9751a4db 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -25,12 +25,11 @@ typedef enum { static RStream *read_stream; static bool eof = false, started_reading = false; -static InbufPollResult inbuf_poll(int32_t ms); -static void stderr_switch(void); -static void read_cb(RStream *rstream, void *data, bool eof); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/input.c.generated.h" +#endif // Helper function used to push bytes from the 'event' key sequence partially // between calls to os_inchar when maxlen < 3 -static int push_event_key(uint8_t *buf, int maxlen); void input_init() { diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h index 57602336d5..7543950b4f 100644 --- a/src/nvim/os/input.h +++ b/src/nvim/os/input.h @@ -4,16 +4,7 @@ #include #include -void input_init(void); -bool input_ready(void); -void input_start(void); -void input_stop(void); -uint32_t input_read(char *buf, uint32_t count); -int os_inchar(uint8_t *, int, int32_t, int); -bool os_char_avail(void); -void os_breakcheck(void); - -bool os_isatty(int fd); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/input.h.generated.h" +#endif #endif // NVIM_OS_INPUT_H - diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c index d19e009421..f9f94158ae 100644 --- a/src/nvim/os/job.c +++ b/src/nvim/os/job.c @@ -58,16 +58,11 @@ static uint32_t job_count = 0; static uv_prepare_t job_prepare; // Some helpers shared in this module -static bool is_alive(Job *job); -static Job * find_job(int id); -static void free_job(Job *job); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/job.c.generated.h" +#endif // Callbacks for libuv -static void job_prepare_cb(uv_prepare_t *handle); -static void read_cb(RStream *rstream, void *data, bool eof); -static void exit_cb(uv_process_t *proc, int64_t status, int term_signal); -static void close_cb(uv_handle_t *handle); -static void emit_exit_event(Job *job); /// Initializes job control resources void job_init() diff --git a/src/nvim/os/job.h b/src/nvim/os/job.h index 3d4c14a14a..665bdffdb5 100644 --- a/src/nvim/os/job.h +++ b/src/nvim/os/job.h @@ -13,25 +13,7 @@ #include "nvim/os/event_defs.h" #include "nvim/os/rstream_defs.h" -void job_init(void); - -void job_teardown(void); - -int job_start(char **argv, - void *data, - rstream_cb stdout_cb, - rstream_cb stderr_cb, - job_exit_cb exit_cb); - -bool job_stop(int id); - -bool job_write(int id, char *data, uint32_t len); - -void job_exit_event(Event event); - -int job_id(Job *job); - -void *job_data(Job *job); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/job.h.generated.h" +#endif #endif // NVIM_OS_JOB_H - diff --git a/src/nvim/os/job_defs.h b/src/nvim/os/job_defs.h index 8e4dc0cd88..a9caa169a8 100644 --- a/src/nvim/os/job_defs.h +++ b/src/nvim/os/job_defs.h @@ -12,4 +12,3 @@ typedef struct job Job; typedef void (*job_exit_cb)(Job *job, void *data); #endif // NVIM_OS_JOB_DEFS_H - diff --git a/src/nvim/os/rstream.c b/src/nvim/os/rstream.c index be37204de6..9b2cea52a5 100644 --- a/src/nvim/os/rstream.c +++ b/src/nvim/os/rstream.c @@ -27,12 +27,9 @@ struct rstream { bool reading, free_handle, async; }; -// Callbacks used by libuv -static void alloc_cb(uv_handle_t *, size_t, uv_buf_t *); -static void read_cb(uv_stream_t *, ssize_t, const uv_buf_t *); -static void fread_idle_cb(uv_idle_t *); -static void close_cb(uv_handle_t *handle); -static void emit_read_event(RStream *rstream, bool eof); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/rstream.c.generated.h" +#endif /// Creates a new RStream instance. A RStream encapsulates all the boilerplate /// necessary for reading from a libuv stream. @@ -226,6 +223,8 @@ void rstream_read_event(Event event) rstream->cb(rstream, rstream->data, event.data.rstream.eof); } +// Callbacks used by libuv + // Called by libuv to allocate memory for reading. static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) { diff --git a/src/nvim/os/rstream.h b/src/nvim/os/rstream.h index b93430ebcf..059b2a5ce8 100644 --- a/src/nvim/os/rstream.h +++ b/src/nvim/os/rstream.h @@ -8,28 +8,7 @@ #include "nvim/os/event_defs.h" #include "nvim/os/rstream_defs.h" -RStream * rstream_new(rstream_cb cb, - size_t buffer_size, - void *data, - bool async); - -void rstream_free(RStream *rstream); - -void rstream_set_stream(RStream *rstream, uv_stream_t *stream); - -void rstream_set_file(RStream *rstream, uv_file file); - -bool rstream_is_regular_file(RStream *rstream); - -void rstream_start(RStream *rstream); - -void rstream_stop(RStream *rstream); - -size_t rstream_read(RStream *rstream, char *buffer, size_t count); - -size_t rstream_available(RStream *rstream); - -void rstream_read_event(Event event); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/rstream.h.generated.h" +#endif #endif // NVIM_OS_RSTREAM_H - diff --git a/src/nvim/os/server.c b/src/nvim/os/server.c index 18a941a264..b5d8d8af64 100644 --- a/src/nvim/os/server.c +++ b/src/nvim/os/server.c @@ -42,9 +42,9 @@ typedef struct { static PMap(cstr_t) *servers = NULL; -static void connection_cb(uv_stream_t *server, int status); -static void free_client(uv_handle_t *handle); -static void free_server(uv_handle_t *handle); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/server.c.generated.h" +#endif /// Initializes the module void server_init() diff --git a/src/nvim/os/server.h b/src/nvim/os/server.h index 9023dd8b3d..43592a91e4 100644 --- a/src/nvim/os/server.h +++ b/src/nvim/os/server.h @@ -1,13 +1,7 @@ #ifndef NVIM_OS_SERVER_H #define NVIM_OS_SERVER_H -void server_init(); - -void server_teardown(); - -void server_start(char *endpoint); - -void server_stop(char *endpoint); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/server.h.generated.h" +#endif #endif // NVIM_OS_SERVER_H - diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 5e02c3504b..766b055450 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -31,20 +31,13 @@ typedef struct { garray_T ga; } ProcessData; -static int tokenize(char_u *str, char **argv); -static int word_length(char_u *command); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/shell.c.generated.h" +#endif -static void write_selection(uv_write_t *req); -static int proc_cleanup_exit(ProcessData *data, - uv_process_options_t *opts, - int shellopts); // Callbacks for libuv -static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf); -static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf); -static void write_cb(uv_write_t *req, int status); -static void exit_cb(uv_process_t *proc, int64_t status, int term_signal); /// Builds the argument vector for running the shell configured in `sh` /// ('shell' option), optionally with a command that will be passed with `shcf` diff --git a/src/nvim/os/shell.h b/src/nvim/os/shell.h index a63fed7277..3d0e32bf67 100644 --- a/src/nvim/os/shell.h +++ b/src/nvim/os/shell.h @@ -17,11 +17,11 @@ typedef enum { kShellOptHideMess = 128, ///< previously a global variable from os_unix.c } ShellOpts; -char ** shell_build_argv(char_u *cmd, char_u *extra_shell_arg); -void shell_free_argv(char **argv); -int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/shell.h.generated.h" +#endif #endif // NVIM_OS_SHELL_H diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 68a455c5a2..85aa8ae5cb 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -21,10 +21,10 @@ static uv_signal_t spwr; #endif static bool rejecting_deadly; -static char * signal_name(int signum); -static void deadly_signal(int signum); -static void signal_cb(uv_signal_t *, int signum); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/signal.c.generated.h" +#endif void signal_init() { uv_signal_init(uv_default_loop(), &sint); diff --git a/src/nvim/os/signal.h b/src/nvim/os/signal.h index 6a0ad5e9ac..7cdde3c71a 100644 --- a/src/nvim/os/signal.h +++ b/src/nvim/os/signal.h @@ -3,11 +3,9 @@ #include "nvim/os/event_defs.h" -void signal_init(void); -void signal_stop(void); -void signal_accept_deadly(void); -void signal_reject_deadly(void); -void signal_handle(Event event); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/signal.h.generated.h" +#endif #endif // NVIM_OS_SIGNAL_H diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 66f9405510..977a4f19c4 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -11,8 +11,10 @@ static uv_mutex_t delay_mutex; static uv_cond_t delay_cond; -static void microdelay(uint64_t ms); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/time.c.generated.h" +#endif /// Initializes the time module void time_init() { diff --git a/src/nvim/os/time.h b/src/nvim/os/time.h index 3b185825be..cfe7eb85ff 100644 --- a/src/nvim/os/time.h +++ b/src/nvim/os/time.h @@ -4,15 +4,13 @@ #include #include -void time_init(void); -void os_delay(uint64_t milliseconds, bool ignoreinput); -void os_microdelay(uint64_t microseconds, bool ignoreinput); -struct tm *os_localtime_r(const time_t *clock, struct tm *result); -struct tm *os_get_localtime(struct tm *result); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/time.h.generated.h" +#endif #endif // NVIM_OS_TIME_H diff --git a/src/nvim/os/uv_helpers.c b/src/nvim/os/uv_helpers.c index fa81fcdcc6..a3c9dd5fbf 100644 --- a/src/nvim/os/uv_helpers.c +++ b/src/nvim/os/uv_helpers.c @@ -13,7 +13,10 @@ typedef struct { Job *job; } HandleData; -static HandleData *init(uv_handle_t *handle); + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/uv_helpers.c.generated.h" +#endif /// Gets the RStream instance associated with a libuv handle /// diff --git a/src/nvim/os/uv_helpers.h b/src/nvim/os/uv_helpers.h index ea797ba9f0..b49656bcb8 100644 --- a/src/nvim/os/uv_helpers.h +++ b/src/nvim/os/uv_helpers.h @@ -7,17 +7,7 @@ #include "nvim/os/rstream_defs.h" #include "nvim/os/job_defs.h" -RStream *handle_get_rstream(uv_handle_t *handle); - -void handle_set_rstream(uv_handle_t *handle, RStream *rstream); - -WStream *handle_get_wstream(uv_handle_t *handle); - -void handle_set_wstream(uv_handle_t *handle, WStream *wstream); - -Job *handle_get_job(uv_handle_t *handle); - -void handle_set_job(uv_handle_t *handle, Job *job); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/uv_helpers.h.generated.h" +#endif #endif // NVIM_OS_UV_HELPERS_H - diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index b5c396b50c..899b97da7e 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -30,8 +30,10 @@ typedef struct { WBuffer *buffer; } WriteData; -static void write_cb(uv_write_t *req, int status); +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/wstream.c.generated.h" +#endif /// Creates a new WStream instance. A WStream encapsulates all the boilerplate /// necessary for writing to a libuv stream. /// diff --git a/src/nvim/os/wstream.h b/src/nvim/os/wstream.h index e133ef1385..d0e9bef93a 100644 --- a/src/nvim/os/wstream.h +++ b/src/nvim/os/wstream.h @@ -7,15 +7,7 @@ #include "nvim/os/wstream_defs.h" -WStream * wstream_new(size_t maxmem); - -void wstream_free(WStream *wstream); - -void wstream_set_stream(WStream *wstream, uv_stream_t *stream); - -bool wstream_write(WStream *wstream, WBuffer *buffer); - -WBuffer *wstream_new_buffer(char *data, size_t size, bool copy); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/wstream.h.generated.h" +#endif #endif // NVIM_OS_WSTREAM_H - -- cgit From 7dd0d9d2ab401034516bd3bd344a71d819a88ef0 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 18 May 2014 00:57:46 +0400 Subject: Make nvim/lib/k*.h headers be the last one in the list So that they do the last nvim/func_attr.h include --- src/nvim/os/channel.c | 2 ++ src/nvim/os/event.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index 9a692cf9fe..d393025ba5 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -17,6 +17,8 @@ #include "nvim/map.h" #include "nvim/lib/kvec.h" +#include "nvim/lib/klist.h" + typedef struct { uint64_t id; PMap(cstr_t) *subscribed_events; diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index dd2b9ba0d1..cdf40541d5 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -4,7 +4,6 @@ #include -#include "nvim/lib/klist.h" #include "nvim/os/event.h" #include "nvim/os/input.h" #include "nvim/os/channel.h" @@ -16,6 +15,8 @@ #include "nvim/memory.h" #include "nvim/misc2.h" +#include "nvim/lib/klist.h" + // event will be cleaned up after it gets processed #define _destroy_event(x) // do nothing KLIST_INIT(Event, Event, _destroy_event) -- cgit From dca28e55c7f798238e693d6db56da201c8d6dc29 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 1 Jun 2014 02:11:35 +0400 Subject: Fix some styles --- src/nvim/os/job.h | 2 +- src/nvim/os/rstream.h | 2 +- src/nvim/os/shell.h | 5 ----- src/nvim/os/signal.h | 2 -- src/nvim/os/time.h | 6 ------ src/nvim/os/wstream.c | 1 + 6 files changed, 3 insertions(+), 15 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/job.h b/src/nvim/os/job.h index 665bdffdb5..f48218ffe7 100644 --- a/src/nvim/os/job.h +++ b/src/nvim/os/job.h @@ -10,8 +10,8 @@ #include #include -#include "nvim/os/event_defs.h" #include "nvim/os/rstream_defs.h" +#include "nvim/os/event_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/job.h.generated.h" diff --git a/src/nvim/os/rstream.h b/src/nvim/os/rstream.h index 059b2a5ce8..713d1e77e6 100644 --- a/src/nvim/os/rstream.h +++ b/src/nvim/os/rstream.h @@ -4,8 +4,8 @@ #include #include #include - #include "nvim/os/event_defs.h" + #include "nvim/os/rstream_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/os/shell.h b/src/nvim/os/shell.h index 3d0e32bf67..e912baedf8 100644 --- a/src/nvim/os/shell.h +++ b/src/nvim/os/shell.h @@ -2,7 +2,6 @@ #define NVIM_OS_SHELL_H #include - #include "nvim/types.h" // Flags for mch_call_shell() second argument @@ -17,11 +16,7 @@ typedef enum { kShellOptHideMess = 128, ///< previously a global variable from os_unix.c } ShellOpts; - - - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/shell.h.generated.h" #endif #endif // NVIM_OS_SHELL_H - diff --git a/src/nvim/os/signal.h b/src/nvim/os/signal.h index 7cdde3c71a..927437b2db 100644 --- a/src/nvim/os/signal.h +++ b/src/nvim/os/signal.h @@ -3,9 +3,7 @@ #include "nvim/os/event_defs.h" - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/signal.h.generated.h" #endif #endif // NVIM_OS_SIGNAL_H - diff --git a/src/nvim/os/time.h b/src/nvim/os/time.h index cfe7eb85ff..8c73fc0c3b 100644 --- a/src/nvim/os/time.h +++ b/src/nvim/os/time.h @@ -4,13 +4,7 @@ #include #include - - - - - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/time.h.generated.h" #endif #endif // NVIM_OS_TIME_H - diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index 899b97da7e..c2ed05b78f 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -34,6 +34,7 @@ typedef struct { #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/wstream.c.generated.h" #endif + /// Creates a new WStream instance. A WStream encapsulates all the boilerplate /// necessary for writing to a libuv stream. /// -- cgit From d906708a439687c7476083b883d29b8e99dd15e3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 1 Jun 2014 02:03:54 +0400 Subject: Remove unneeded klist include in channel.c --- src/nvim/os/channel.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index d393025ba5..9a692cf9fe 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -17,8 +17,6 @@ #include "nvim/map.h" #include "nvim/lib/kvec.h" -#include "nvim/lib/klist.h" - typedef struct { uint64_t id; PMap(cstr_t) *subscribed_events; -- cgit From 1747d3d940b1d46a68c489582cf50b05a4e3358e Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 2 Jun 2014 01:04:21 +0400 Subject: Use generated headers in os.h --- src/nvim/os/os.h | 58 ++++++-------------------------------------------------- 1 file changed, 6 insertions(+), 52 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h index 73e09e5012..5dd498e3dc 100644 --- a/src/nvim/os/os.h +++ b/src/nvim/os/os.h @@ -4,62 +4,16 @@ #include "nvim/vim.h" -int os_chdir(const char *path); - -int os_dirname(char_u *buf, size_t len); - -bool os_isdir(const char_u *name); - -bool os_can_exe(const char_u *name); - -int32_t os_getperm(const char_u *name); - -int os_setperm(const char_u *name, int perm); - -bool os_file_exists(const char_u *name); - -bool os_file_is_readonly(const char *name); - -int os_file_is_writable(const char *name); - -bool os_get_file_size(const char *name, off_t *size); - -int os_rename(const char_u *path, const char_u *new_path); - -int os_mkdir(const char *path, int32_t mode); - -int os_rmdir(const char *path); - -int os_remove(const char *path); - -uint64_t os_get_total_mem_kib(void); -const char *os_getenv(const char *name); -int os_setenv(const char *name, const char *value, int overwrite); -char *os_getenvname_at_index(size_t index); - -int64_t os_get_pid(void); - -void os_get_hostname(char *hostname, size_t len); - -int os_get_usernames(garray_T *usernames); -int os_get_user_name(char *s, size_t len); -int os_get_uname(uid_t uid, char *s, size_t len); -char *os_get_user_directory(const char *name); - -int os_stat(const char_u *name, uv_stat_t *statbuf); - /// Struct which encapsulates stat information. typedef struct { // TODO(stefan991): make stat private uv_stat_t stat; } FileInfo; -bool os_get_file_info(const char *path, FileInfo *file_info); - -bool os_get_file_info_link(const char *path, FileInfo *file_info); - -bool os_get_file_info_fd(int file_descriptor, FileInfo *file_info); - -bool os_file_info_id_equal(FileInfo *file_info_1, FileInfo *file_info_2); - +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/fs.h.generated.h" +# include "os/mem.h.generated.h" +# include "os/env.h.generated.h" +# include "os/users.h.generated.h" +#endif #endif // NVIM_OS_OS_H -- cgit