Utility Functions

Utility Functions — Miscellaneous utility functions for evolution-data-server.

Synopsis

struct              tm;
int                 e_util_mkdir_hier                   (const char *path,
                                                         mode_t mode);
gchar *             e_util_strstrcase                   (const gchar *haystack,
                                                         const gchar *needle);
gchar *             e_util_unicode_get_utf8             (const gchar *text,
                                                         gunichar *out);
const gchar *       e_util_utf8_strstrcase              (const gchar *haystack,
                                                         const gchar *needle);
const gchar *       e_util_utf8_strstrcasedecomp        (const gchar *haystack,
                                                         const gchar *needle);
int                 e_util_utf8_strcasecmp              (const gchar *s1,
                                                         const gchar *s2);
guint64             e_util_pthread_id                   (pthread_t t);
void                e_filename_make_safe                (gchar *string);
size_t              e_utf8_strftime                     (char *s,
                                                         size_t max,
                                                         const char *fmt,
                                                         const struct tm *tm);
size_t              e_strftime                          (char *s,
                                                         size_t max,
                                                         const char *fmt,
                                                         const struct tm *tm);
const char *        e_util_get_prefix                   (void);
const char *        e_util_get_cp_prefix                (void);
const char *        e_util_get_localedir                (void);
char *              e_util_replace_prefix               (const char *configure_time_prefix,
                                                         const char *runtime_prefix,
                                                         const char *configure_time_path);

Description

Details

struct tm

struct tm;


e_util_mkdir_hier ()

int                 e_util_mkdir_hier                   (const char *path,
                                                         mode_t mode);

Warning

e_util_mkdir_hier is deprecated and should not be used in newly-written code.

Creates a directory hierarchy based on the string path. If path is an absolute path, the directories will be created relative to the root of the file system; otherwise, the directories will be created relative to the current directory.

path :

The directory hierarchy to create.

mode :

The permissions to use for the directories.

Returns :

0 on success; -1 on failure.

e_util_strstrcase ()

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

Find the first instance of needle in haystack, ignoring case for bytes that are ASCII characters.

haystack :

The string to search in.

needle :

The string to search for.

Returns :

A pointer to the start of needle in haystack, or NULL if needle is not found.

e_util_unicode_get_utf8 ()

gchar *             e_util_unicode_get_utf8             (const gchar *text,
                                                         gunichar *out);

Get a UTF-8 character from the beginning of text.

text :

The string to take the UTF-8 character from.

out :

The location to store the UTF-8 character in.

Returns :

A pointer to the next character in text after out.

e_util_utf8_strstrcase ()

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

Find the first instance of needle in haystack, ignoring case. (No proper case folding or decomposing is done.) Both needle and haystack are UTF-8 strings.

haystack :

The string to search in.

needle :

The string to search for.

Returns :

A pointer to the first instance of needle in haystack, or NULL if no match is found, or if either of the strings are not legal UTF-8 strings.

e_util_utf8_strstrcasedecomp ()

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

Find the first instance of needle in haystack, where both needle and haystack are UTF-8 strings. Both strings are stripped and decomposed for comparison, and case is ignored.

haystack :

The string to search in.

needle :

The string to search for.

Returns :

A pointer to the first instance of needle in haystack, or NULL if either of the strings are not legal UTF-8 strings.

e_util_utf8_strcasecmp ()

int                 e_util_utf8_strcasecmp              (const gchar *s1,
                                                         const gchar *s2);

s1 :

s2 :

Returns :


e_util_pthread_id ()

guint64             e_util_pthread_id                   (pthread_t t);

Returns a 64-bit integer hopefully uniquely identifying the thread. To be used in debugging output and logging only. To test whether two pthread_t values refer to the same thread, use pthread_equal().

There is no guarantee that calling e_util_pthread_id() on one thread first and later after that thread has dies on another won't return the same integer.

On some platforms it might even be that when called two times on the same thread's pthread_t (with some pthread API calls inbetween) we will return different values (this of course makes this function rather useless on such platforms).

On Linux and Win32, known to really return a unique id for each thread existing at a certain time. No guarantee that ids won't be reused after a thread has terminated, though.

t :

A pthread_t value

Returns :

A 64-bit integer.

e_filename_make_safe ()

void                e_filename_make_safe                (gchar *string);

string :


e_utf8_strftime ()

size_t              e_utf8_strftime                     (char *s,
                                                         size_t max,
                                                         const char *fmt,
                                                         const struct tm *tm);

The UTF-8 equivalent of e_strftime().

s :

The string array to store the result in.

max :

The size of array s.

fmt :

The formatting to use on tm.

tm :

The time value to format.

Returns :

The number of characters placed in s.

e_strftime ()

size_t              e_strftime                          (char *s,
                                                         size_t max,
                                                         const char *fmt,
                                                         const struct tm *tm);

This function is a wrapper around the strftime(3) function, which converts the %l and %k (12h and 24h) format variables if necessary.

s :

The string array to store the result in.

max :

The size of array s.

fmt :

The formatting to use on tm.

tm :

The time value to format.

Returns :

The number of characters placed in s.

e_util_get_prefix ()

const char *        e_util_get_prefix                   (void);

Returns :


e_util_get_cp_prefix ()

const char *        e_util_get_cp_prefix                (void);

Returns :


e_util_get_localedir ()

const char *        e_util_get_localedir                (void);

Returns :


e_util_replace_prefix ()

char *              e_util_replace_prefix               (const char *configure_time_prefix,
                                                         const char *runtime_prefix,
                                                         const char *configure_time_path);

configure_time_prefix :

runtime_prefix :

configure_time_path :

Returns :