utils

utils

Functions

gchar * gebr_g_string_remove_accents ()
void gebr_g_string_replace ()
void gebr_g_string_replace_first_ref ()
gboolean gebr_g_string_starts_with ()
gboolean gebr_g_string_ends_with ()
gboolean gebr_append_filename_extension ()
gboolean gebr_path_is_at_home ()
gboolean gebr_path_use_home_variable ()
gboolean gebr_path_resolve_home_variable ()
void gebr_path_set_to ()
GString * gebr_temp_directory_create ()
void gebr_temp_directory_destroy ()
GString * gebr_make_unique_filename ()
GString * gebr_make_temp_filename ()
gint gebr_system ()
gboolean gebr_dir_has_files ()
int gebr_home_mode ()
gboolean gebr_create_config_dirs ()
gchar * gebr_locale_to_utf8 ()
gboolean g_key_file_has_key_woe ()
GString * gebr_g_key_file_load_string_key ()
gboolean gebr_g_key_file_load_boolean_key ()
int gebr_g_key_file_load_int_key ()
gboolean gebr_g_key_file_has_key ()
gboolean gebr_g_key_file_remove_key ()
#define gebr_foreach_gslist_hyg()
#define gebr_foreach_gslist()
#define gebr_glist_foreach_hyg()
#define gebr_glist_foreach()
#define gebr_directory_foreach_file_hyg()
#define gebr_directory_foreach_file()
const gchar * gebr_validate_int ()
const gchar * gebr_validate_float ()
int g_strcmp0 ()
gboolean gebr_realpath_equal ()
gchar * gebr_str_escape ()
gchar * gebr_date_get_localized ()
gchar * gebr_id_random_create ()
gchar * gebr_lock_file ()
gchar * gebr_str_word_before_pos ()
gchar * gebr_str_remove_trailing_zeros ()
gboolean gebr_str_canonical_var_name ()
gchar * gebr_calculate_relative_time ()
gdouble gebr_get_lower_bound_for_type ()
gint gebr_get_number_of_time_controls ()
gchar * gebr_get_control_text_for_type ()
gchar * gebr_calculate_detailed_relative_time ()
gchar * gebr_compute_diff_iso_times ()
gint gebr_compute_diff_clock_to_me ()
gboolean gebr_utf8_is_asc_alnum ()
gchar * gebr_utf8_strstr ()
gint gebr_calculate_number_of_processors ()
void gebr_pairstrfreev ()
gchar * gebr_remove_path_prefix ()
gchar * gebr_relativise_old_home_path ()
gchar * gebr_relativise_home_path ()
gchar * gebr_relativise_path ()
gchar * gebr_resolve_relative_path ()
gchar *** gebr_generate_paths_with_home ()
void gebr_gtk_bookmarks_add_paths ()
void gebr_gtk_bookmarks_remove_paths ()
gboolean gebr_verify_starting_slash ()
gboolean gebr_validate_path ()
gint gebr_strv_indexof ()
gboolean gebr_generate_key ()
gboolean gebr_add_remove_ssh_key ()
gchar * gebr_get_user_from_address ()
gchar * gebr_get_host_from_address ()
gboolean gebr_verify_address_without_username ()
gboolean gebr_kill_by_port ()
gchar * gebr_key_filename ()
gchar * gebr_create_id_with_current_time ()
GList * gebr_double_list_to_list ()
gboolean gebr_gzfile_get_contents ()
gboolean gebr_callback_true ()
void gebr_string_freeall ()
const gchar * gebr_apply_pattern_on_address ()
GQueue * gebr_gqueue_push_tail_avoiding_duplicates ()
const gchar * gebr_paths_get_value_by_key ()
const gchar * gebr_get_nfsid ()
void GEBR_LOCK_FILE ()
void GEBR_UNLOCK_FILE ()

Types and Values

enum TimesType

Object Hierarchy


Description

Functions

gebr_g_string_remove_accents ()

gchar *
gebr_g_string_remove_accents (gchar *title);

Replace accented characters on a string to non accented characters. If character is non ASCII, it is replaced to ""

Parameters

title

the text with accents to be removed

 

gebr_g_string_replace ()

void
gebr_g_string_replace (GString *string,
                       const gchar *oldtext,
                       const gchar *newtext);

