Macros | Functions
XDG: Freedesktop.org Base Directory Specification

Implementation of XDG Base Directory Specification (version 0.7). More...

Macros

#define MAIN_ERR_PREFIX   "XDG: "
 Message prefix for XDG module.
 

Functions

int xdg_append_to_path (const char **buf, const char *newcomp)
 Append path component to buffer. More...
 
const char * xdg_get_confdir (const char *progname)
 Get configuration directory. More...
 

Detailed Description

Implementation of XDG Base Directory Specification (version 0.7).

Function Documentation

◆ xdg_append_to_path()

int xdg_append_to_path ( const char **  buf,
const char *  newcomp 
)

Append path component to buffer.

Parameters
[in]bufPointer to buffer pointer
[in]newcompNew path component to append

First a slash "/" is appended to the content of buf. Then, if newcomp is not NULL , it is appended after the slash. Additional memory is automatically allocated.

Attention
Dereferenced buf must be usable for realloc() .
Returns
  • Zero on success
  • Negative value on error

Definition at line 55 of file xdg.c.

References PRINT_ERROR.

Referenced by core_get_cancel_key(), log_get_logpathname(), and xdg_get_confdir().

◆ xdg_get_confdir()

const char* xdg_get_confdir ( const char *  progname)

Get configuration directory.

Parameters
[in]prognameProgram name

If progname is NULL then $XDG_CONFIG_HOME is returned. Otherwise progname is appended as subdirectory and $XDG_CONFIG_HOME/progname is returned.

If XDG_CONFIG_HOME is not defined, the default $HOME/.config is used (it is treated as error if HOME is not defined in this case).

Note
On success, the caller is responsible to free the memory allocated for the result.
Returns
  • Pointer to result on success
  • NULL on error

Definition at line 115 of file xdg.c.

References fu_check_path(), fu_create_path(), main_confprefix, main_debug, MAIN_ERR_PREFIX, PRINT_ERROR, ts_getenv(), and xdg_append_to_path().

Referenced by core_get_cancel_key(), and log_get_logpathname().


Generated at 2024-04-27 using  doxygen