#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <glib.h>
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "utils.h"
#include "datastructures.h"
#include "session.h"
#include "settings.h"
Go to the source code of this file.
#define _FILE_OFFSET_BITS 64 |
#define _XOPEN_SOURCE 700 |
void _girara_debug |
( |
const char * |
function, |
|
|
int |
line, |
|
|
girara_debug_level_t |
level, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
void girara_clean_line |
( |
char * |
line) | |
|
Trims and cleans a line from multiple whitespaces
- Parameters
-
Definition at line 350 of file utils.c.
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.
Definition at line 467 of file utils.c.
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 occured
Definition at line 486 of file utils.c.
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 occured
Definition at line 184 of file utils.c.
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 occured
Definition at line 291 of file utils.c.
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 occured
Definition at line 308 of file utils.c.
char* girara_file_read_line |
( |
FILE * |
file) | |
|
Reads a line from the file. Returned string has to be freed.
- Parameters
-
- Returns
- Read line or NULL if an error occured
Definition at line 269 of file utils.c.
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).
Definition at line 33 of file utils.c.
Get the debug level.
- Returns
- The debug level.
Definition at line 440 of file utils.c.
char* girara_get_home_directory |
( |
const char * |
user) | |
|
Returns the home directory for the given user. $HOME is prefered 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.
Definition at line 94 of file utils.c.
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.
Definition at line 131 of file utils.c.
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
Definition at line 378 of file utils.c.
Set the debug level. Any message with a level lower than the debug level will be discarded.
- Parameters
-
level | The new debug level. |
Definition at line 446 of file utils.c.
girara_list_t* girara_split_path_array |
( |
const char * |
patharray) | |
|
Splits paths seperated by : (as in $PATH) into a list.
- Parameters
-
patharray | String like $PATH to split |
- Returns
- a list of paths and NULL on failure.
Definition at line 167 of file utils.c.
bool girara_xdg_open |
( |
const char * |
uri) | |
|
Opens a URI with xdg-open.
- Parameters
-
- Returns
- true on success, false otherwise
Definition at line 70 of file utils.c.
void update_state_by_keyval |
( |
int * |
state, |
|
|
int |
keyval |
|
) |
| |