Replace each reference of oldtext in string with newtext. If newtext if NULL, then each reference of oldtext found is removed.

Parameters

string

The string to with the text.

 

oldtext

The text to be replaced.

 

newtext

The text to replace oldtext.

 

gebr_g_string_replace_first_ref ()

void
gebr_g_string_replace_first_ref (GString *string,
                                 const gchar *oldtext,
                                 const gchar *newtext);

gebr_g_string_starts_with ()

gboolean
gebr_g_string_starts_with (GString *string,
                           const gchar *val);

gebr_g_string_ends_with ()

gboolean
gebr_g_string_ends_with (GString *string,
                         const gchar *val);

gebr_append_filename_extension ()

gboolean
gebr_append_filename_extension (GString *filename,
                                const gchar *extension);

gebr_path_is_at_home ()

gboolean
gebr_path_is_at_home (const gchar *path);

gebr_path_use_home_variable ()

gboolean
gebr_path_use_home_variable (GString *path);

gebr_path_resolve_home_variable ()

gboolean
gebr_path_resolve_home_variable (GString *path);

gebr_path_set_to ()

void
gebr_path_set_to (GString *path,
                  gboolean relative);

gebr_temp_directory_create ()

GString *
gebr_temp_directory_create (void);

gebr_temp_directory_destroy ()

void
gebr_temp_directory_destroy (GString *path);

gebr_make_unique_filename ()

GString *
gebr_make_unique_filename (const gchar *template);

gebr_make_temp_filename ()

GString *
gebr_make_temp_filename (const gchar *template);

gebr_system ()

gint
gebr_system (const gchar *cmd,
             ...);

gebr_dir_has_files ()

gboolean
gebr_dir_has_files (const gchar *dir_path);

gebr_home_mode ()

int
gebr_home_mode (void);

gebr_create_config_dirs ()

gboolean
gebr_create_config_dirs (void);

gebr_locale_to_utf8 ()

gchar *
gebr_locale_to_utf8 (const gchar *string);

g_key_file_has_key_woe ()

gboolean
g_key_file_has_key_woe (GKeyFile *key_file,
                        const gchar *group,
                        const gchar *key);

gebr_g_key_file_load_string_key ()

GString *
gebr_g_key_file_load_string_key (GKeyFile *key_file,
                                 const gchar *group,
                                 const gchar *key,
                                 const gchar *default_value);

gebr_g_key_file_load_boolean_key ()

gboolean
gebr_g_key_file_load_boolean_key (GKeyFile *key_file,
                                  const gchar *group,
                                  const gchar *key,
                                  gboolean default_value);

gebr_g_key_file_load_int_key ()

int
gebr_g_key_file_load_int_key (GKeyFile *key_file,
                              const gchar *group,
                              const gchar *key,
                              int default_value);

gebr_g_key_file_has_key ()

gboolean
gebr_g_key_file_has_key (GKeyFile *key_file,
                         const gchar *group,
                         const gchar *key);

gebr_g_key_file_remove_key ()

gboolean
gebr_g_key_file_remove_key (GKeyFile *key_file,
                            const gchar *group,
                            const gchar *key);

gebr_foreach_gslist_hyg()

#define             gebr_foreach_gslist_hyg(element, list, hygid)

gebr_foreach_gslist()

#define             gebr_foreach_gslist(element, list)

gebr_glist_foreach_hyg()

#define             gebr_glist_foreach_hyg(element, list, hygid)

gebr_glist_foreach()

#define             gebr_glist_foreach(element, list)

gebr_directory_foreach_file_hyg()

#define             gebr_directory_foreach_file_hyg(filename, directory, hygid)

gebr_directory_foreach_file()

#define             gebr_directory_foreach_file(filename, directory)

gebr_validate_int ()

const gchar *
gebr_validate_int (const gchar *text_value,
                   const gchar *min,
                   const gchar *max);

gebr_validate_float ()

const gchar *
gebr_validate_float (const gchar *text_value,
                     const gchar *min,
                     const gchar *max);

g_strcmp0 ()

int
g_strcmp0 (const char *str1,
           const char *str2);

gebr_realpath_equal ()

gboolean
gebr_realpath_equal (const gchar *path1,
                     const gchar *path2);

Compares if path1 and path2 resolves to the same file. The equality is decided by calling g_stat() on both of them and comparing their inode ids.

Parameters

path1

the first path

 

path2

the second path

 

Returns

TRUE if path1 points to the same file/directory as path2 . FALSE otherwise, including if one or both of then does not exists in the file system.


gebr_str_escape ()

gchar *
gebr_str_escape (const gchar *str);

Escapes all backslashes and quotes in a string. It is based on glib's g_strescape.

Parameters

str

the string to be escaped

 

Returns

a newly allocated string.


gebr_date_get_localized ()

gchar *
gebr_date_get_localized (const gchar *format,
                         const gchar *locale);

gebr_id_random_create ()

gchar *
gebr_id_random_create (gssize bytes);

gebr_lock_file ()

gchar *
gebr_lock_file (const gchar *path,
                const gchar *content);

If content is NULL, returns the content of path . Otherwise, content is written in path in a safe way.


gebr_str_word_before_pos ()

gchar *
gebr_str_word_before_pos (const gchar *str,
                          gint *pos);

gebr_str_remove_trailing_zeros ()

gchar *
gebr_str_remove_trailing_zeros (gchar *str);

Modifies str inplace by removing trailing zeros.

Returns

The same str , but modified.


gebr_str_canonical_var_name ()

gboolean
gebr_str_canonical_var_name (const gchar *keyword,
                             gchar **new_value,
                             GError **error);

Parameters

keyword

The keyword to be canonized. (not modified)

 

new_value

Returns a new alocated string with the canonized value of keyword.

 

error

A GError (not used until now)

 

Returns

TRUE if everthing is ok. False otherwise.


gebr_calculate_relative_time ()

gchar *
gebr_calculate_relative_time (GTimeVal *time1,
                              GTimeVal *time2,
                              TimesType *type,
                              gdouble *delta);

Parameters

time1

The first date to compare

 

time2

The second date to compare

 

Returns

A message (string) of the relative time and NULL if time2 is older than time1.


gebr_get_lower_bound_for_type ()

gdouble
gebr_get_lower_bound_for_type (TimesType type);

Returns


gebr_get_number_of_time_controls ()

gint
gebr_get_number_of_time_controls ();

gebr_get_control_text_for_type ()

gchar *
gebr_get_control_text_for_type (TimesType type);

Return:


gebr_calculate_detailed_relative_time ()

gchar *
gebr_calculate_detailed_relative_time (GTimeVal *time1,
                                       GTimeVal *time2);

gebr_compute_diff_iso_times ()

gchar *
gebr_compute_diff_iso_times (const gchar *iso_time1,
                             const gchar *iso_time2);

gebr_compute_diff_clock_to_me ()

gint
gebr_compute_diff_clock_to_me (const gchar *iso_time1);

gebr_utf8_is_asc_alnum ()

gboolean
gebr_utf8_is_asc_alnum (const gchar *str);

Parameters

str

The string to check

 

Returns

TRUE if str is ASC and alpha-numerical.


gebr_utf8_strstr ()

gchar *
gebr_utf8_strstr (const gchar *haystack,
                  const gchar *needle);

Searches for needle in haystack and returns a pointer to the begging of the substring or NULL if it was not found.


gebr_calculate_number_of_processors ()

gint
gebr_calculate_number_of_processors (gint total_nprocs,
                                     gdouble aggressive);

Calculate real number of processors will be used

Parameters

total_nprocs

Number of processors of a server

 

aggressive

Aggressive percentage (slider)

 

gebr_pairstrfreev ()

void
gebr_pairstrfreev (gchar ***strv);

Frees a vector of pairs of strings.


gebr_remove_path_prefix ()

gchar *
gebr_remove_path_prefix (const gchar *prefix,
                         const gchar *path);

Remove prefix from path


gebr_relativise_old_home_path ()

gchar *
gebr_relativise_old_home_path (const gchar *path_string);

Change $HOME of path_string to <HOME>


gebr_relativise_home_path ()

gchar *
gebr_relativise_home_path (const gchar *path_string,
                           const gchar *mount_point,
                           const gchar *home);

Substitute home with the prefix HOME pvector is a vector of pair of strings, the first entry is an alias and the second is an absolute path.


