#include <stdio.h>
#include "types.h"
#include "macros.h"
#include "log.h"
Go to the source code of this file.
◆ girara_xdg_path_t
Enum for directories specified in the XDG specification.
Enumerator |
---|
XDG_CONFIG | XDG_CONFIG_HOME
|
XDG_DATA | XDG_DATA_HOME
|
XDG_CONFIG_DIRS | XDG_CONFIG_DIRS
|
XDG_DATA_DIRS | XDG_DATA_DIRS
|
XDG_CACHE | XDG_CACHE_HOME
|
Definition at line 15 of file utils.h.
◆ girara_clean_line()
void girara_clean_line |
( |
char * |
line | ) |
|
Trims and cleans a line from multiple whitespaces
- Parameters
-
◆ girara_escape_string()
char * girara_escape_string |
( |
const char * |
value | ) |
|
Escape \, \t, ", ' and spaces in strings.
- Parameters
-
value | The string to be escaped. |
- Returns
- The escaped string. Needs to be freed with g_free.
◆ girara_exec_with_argument_list()
bool girara_exec_with_argument_list |
( |
girara_session_t * |
session, |
|
|
girara_list_t * |
argument_list |
|
) |
| |
Execute command from argument list
- Parameters
-
session | The used girara session |
argument_list | The argument list |
- Returns
- true if no error occurred
◆ girara_file_open()
FILE * girara_file_open |
( |
const char * |
path, |
|
|
const char * |
mode |
|
) |
| |
Open a file in a safe way
- Parameters
-
path | Path of the file |
mode | Mode that the file should be opened |
- Returns
- NULL if an error occurred
◆ girara_file_read()
char * girara_file_read |
( |
const char * |
path | ) |
|
Reads the whole content from a file. Returned string has to be freed.
- Parameters
-
- Returns
- Read file or NULL if an error occurred
◆ girara_file_read2()
char * girara_file_read2 |
( |
FILE * |
file | ) |
|
Reads the whole content from a file. Returned string has to be freed.
- Parameters
-
- Returns
- Read file or NULL if an error occurred
◆ girara_file_read_line()
char * girara_file_read_line |
( |
FILE * |
file | ) |
|
Reads a line from the file. The returned string has to be released with g_free.
- Parameters
-
- Returns
- Read line or NULL if an error occurred
◆ girara_fix_path()
char * girara_fix_path |
( |
const char * |
path | ) |
|
Returns a "fixed" version of path. Which means, it will be an absolute path and fully expanded. ~ and ~user will be replaced by the current user's home directory (user's home directory respectively).
- Parameters
-
- Returns
- the "fixed" path (needs to be freed with g_free).
◆ girara_get_home_directory()
char * girara_get_home_directory |
( |
const char * |
user | ) |
|
Returns the home directory for the given user. $HOME is preferred over the value from g_get_home_dir.
- Parameters
-
user | a username or NULL to get home directory of the current user. |
- Returns
- a string containing the path to the user's home directory (needs to be freed with g_free) or NULL if the user doesn't exist.
◆ girara_get_xdg_path()
Returns a specific path specified in the XDG specification. ~ in paths will not be expanded.
- Parameters
-
- Returns
- a string containing the requested patch (needs to be freed with g_free) or NULL for invalid values.
◆ girara_replace_substring()
char * girara_replace_substring |
( |
const char * |
string, |
|
|
const char * |
old, |
|
|
const char * |
new |
|
) |
| |
Replaces all occurrences of old in string with new and returns a new allocated string
- Parameters
-
string | The original string |
old | String to replace |
new | Replacement string |
- Returns
- new allocated string, needs to be freed with g_free
◆ girara_safe_realloc()
void * girara_safe_realloc |
( |
void ** |
ptr, |
|
|
size_t |
size |
|
) |
| |
Changes the size of the memory block by wrapping a realloc function call In addition it frees the old memory block if realloc fails.
- Parameters
-
ptr | Memory space |
size | Number of bytes |
- Returns
- Pointer to the allocated memory block or NULL
◆ girara_split_path_array()
girara_list_t * girara_split_path_array |
( |
const char * |
patharray | ) |
|
Splits paths separated by : (as in $PATH) into a list.
- Parameters
-
patharray | String like $PATH to split |
- Returns
- a list of paths and NULL on failure.
◆ girara_version()
const char * girara_version |
( |
void |
| ) |
|
Return version of girara.
- Returns
- version string
◆ girara_xdg_open()
bool girara_xdg_open |
( |
const char * |
uri | ) |
|
Opens a URI with xdg-open. If xdg-open is not available, it falls back to the equivalent of gio open.
- Parameters
-
- Returns
- true on success, false otherwise
◆ girara_xdg_open_with_working_directory()
bool girara_xdg_open_with_working_directory |
( |
const char * |
uri, |
|
|
const char * |
working_directory |
|
) |
| |
Opens a URI with xdg-open in a different working directory. If xdg-open is not available, it falls back to the equivalent of gio open.
- Parameters
-
uri | the URI to be opened. |
working_directory | working directory |
- Returns
- true on success, false otherwise