diff options
| author | ZyX <kp-pav@yandex.ru> | 2015-10-17 21:30:52 +0300 | 
|---|---|---|
| committer | ZyX <kp-pav@yandex.ru> | 2015-10-23 14:54:11 +0300 | 
| commit | aadaa1fed4d471fc2e286b0ffa151c006482389e (patch) | |
| tree | c1d1179ee4bb32b450513e5d5fcb4bc2fd794760 /src | |
| parent | 89a10b3e7cadc5d088217380de7ed1af70ed8b31 (diff) | |
| download | rneovim-aadaa1fed4d471fc2e286b0ffa151c006482389e.tar.gz rneovim-aadaa1fed4d471fc2e286b0ffa151c006482389e.tar.bz2 rneovim-aadaa1fed4d471fc2e286b0ffa151c006482389e.zip | |
stdpaths: Add documentation
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/os/stdpaths.c | 24 | ||||
| -rw-r--r-- | src/nvim/os/stdpaths_defs.h | 13 | 
2 files changed, 31 insertions, 6 deletions
| diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 167a53c985..0ed7aec2a6 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -5,6 +5,7 @@  #include "nvim/path.h"  #include "nvim/memory.h" +/// Names of the environment variables, mapped to XDGVarType values  static const char *xdg_env_vars[] = {    [kXDGConfigHome] = "XDG_CONFIG_HOME",    [kXDGDataHome] = "XDG_DATA_HOME", @@ -14,6 +15,9 @@ static const char *xdg_env_vars[] = {    [kXDGDataDirs] = "XDG_DATA_DIRS",  }; +/// Defaults for XDGVarType values +/// +/// Used in case environment variables contain nothing. Need to be expanded.  static const char *const xdg_defaults[] = {    // Windows, Apple stuff are just shims right now  #ifdef WIN32 @@ -37,6 +41,11 @@ static const char *const xdg_defaults[] = {  };  #endif +/// Return XDG variable value +/// +/// @param[in]  idx  XDG variable to use. +/// +/// @return [allocated] variable value.  char *stdpaths_get_xdg_var(const XDGVarType idx)    FUNC_ATTR_WARN_UNUSED_RESULT  { @@ -54,6 +63,11 @@ char *stdpaths_get_xdg_var(const XDGVarType idx)    return ret;  } +/// Return nvim-specific XDG directory subpath +/// +/// @param[in]  idx  XDG directory to use. +/// +/// @return [allocated] `{xdg_directory}/nvim`  static char *get_xdg_home(const XDGVarType idx)    FUNC_ATTR_WARN_UNUSED_RESULT  { @@ -64,12 +78,22 @@ static char *get_xdg_home(const XDGVarType idx)    return dir;  } +/// Return subpath of $XDG_CONFIG_HOME +/// +/// @param[in]  fname  New component of the path. +/// +/// @return [allocated] `$XDG_CONFIG_HOME/nvim/{fname}`  char *stdpaths_user_conf_subpath(const char *fname)    FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL  {    return concat_fnames_realloc(get_xdg_home(kXDGConfigHome), fname, true);  } +/// Return subpath of $XDG_DATA_HOME +/// +/// @param[in]  fname  New component of the path. +/// +/// @return [allocated] `$XDG_DATA_HOME/nvim/{fname}`  char *stdpaths_user_data_subpath(const char *fname)    FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL  { diff --git a/src/nvim/os/stdpaths_defs.h b/src/nvim/os/stdpaths_defs.h index 3b882cd582..1433e0bc62 100644 --- a/src/nvim/os/stdpaths_defs.h +++ b/src/nvim/os/stdpaths_defs.h @@ -1,13 +1,14 @@  #ifndef NVIM_OS_STDPATHS_DEFS_H  #define NVIM_OS_STDPATHS_DEFS_H +/// List of possible XDG variables  typedef enum { -  kXDGConfigHome, -  kXDGDataHome, -  kXDGCacheHome, -  kXDGRuntimeDir, -  kXDGConfigDirs, -  kXDGDataDirs, +  kXDGConfigHome,  ///< XDG_CONFIG_HOME +  kXDGDataHome,    ///< XDG_DATA_HOME +  kXDGCacheHome,   ///< XDG_CACHE_HOME +  kXDGRuntimeDir,  ///< XDG_RUNTIME_DIR +  kXDGConfigDirs,  ///< XDG_CONFIG_DIRS +  kXDGDataDirs,    ///< XDG_DATA_DIRS  } XDGVarType;  #endif  // NVIM_OS_STDPATHS_DEFS_H | 