gebr_relativise_path ()

gchar *
gebr_relativise_path (const gchar *path_string,
                      const gchar *mount_point,
                      gchar ***pvector);

Substitute path with the longest prefix in pvector . pvector is a vector of pair of strings, the first entry is an alias and the second is an absolute path.


gebr_resolve_relative_path ()

gchar *
gebr_resolve_relative_path (const char *path,
                            gchar ***pvector);

Transfors a relative path in absolute path


gebr_generate_paths_with_home ()

gchar ***
gebr_generate_paths_with_home (const gchar *home);

gebr_gtk_bookmarks_add_paths ()

void
gebr_gtk_bookmarks_add_paths (const gchar *filename,
                              const gchar *uri_prefix,
                              gchar ***paths);

Add bookmarks on filename file with uri_prefix and base paths set on vector paths , and include suffix (GeBR) on name to identify


gebr_gtk_bookmarks_remove_paths ()

void
gebr_gtk_bookmarks_remove_paths (const gchar *filename,
                                 gchar ***paths);

Remove bookmarks according paths for filename


gebr_verify_starting_slash ()

gboolean
gebr_verify_starting_slash (const gchar *string);

gebr_validate_path ()

gboolean
gebr_validate_path (const gchar *path,
                    gchar ***paths,
                    gchar **err_msg);

gebr_strv_indexof ()

gint
gebr_strv_indexof (const gchar **strv,
                   const gchar *value);

gebr_generate_key ()

gboolean
gebr_generate_key ();

gebr_add_remove_ssh_key ()

gboolean
gebr_add_remove_ssh_key (gboolean remove);

gebr_get_user_from_address ()

gchar *
gebr_get_user_from_address (const gchar *address);

Get substring before the first @ from address . In case there's no @, get the returns the local user.


gebr_get_host_from_address ()

gchar *
gebr_get_host_from_address (const gchar *address);

Get substring after the first @ and before the first space In case there's no @, get the substring before the first space


gebr_verify_address_without_username ()

gboolean
gebr_verify_address_without_username (const gchar *address);

gebr_kill_by_port ()

gboolean
gebr_kill_by_port (gint port);

gebr_key_filename ()

gchar *
gebr_key_filename (gboolean public);

gebr_create_id_with_current_time ()

gchar *
gebr_create_id_with_current_time ();

gebr_double_list_to_list ()

GList *
gebr_double_list_to_list (GList *double_list);

gebr_gzfile_get_contents ()

gboolean
gebr_gzfile_get_contents (const gchar *filename,
                          GString *contents,
                          gchar **error);

Parameters

filename

The name of gzipped file

 

contents

a GString to fill the contents of file

 

error

an error message or NULL

 

Returns

FALSE if have some error, TRUE otherwise


gebr_callback_true ()

gboolean
gebr_callback_true (void);

Returns

TRUE.


gebr_string_freeall ()

void
gebr_string_freeall (GString *string);

Equivalent to calling g_string_free(string, TRUE).


gebr_apply_pattern_on_address ()

const gchar *
gebr_apply_pattern_on_address (const gchar *addr);

gebr_gqueue_push_tail_avoiding_duplicates ()

GQueue *
gebr_gqueue_push_tail_avoiding_duplicates
                               (GQueue *queue,
                                const gchar *data);

gebr_paths_get_value_by_key ()

const gchar *
gebr_paths_get_value_by_key (const gchar ***paths,
                             const gchar *key);

gebr_get_nfsid ()

const gchar *
gebr_get_nfsid (void);

Returns

the NFSID of the calling process domain.


GEBR_LOCK_FILE ()

void
GEBR_LOCK_FILE (const gchar *path);

Locks the file pointed by path . You must call GEBR_UNLOCK_FILE() when done.


GEBR_UNLOCK_FILE ()

void
GEBR_UNLOCK_FILE (const gchar *path);

Unlocks the file pointed by path .

Types and Values

enum TimesType

Members

TIME_NONE

   

TIME_MOMENTS_AGO

   

TIME_HOURS_AGO

   

TIME_DAYS_AGO

   

TIME_WEEKS_AGO

   

TIME_MONTHS_AGO

   

TIME_YEARS_AGO

   

TIME_N_TYPES