35 #include "qof-backend.hpp"    37 G_GNUC_UNUSED 
static QofLogModule log_module = QOF_MOD_UTIL;
    43     GList *keys = g_list_sort(g_hash_table_get_keys(hash_table), compare_func);
    45     for (iter = keys; iter; iter = iter->next)
    47         func(iter->data, g_hash_table_lookup(hash_table, iter->data), user_data);
    56     gchar *haystack_casefold, *haystack_normalized;
    57     gchar *needle_casefold, *needle_normalized;
    60     g_return_val_if_fail (haystack && needle, FALSE);
    62     haystack_casefold = g_utf8_casefold (haystack, -1);
    63     haystack_normalized = g_utf8_normalize (haystack_casefold, -1,
    65     g_free (haystack_casefold);
    67     needle_casefold = g_utf8_casefold (needle, -1);
    68     needle_normalized = g_utf8_normalize (needle_casefold, -1, G_NORMALIZE_NFC);
    69     g_free (needle_casefold);
    71     p = strstr (haystack_normalized, needle_normalized);
    72     g_free (haystack_normalized);
    73     g_free (needle_normalized);
    82 qof_utf8_strcasecmp (
const gchar *da, 
const gchar *db)
    84     gchar *da_casefold, *db_casefold;
    87     g_return_val_if_fail (da != NULL, 0);
    88     g_return_val_if_fail (db != NULL, 0);
    90     da_casefold = g_utf8_casefold (da, -1);
    91     db_casefold = g_utf8_casefold (db, -1);
    92     retval = g_utf8_collate (da_casefold, db_casefold);
   106             gint retval = qof_utf8_strcasecmp ((da), (db));
   108             if (retval) 
return retval;
   111     else if ((!(da)) && (db))
   115     else if ((da) && (!(db)))
   125     if (da && db) 
return strcmp (da, db);
   126     if (!da && db && 0 == db[0]) 
return 0;
   127     if (!db && da && 0 == da[0]) 
return 0;
   128     if (!da && db) 
return -1;
   129     if (da && !db) 
return +1;
   133 #define MAX_DIGITS 50   139     gchar buf[MAX_DIGITS];
   140     gulong broke[MAX_DIGITS];
   142     gulong places = 0, reval;
   144     if ((2 > base) || (36 < base)) 
return NULL;
   148     for (i = 0; i < MAX_DIGITS; i++)
   158     for (i = places - 2; i >= 0; i--)
   166     for (i = 0; i < (gint)places; i++)
   170             buf[places-1-i] = 0x30 + broke[i];  
   174             buf[places-1-i] = 0x41 - 10 + broke[i];  
   179     return g_strdup (buf);
   189     if (s == NULL) 
return FALSE;
   190     if (*s == 0) 
return FALSE;
   192     while (*s && isspace(*s))
   195     if (*s == 0) 
return FALSE;
   196     if (!isdigit(*s)) 
return FALSE;
   198     while (*s && isdigit(*s))
   201     if (*s == 0) 
return TRUE;
   203     while (*s && isspace(*s))
   206     if (*s == 0) 
return TRUE;
   216 G_GNUC_UNUSED 
static const gchar *
   217 qof_util_whitespace_filter (
const gchar * val)
   220     if (!val) 
return NULL;
   222     len = strspn (val, 
"\a\b\t\n\v\f\r ");
   223     if (0 == val[len]) 
return NULL;
   227 #ifdef THESE_CAN_BE_USEFUL_FOR_DEGUGGING   228 static guint g_str_hash_KEY(gconstpointer v)
   230     return g_str_hash(v);
   232 static guint g_str_hash_VAL(gconstpointer v)
   234     return g_str_hash(v);
   236 static gpointer g_strdup_VAL(gpointer v)
   240 static gpointer g_strdup_KEY(gpointer v)
   244 static void g_free_VAL(gpointer v)
   248 static void g_free_KEY(gpointer v)
   252 static gboolean qof_util_str_equal(gconstpointer v, gconstpointer v2)
   254     return (v && v2) ? g_str_equal(v, v2) : FALSE;
   263     qof_object_initialize ();
   265     qof_book_register ();
   271     qof_query_shutdown ();
   272     qof_object_shutdown ();
   273     QofBackend::release_backends();
 gint safe_strcasecmp(const gchar *da, const gchar *db)
case sensitive comparison of strings da and db - either may be NULL. 
 
void qof_log_init(void)
Initialize the error logging subsystem. 
 
void qof_string_cache_destroy(void)
Destroy the qof_string_cache. 
 
void qof_log_shutdown(void)
Be nice, close the logfile if possible. 
 
gboolean gnc_strisnum(const gchar *s)
Returns true if string s is a number, possibly surrounded by whitespace. 
 
void qof_query_init(void)
Subsystem initialization and shutdown. 
 
gint null_strcmp(const gchar *da, const gchar *db)
The null_strcmp compares strings a and b the same way that strcmp() does, except that either may be n...
 
gchar * ultostr(gulong val, gint base)
The ultostr() subroutine is the inverse of strtoul(). 
 
void g_hash_table_foreach_sorted(GHashTable *hash_table, GHFunc func, gpointer user_data, GCompareFunc compare_func)
Calls the given function for each of the key/value pairs in the GHashTable in an order determined by ...
 
void qof_close(void)
Safely close down the Query Object Framework. 
 
gboolean qof_utf8_substr_nocase(const gchar *haystack, const gchar *needle)
Search for an occurrence of the substring needle in the string haystack, ignoring case...
 
void qof_init(void)
Initialise the Query Object Framework. 
 
void qof_string_cache_init(void)
The QOF String Cache: