static GStaticMutex log_mutex = G_STATIC_MUTEX_INIT;
static GHashTable *domains_hash;
-static char **ring_buffer;
-static int ring_buffer_next_index;
-static int ring_buffer_num_lines;
-static int ring_buffer_max_lines = DEFAULT_RING_BUFFER_NUM_LINES;
+static gchar **ring_buffer;
+static gint ring_buffer_next_index;
+static gint ring_buffer_num_lines;
+static gint ring_buffer_max_lines = DEFAULT_RING_BUFFER_NUM_LINES;
static GSList *milestones_head;
static GSList *milestones_tail;
}
void
-e_debug_log (gboolean is_milestone, const char *domain, const char *format, ...)
+e_debug_log (gboolean is_milestone, const gchar *domain, const gchar *format, ...)
{
va_list args;
}
static gboolean
-is_domain_enabled (const char *domain)
+is_domain_enabled (const gchar *domain)
{
/* User actions are always logged */
if (strcmp (domain, E_DEBUG_LOG_DOMAIN_USER) == 0)
if (ring_buffer)
return;
- ring_buffer = g_new0 (char *, ring_buffer_max_lines);
+ ring_buffer = g_new0 (gchar *, ring_buffer_max_lines);
ring_buffer_next_index = 0;
ring_buffer_num_lines = 0;
}
static void
-add_to_ring (char *str)
+add_to_ring (gchar *str)
{
ensure_ring ();
g_assert (str != NULL);
if (ring_buffer_num_lines == ring_buffer_max_lines) {
- /* We have an overlap, and the ring_buffer_next_index points to
+ /* We have an overlap, and the ring_buffer_next_index pogints to
* the "first" item. Free it to make room for the new item.
*/
}
static void
-add_to_milestones (const char *str)
+add_to_milestones (const gchar *str)
{
- char *str_copy;
+ gchar *str_copy;
str_copy = g_strdup (str);
}
void
-e_debug_logv (gboolean is_milestone, const char *domain, const char *format, va_list args)
+e_debug_logv (gboolean is_milestone, const gchar *domain, const gchar *format, va_list args)
{
- char *str;
- char *debug_str;
+ gchar *str;
+ gchar *debug_str;
struct timeval tv;
struct tm tm;
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
- (int) (tv.tv_usec / 100),
+ (gint) (tv.tv_usec / 100),
domain,
str);
g_free (str);
}
gboolean
-e_debug_log_load_configuration (const char *filename, GError **error)
+e_debug_log_load_configuration (const gchar *filename, GError **error)
{
GKeyFile *key_file;
- char **strings;
+ gchar **strings;
gsize num_strings;
- int num;
+ gint num;
GError *my_error;
g_assert (filename != NULL);
if (my_error)
g_error_free (my_error);
else {
- int i;
+ gint i;
for (i = 0; i < num_strings; i++)
strings[i] = g_strstrip (strings[i]);
- e_debug_log_enable_domains ((const char **) strings, num_strings);
+ e_debug_log_enable_domains ((const gchar **) strings, num_strings);
g_strfreev (strings);
}
}
void
-e_debug_log_enable_domains (const char **domains, int n_domains)
+e_debug_log_enable_domains (const gchar **domains, gint n_domains)
{
- int i;
+ gint i;
g_assert (domains != NULL);
g_assert (n_domains >= 0);
continue; /* user actions are always enabled */
if (g_hash_table_lookup (domains_hash, domains[i]) == NULL) {
- char *domain;
+ gchar *domain;
domain = g_strdup (domains[i]);
g_hash_table_insert (domains_hash, domain, domain);
}
void
-e_debug_log_disable_domains (const char **domains, int n_domains)
+e_debug_log_disable_domains (const gchar **domains, gint n_domains)
{
- int i;
+ gint i;
g_assert (domains != NULL);
g_assert (n_domains >= 0);
if (domains_hash) {
for (i = 0; i < n_domains; i++) {
- char *domain;
+ gchar *domain;
g_assert (domains[i] != NULL);
}
gboolean
-e_debug_log_is_domain_enabled (const char *domain)
+e_debug_log_is_domain_enabled (const gchar *domain)
{
gboolean retval;
}
struct domains_dump_closure {
- char **domains;
- int num_domains;
+ gchar **domains;
+ gint num_domains;
};
static void
domains_foreach_dump_cb (gpointer key, gpointer value, gpointer data)
{
struct domains_dump_closure *closure;
- char *domain;
+ gchar *domain;
closure = data;
domain = key;
{
GKeyFile *key_file;
struct domains_dump_closure closure;
- int num_domains;
+ gint num_domains;
key_file = g_key_file_new ();
if (domains_hash) {
num_domains = g_hash_table_size (domains_hash);
if (num_domains != 0) {
- closure.domains = g_new (char *, num_domains);
+ closure.domains = g_new (gchar *, num_domains);
closure.num_domains = 0;
g_hash_table_foreach (domains_hash, domains_foreach_dump_cb, &closure);
}
static gboolean
-write_string (const char *filename, FILE *file, const char *str, GError **error)
+write_string (const gchar *filename, FILE *file, const gchar *str, GError **error)
{
if (fputs (str, file) == EOF) {
- int saved_errno;
+ gint saved_errno;
saved_errno = errno;
g_set_error (error,
}
static gboolean
-dump_configuration (const char *filename, FILE *file, GError **error)
+dump_configuration (const gchar *filename, FILE *file, GError **error)
{
GKeyFile *key_file;
- char *data;
+ gchar *data;
gsize length;
gboolean success;
}
static gboolean
-dump_milestones (const char *filename, FILE *file, GError **error)
+dump_milestones (const gchar *filename, FILE *file, GError **error)
{
GSList *l;
return FALSE;
for (l = milestones_head; l; l = l->next) {
- const char *str;
+ const gchar *str;
str = l->data;
if (!(write_string (filename, file, str, error)
}
static gboolean
-dump_ring_buffer (const char *filename, FILE *file, GError **error)
+dump_ring_buffer (const gchar *filename, FILE *file, GError **error)
{
- int start_index;
- int i;
+ gint start_index;
+ gint i;
if (!write_string (filename, file, "===== BEGIN RING BUFFER =====\n", error))
return FALSE;
start_index = 0;
for (i = 0; i < ring_buffer_num_lines; i++) {
- int idx;
+ gint idx;
idx = (start_index + i) % ring_buffer_max_lines;
}
gboolean
-e_debug_log_dump (const char *filename, GError **error)
+e_debug_log_dump (const gchar *filename, GError **error)
{
FILE *file;
gboolean success;
file = fopen (filename, "w");
if (!file) {
- int saved_errno;
+ gint saved_errno;
saved_errno = errno;
g_set_error (error,
do_close:
if (fclose (file) != 0) {
- int saved_errno;
+ gint saved_errno;
saved_errno = errno;
{
time_t t;
struct tm tm;
- char *basename;
- char *filename;
+ gchar *basename;
+ gchar *filename;
gboolean retval;
g_assert (error == NULL || *error == NULL);
}
void
-e_debug_log_set_max_lines (int num_lines)
+e_debug_log_set_max_lines (gint num_lines)
{
- char **new_buffer;
- int lines_to_copy;
+ gchar **new_buffer;
+ gint lines_to_copy;
g_assert (num_lines > 0);
if (num_lines == ring_buffer_max_lines)
goto out;
- new_buffer = g_new0 (char *, num_lines);
+ new_buffer = g_new0 (gchar *, num_lines);
lines_to_copy = MIN (num_lines, ring_buffer_num_lines);
if (ring_buffer) {
- int start_index;
- int i;
+ gint start_index;
+ gint i;
if (ring_buffer_num_lines == ring_buffer_max_lines)
start_index = (ring_buffer_next_index + ring_buffer_max_lines - lines_to_copy) % ring_buffer_max_lines;
g_assert (start_index >= 0 && start_index < ring_buffer_max_lines);
for (i = 0; i < lines_to_copy; i++) {
- int idx;
+ gint idx;
idx = (start_index + i) % ring_buffer_max_lines;
unlock ();
}
-int
+gint
e_debug_log_get_max_lines (void)
{
- int retval;
+ gint retval;
lock ();
retval = ring_buffer_max_lines;
void
e_debug_log_clear (void)
{
- int i;
+ gint i;
lock ();
#define E_DEBUG_LOG_DOMAIN_GLOG "GLog" /* used for GLog messages; don't use it yourself */
#define E_DEBUG_LOG_DOMAIN_CAL_QUERIES "CalQueries" /* used for calendar queries analysis */
-void e_debug_log (gboolean is_milestone, const char *domain, const char *format, ...);
+void e_debug_log (gboolean is_milestone, const gchar *domain, const gchar *format, ...);
-void e_debug_logv (gboolean is_milestone, const char *domain, const char *format, va_list args);
+void e_debug_logv (gboolean is_milestone, const gchar *domain, const gchar *format, va_list args);
-gboolean e_debug_log_load_configuration (const char *filename, GError **error);
+gboolean e_debug_log_load_configuration (const gchar *filename, GError **error);
-void e_debug_log_enable_domains (const char **domains, int n_domains);
-void e_debug_log_disable_domains (const char **domains, int n_domains);
+void e_debug_log_enable_domains (const gchar **domains, gint n_domains);
+void e_debug_log_disable_domains (const gchar **domains, gint n_domains);
-gboolean e_debug_log_is_domain_enabled (const char *domain);
+gboolean e_debug_log_is_domain_enabled (const gchar *domain);
-gboolean e_debug_log_dump (const char *filename, GError **error);
+gboolean e_debug_log_dump (const gchar *filename, GError **error);
gboolean e_debug_log_dump_to_dated_file (GError **error);
-void e_debug_log_set_max_lines (int num_lines);
-int e_debug_log_get_max_lines (void);
+void e_debug_log_set_max_lines (gint num_lines);
+gint e_debug_log_get_max_lines (void);
/* For testing only */
void e_debug_log_clear (void);
static GObjectClass *parent_class;
#endif
-typedef gboolean (ESGeneratorFunc)(int argc, struct _ESExpResult **argv, struct _ESExpResult *r);
-typedef gboolean (ESOperatorFunc)(int argc, struct _ESExpResult **argv, struct _ESExpResult *r);
+typedef gboolean (ESGeneratorFunc) (gint argc, struct _ESExpResult **argv, struct _ESExpResult *r);
+typedef gboolean (ESOperatorFunc) (gint argc, struct _ESExpResult **argv, struct _ESExpResult *r);
+
/* FIXME: constant _TIME_MAX used in different files, move it somewhere */
#define _TIME_MAX ((time_t) INT_MAX) /* Max valid time_t */
}
#endif
-const char *time_functions[] = {
+const gchar *time_functions[] = {
"time-now",
"make-time",
"time-add-day",
};
static gboolean
-binary_generator (int argc, struct _ESExpResult **argv, struct _ESExpResult *r)
+binary_generator (gint argc, struct _ESExpResult **argv, struct _ESExpResult *r)
{
g_return_val_if_fail (r != NULL, FALSE);
g_return_val_if_fail (argc == 2, FALSE);
}
static gboolean
-unary_generator(int argc, struct _ESExpResult **argv, struct _ESExpResult *r)
+unary_generator(gint argc, struct _ESExpResult **argv, struct _ESExpResult *r)
{
/* unary generator with end time */
g_return_val_if_fail (r != NULL, FALSE);
}
static const struct {
- char *name;
+ const gchar *name;
ESGeneratorFunc *func;
} generators[] = {
{"occur-in-time-range?", binary_generator},
{"completed-before?", unary_generator},
};
-const int generators_count = sizeof(generators) / sizeof(generators[0]);
+const gint generators_count = sizeof(generators) / sizeof(generators[0]);
static gboolean
-or_operator(int argc, struct _ESExpResult **argv, struct _ESExpResult *r)
+or_operator(gint argc, struct _ESExpResult **argv, struct _ESExpResult *r)
{
/*
A B A or B
}
static gboolean
-and_operator(int argc, struct _ESExpResult **argv, struct _ESExpResult *r)
+and_operator(gint argc, struct _ESExpResult **argv, struct _ESExpResult *r)
{
/*
A B A and B
}
static const struct {
- char *name;
+ const gchar *name;
ESOperatorFunc *func;
} operators[] = {
{"or", or_operator},
{"and", and_operator}
};
-const int operators_count = sizeof(operators) / sizeof(operators[0]);
+const gint operators_count = sizeof(operators) / sizeof(operators[0]);
static ESOperatorFunc*
-get_operator_function(const char *fname)
+get_operator_function(const gchar *fname)
{
- int i;
+ gint i;
g_return_val_if_fail (fname != NULL, NULL);
}
static inline gboolean
-is_time_function(const char *fname)
+is_time_function(const gchar *fname)
{
- int i;
+ gint i;
g_return_val_if_fail (fname != NULL, FALSE);
}
static ESGeneratorFunc*
-get_generator_function(const char *fname)
+get_generator_function(const gchar *fname)
{
- int i;
+ gint i;
g_return_val_if_fail (fname != NULL, NULL);
e_sexp_term_evaluate_occur_times(struct _ESExp *f, struct _ESExpTerm *t, time_t *start, time_t *end)
{
struct _ESExpResult *r = NULL;
- int i, argc;
+ gint i, argc;
struct _ESExpResult **argv;
gboolean ok = TRUE;
break;
case ESEXP_TERM_IFUNC:
case ESEXP_TERM_FUNC:
+ {
+ ESGeneratorFunc *generator = NULL;
+ ESOperatorFunc *operator = NULL;
+
r(printf(" (function \"%s\"\n", t->value.func.sym->name));
r = e_sexp_result_new(f, ESEXP_RES_UNDEFINED);
start, end);
}
- ESGeneratorFunc *generator = NULL;
- ESOperatorFunc *operator = NULL;
-
if (is_time_function(t->value.func.sym->name)) {
/* evaluate time */
if (t->value.func.sym->f.func)
e_sexp_resultv_free(f, t->value.func.termcount, argv);
break;
-
+ }
case ESEXP_TERM_INT:
case ESEXP_TERM_BOOL:
case ESEXP_TERM_TIME: