mirror of https://github.com/djcb/mu.git
* fix compiler warning for newest gcc/g++
This commit is contained in:
parent
a051f3a89f
commit
daaec407eb
|
@ -29,7 +29,7 @@ INCLUDES=$(XAPIAN_CXXFLAGS) $(GMIME_CFLAGS) $(GLIB_CFLAGS)
|
||||||
# don't use -Werror, as it might break on other compilers
|
# don't use -Werror, as it might break on other compilers
|
||||||
# use -Wno-unused-parameters, because some callbacks may not
|
# use -Wno-unused-parameters, because some callbacks may not
|
||||||
# really need all the params they get
|
# really need all the params they get
|
||||||
AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement -pedantic
|
AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement -pedantic -Wno-variadic-macros
|
||||||
AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
|
AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
|
||||||
|
|
||||||
bin_PROGRAMS= \
|
bin_PROGRAMS= \
|
||||||
|
|
|
@ -366,9 +366,9 @@ show_parts (const char* path, MuConfig *opts, GError **err)
|
||||||
static gboolean
|
static gboolean
|
||||||
check_params (MuConfig *opts)
|
check_params (MuConfig *opts)
|
||||||
{
|
{
|
||||||
guint param_num;
|
size_t param_num;
|
||||||
|
|
||||||
param_num = mu_config_param_num(opts);
|
param_num = mu_config_param_num (opts);
|
||||||
|
|
||||||
if (param_num < 2) {
|
if (param_num < 2) {
|
||||||
g_warning ("usage: mu extract [options] <file> [<pattern>]");
|
g_warning ("usage: mu extract [options] <file> [<pattern>]");
|
||||||
|
|
|
@ -469,7 +469,7 @@ output_links (MuMsgIter *iter, const char* linksdir, gboolean clearlinks,
|
||||||
|
|
||||||
if (errcount > 0) {
|
if (errcount > 0) {
|
||||||
g_set_error (err, 0, MU_ERROR_FILE_CANNOT_LINK,
|
g_set_error (err, 0, MU_ERROR_FILE_CANNOT_LINK,
|
||||||
"error linking %u message(s)", errcount);
|
"error linking %u message(s)", (unsigned)errcount);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ output_xml_msg (MuMsg *msg)
|
||||||
print_attr_xml ("subject", mu_msg_get_subject (msg));
|
print_attr_xml ("subject", mu_msg_get_subject (msg));
|
||||||
g_print ("\t\t<date>%u</date>\n",
|
g_print ("\t\t<date>%u</date>\n",
|
||||||
(unsigned)mu_msg_get_date (msg));
|
(unsigned)mu_msg_get_date (msg));
|
||||||
g_print ("\t\t<size>%u</size>\n", mu_msg_get_size (msg));
|
g_print ("\t\t<size>%u</size>\n", (unsigned)mu_msg_get_size (msg));
|
||||||
print_attr_xml ("msgid", mu_msg_get_msgid (msg));
|
print_attr_xml ("msgid", mu_msg_get_msgid (msg));
|
||||||
print_attr_xml ("path", mu_msg_get_path (msg));
|
print_attr_xml ("path", mu_msg_get_path (msg));
|
||||||
print_attr_xml ("maildir", mu_msg_get_maildir (msg));
|
print_attr_xml ("maildir", mu_msg_get_maildir (msg));
|
||||||
|
|
|
@ -93,7 +93,8 @@ send_expr (const char* frm, ...)
|
||||||
|
|
||||||
expr = NULL;
|
expr = NULL;
|
||||||
exprlen = g_vasprintf (&expr, frm, ap);
|
exprlen = g_vasprintf (&expr, frm, ap);
|
||||||
hdrlen = snprintf (hdr, sizeof(hdr), BOX "%u" BOX, exprlen);
|
hdrlen = snprintf (hdr, sizeof(hdr), BOX "%u" BOX,
|
||||||
|
(unsigned)exprlen);
|
||||||
|
|
||||||
if (write (fileno(stdout), hdr, hdrlen) < 0)
|
if (write (fileno(stdout), hdr, hdrlen) < 0)
|
||||||
MU_WRITE_LOG ("error writing output: %s", strerror(errno));
|
MU_WRITE_LOG ("error writing output: %s", strerror(errno));
|
||||||
|
|
260
src/mu-config.c
260
src/mu-config.c
|
@ -1,4 +1,4 @@
|
||||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
/* -*-Mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
|
@ -33,6 +33,8 @@
|
||||||
#include "mu-cmd.h"
|
#include "mu-cmd.h"
|
||||||
|
|
||||||
|
|
||||||
|
static MuConfig MU_CONFIG;
|
||||||
|
|
||||||
|
|
||||||
static MuConfigFormat
|
static MuConfigFormat
|
||||||
get_output_format (const char *formatstr)
|
get_output_format (const char *formatstr)
|
||||||
|
@ -64,49 +66,49 @@ get_output_format (const char *formatstr)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_group_mu_defaults (MuConfig *opts)
|
set_group_mu_defaults (void)
|
||||||
{
|
{
|
||||||
gchar *exp;
|
gchar *exp;
|
||||||
|
|
||||||
if (!opts->muhome)
|
if (!MU_CONFIG.muhome)
|
||||||
opts->muhome = mu_util_guess_mu_homedir();
|
MU_CONFIG.muhome = mu_util_guess_mu_homedir();
|
||||||
|
|
||||||
exp = mu_util_dir_expand(opts->muhome);
|
exp = mu_util_dir_expand(MU_CONFIG.muhome);
|
||||||
if (exp) {
|
if (exp) {
|
||||||
g_free(opts->muhome);
|
g_free(MU_CONFIG.muhome);
|
||||||
opts->muhome = exp;
|
MU_CONFIG.muhome = exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for the MU_NOCOLOR env var; but in any case don't
|
/* check for the MU_NOCOLOR env var; but in any case don't
|
||||||
* use colors unless we're writing to a tty */
|
* use colors unless we're writing to a tty */
|
||||||
if (g_getenv (MU_NOCOLOR) != NULL)
|
if (g_getenv (MU_NOCOLOR) != NULL)
|
||||||
opts->nocolor = TRUE;
|
MU_CONFIG.nocolor = TRUE;
|
||||||
|
|
||||||
if (!isatty(fileno(stdout)))
|
if (!isatty(fileno(stdout)))
|
||||||
opts->nocolor = TRUE;
|
MU_CONFIG.nocolor = TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
config_options_group_mu (MuConfig *opts)
|
config_options_group_mu (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"debug", 'd', 0, G_OPTION_ARG_NONE, &opts->debug,
|
{"debug", 'd', 0, G_OPTION_ARG_NONE, &MU_CONFIG.debug,
|
||||||
"print debug output to standard error (false)", NULL},
|
"print debug output to standard error (false)", NULL},
|
||||||
{"quiet", 'q', 0, G_OPTION_ARG_NONE, &opts->quiet,
|
{"quiet", 'q', 0, G_OPTION_ARG_NONE, &MU_CONFIG.quiet,
|
||||||
"don't give any progress information (false)", NULL},
|
"don't give any progress information (false)", NULL},
|
||||||
{"version", 'v', 0, G_OPTION_ARG_NONE, &opts->version,
|
{"version", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.version,
|
||||||
"display version and copyright information (false)", NULL},
|
"display version and copyright information (false)", NULL},
|
||||||
{"muhome", 0, 0, G_OPTION_ARG_FILENAME, &opts->muhome,
|
{"muhome", 0, 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.muhome,
|
||||||
"specify an alternative mu directory", NULL},
|
"specify an alternative mu directory", NULL},
|
||||||
{"log-stderr", 0, 0, G_OPTION_ARG_NONE, &opts->log_stderr,
|
{"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr,
|
||||||
"log to standard error (false)", NULL},
|
"log to standard error (false)", NULL},
|
||||||
{"nocolor", 0, 0, G_OPTION_ARG_NONE, &opts->nocolor,
|
{"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor,
|
||||||
"don't use ANSI-colors in some output (false)", NULL},
|
"don't use ANSI-colors in some output (false)", NULL},
|
||||||
|
|
||||||
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
|
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
|
||||||
&opts->params, "parameters", NULL},
|
&MU_CONFIG.params, "parameters", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,41 +119,41 @@ config_options_group_mu (MuConfig *opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_group_index_defaults (MuConfig *opts)
|
set_group_index_defaults (void)
|
||||||
{
|
{
|
||||||
char *exp;
|
char *exp;
|
||||||
|
|
||||||
if (!opts->maildir)
|
if (!MU_CONFIG.maildir)
|
||||||
opts->maildir = mu_util_guess_maildir ();
|
MU_CONFIG.maildir = mu_util_guess_maildir ();
|
||||||
|
|
||||||
if (opts->maildir) {
|
if (MU_CONFIG.maildir) {
|
||||||
exp = mu_util_dir_expand(opts->maildir);
|
exp = mu_util_dir_expand(MU_CONFIG.maildir);
|
||||||
if (exp) {
|
if (exp) {
|
||||||
g_free(opts->maildir);
|
g_free(MU_CONFIG.maildir);
|
||||||
opts->maildir = exp;
|
MU_CONFIG.maildir = exp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
config_options_group_index (MuConfig * opts)
|
config_options_group_index (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &opts->maildir,
|
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.maildir,
|
||||||
"top of the maildir", NULL},
|
"top of the maildir", NULL},
|
||||||
{"reindex", 0, 0, G_OPTION_ARG_NONE, &opts->reindex,
|
{"reindex", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.reindex,
|
||||||
"index even already indexed messages (false)", NULL},
|
"index even already indexed messages (false)", NULL},
|
||||||
{"rebuild", 0, 0, G_OPTION_ARG_NONE, &opts->rebuild,
|
{"rebuild", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.rebuild,
|
||||||
"rebuild the database from scratch (false)", NULL},
|
"rebuild the database from scratch (false)", NULL},
|
||||||
{"autoupgrade", 0, 0, G_OPTION_ARG_NONE, &opts->autoupgrade,
|
{"autoupgrade", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.autoupgrade,
|
||||||
"auto-upgrade the database with new mu versions (false)",
|
"auto-upgrade the database with new mu versions (false)",
|
||||||
NULL},
|
NULL},
|
||||||
{"nocleanup", 0, 0, G_OPTION_ARG_NONE, &opts->nocleanup,
|
{"nocleanup", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocleanup,
|
||||||
"don't clean up the database after indexing (false)", NULL},
|
"don't clean up the database after indexing (false)", NULL},
|
||||||
{"xbatchsize", 0, 0, G_OPTION_ARG_INT, &opts->xbatchsize,
|
{"xbatchsize", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.xbatchsize,
|
||||||
"set transaction batchsize for xapian commits (0)", NULL},
|
"set transaction batchsize for xapian commits (0)", NULL},
|
||||||
{"max-msg-size", 0, 0, G_OPTION_ARG_INT, &opts->max_msg_size,
|
{"max-msg-size", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.max_msg_size,
|
||||||
"set the maximum size for message files", NULL},
|
"set the maximum size for message files", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -165,61 +167,61 @@ config_options_group_index (MuConfig * opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_group_find_defaults (MuConfig *opts)
|
set_group_find_defaults (void)
|
||||||
{
|
{
|
||||||
/* note, when no fields are specified, we use
|
/* note, when no fields are specified, we use
|
||||||
* date-from-subject, and sort descending by date. If fields
|
* date-from-subject, and sort descending by date. If fields
|
||||||
* *are* specified, we sort in ascending order. */
|
* *are* specified, we sort in ascending order. */
|
||||||
if (!opts->fields) {
|
if (!MU_CONFIG.fields) {
|
||||||
opts->fields = "d f s";
|
MU_CONFIG.fields = "d f s";
|
||||||
if (!opts->sortfield)
|
if (!MU_CONFIG.sortfield)
|
||||||
opts->sortfield = "d";
|
MU_CONFIG.sortfield = "d";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opts->formatstr) /* by default, use plain output */
|
if (!MU_CONFIG.formatstr) /* by default, use plain output */
|
||||||
opts->format = MU_CONFIG_FORMAT_PLAIN;
|
MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
|
||||||
else
|
else
|
||||||
opts->format =
|
MU_CONFIG.format =
|
||||||
get_output_format (opts->formatstr);
|
get_output_format (MU_CONFIG.formatstr);
|
||||||
|
|
||||||
if (opts->linksdir) {
|
if (MU_CONFIG.linksdir) {
|
||||||
gchar *old = opts->linksdir;
|
gchar *old = MU_CONFIG.linksdir;
|
||||||
opts->linksdir = mu_util_dir_expand(opts->linksdir);
|
MU_CONFIG.linksdir = mu_util_dir_expand(MU_CONFIG.linksdir);
|
||||||
if (!opts->linksdir) /* we'll check the dir later */
|
if (!MU_CONFIG.linksdir) /* we'll check the dir later */
|
||||||
opts->linksdir = old;
|
MU_CONFIG.linksdir = old;
|
||||||
else
|
else
|
||||||
g_free(old);
|
g_free(old);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
config_options_group_find (MuConfig *opts)
|
config_options_group_find (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"fields", 'f', 0, G_OPTION_ARG_STRING, &opts->fields,
|
{"fields", 'f', 0, G_OPTION_ARG_STRING, &MU_CONFIG.fields,
|
||||||
"fields to display in the output", NULL},
|
"fields to display in the output", NULL},
|
||||||
{"sortfield", 's', 0, G_OPTION_ARG_STRING, &opts->sortfield,
|
{"sortfield", 's', 0, G_OPTION_ARG_STRING, &MU_CONFIG.sortfield,
|
||||||
"field to sort on", NULL},
|
"field to sort on", NULL},
|
||||||
{"threads", 't', 0, G_OPTION_ARG_NONE, &opts->threads,
|
{"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads,
|
||||||
"show message threads", NULL},
|
"show message threads", NULL},
|
||||||
{"bookmark", 'b', 0, G_OPTION_ARG_STRING, &opts->bookmark,
|
{"bookmark", 'b', 0, G_OPTION_ARG_STRING, &MU_CONFIG.bookmark,
|
||||||
"use a bookmarked query", NULL},
|
"use a bookmarked query", NULL},
|
||||||
{"reverse", 'z', 0, G_OPTION_ARG_NONE, &opts->reverse,
|
{"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse,
|
||||||
"sort in reverse (descending) order (z -> a)", NULL},
|
"sort in reverse (descending) order (z -> a)", NULL},
|
||||||
{"summary", 'k', 0, G_OPTION_ARG_NONE, &opts->summary,
|
{"summary", 'k', 0, G_OPTION_ARG_NONE, &MU_CONFIG.summary,
|
||||||
"include a short summary of the message (false)", NULL},
|
"include a short summary of the message (false)", NULL},
|
||||||
{"linksdir", 0, 0, G_OPTION_ARG_STRING, &opts->linksdir,
|
{"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir,
|
||||||
"output as symbolic links to a target maildir", NULL},
|
"output as symbolic links to a target maildir", NULL},
|
||||||
{"clearlinks", 0, 0, G_OPTION_ARG_NONE, &opts->clearlinks,
|
{"clearlinks", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.clearlinks,
|
||||||
"clear old links before filling a linksdir (false)", NULL},
|
"clear old links before filling a linksdir (false)", NULL},
|
||||||
{"format", 'o', 0, G_OPTION_ARG_STRING, &opts->formatstr,
|
{"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
|
||||||
"output format ('plain'(*), 'links', 'xml',"
|
"output format ('plain'(*), 'links', 'xml',"
|
||||||
"'sexp', 'xquery')", NULL},
|
"'sexp', 'xquery')", NULL},
|
||||||
{"exec", 'e', 0, G_OPTION_ARG_STRING, &opts->exec,
|
{"exec", 'e', 0, G_OPTION_ARG_STRING, &MU_CONFIG.exec,
|
||||||
"execute command on each match message", NULL},
|
"execute command on each match message", NULL},
|
||||||
{"include-unreable", 0, 0, G_OPTION_ARG_NONE,
|
{"include-unreable", 0, 0, G_OPTION_ARG_NONE,
|
||||||
&opts->include_unreadable,
|
&MU_CONFIG.include_unreadable,
|
||||||
"don't ignore messages without a disk file (false)", NULL},
|
"don't ignore messages without a disk file (false)", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -233,17 +235,17 @@ config_options_group_find (MuConfig *opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup *
|
static GOptionGroup *
|
||||||
config_options_group_mkdir (MuConfig *opts)
|
config_options_group_mkdir (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"mode", 0, 0, G_OPTION_ARG_INT, &opts->dirmode,
|
{"mode", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.dirmode,
|
||||||
"set the mode (as in chmod), in octal notation", NULL},
|
"set the mode (as in chmod), in octal notation", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* set dirmode before, because '0000' is a valid mode */
|
/* set dirmode before, because '0000' is a valid mode */
|
||||||
opts->dirmode = 0755;
|
MU_CONFIG.dirmode = 0755;
|
||||||
|
|
||||||
og = g_option_group_new("mkdir", "options for the 'mkdir' command",
|
og = g_option_group_new("mkdir", "options for the 'mkdir' command",
|
||||||
"", NULL, NULL);
|
"", NULL, NULL);
|
||||||
|
@ -254,22 +256,22 @@ config_options_group_mkdir (MuConfig *opts)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_group_cfind_defaults (MuConfig *opts)
|
set_group_cfind_defaults (void)
|
||||||
{
|
{
|
||||||
if (!opts->formatstr) /* by default, use plain output */
|
if (!MU_CONFIG.formatstr) /* by default, use plain output */
|
||||||
opts->format = MU_CONFIG_FORMAT_PLAIN;
|
MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
|
||||||
else
|
else
|
||||||
opts->format = get_output_format (opts->formatstr);
|
MU_CONFIG.format = get_output_format (MU_CONFIG.formatstr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GOptionGroup *
|
static GOptionGroup *
|
||||||
config_options_group_cfind (MuConfig *opts)
|
config_options_group_cfind (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"format", 'o', 0, G_OPTION_ARG_STRING, &opts->formatstr,
|
{"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
|
||||||
"output format ('plain'(*), 'mutt', 'wanderlust',"
|
"output format ('plain'(*), 'mutt', 'wanderlust',"
|
||||||
"'org-contact', 'csv')", NULL},
|
"'org-contact', 'csv')", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
|
@ -284,24 +286,24 @@ config_options_group_cfind (MuConfig *opts)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_group_view_defaults (MuConfig *opts)
|
set_group_view_defaults (void)
|
||||||
{
|
{
|
||||||
if (!opts->formatstr) /* by default, use plain output */
|
if (!MU_CONFIG.formatstr) /* by default, use plain output */
|
||||||
opts->format = MU_CONFIG_FORMAT_PLAIN;
|
MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
|
||||||
else
|
else
|
||||||
opts->format = get_output_format (opts->formatstr);
|
MU_CONFIG.format = get_output_format (MU_CONFIG.formatstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup *
|
static GOptionGroup *
|
||||||
config_options_group_view (MuConfig *opts)
|
config_options_group_view (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"summary", 0, 0, G_OPTION_ARG_NONE, &opts->summary,
|
{"summary", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.summary,
|
||||||
"only show a short summary of the message (false)", NULL},
|
"only show a short summary of the message (false)", NULL},
|
||||||
{"terminate", 0, 0, G_OPTION_ARG_NONE, &opts->terminator,
|
{"terminate", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.terminator,
|
||||||
"terminate messages with ascii-0x07 (\\f, form-feed)", NULL},
|
"terminate messages with ascii-0x07 (\\f, form-feed)", NULL},
|
||||||
{"format", 'o', 0, G_OPTION_ARG_STRING, &opts->formatstr,
|
{"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
|
||||||
"output format ('plain'(*), 'sexp')", NULL},
|
"output format ('plain'(*), 'sexp')", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -316,27 +318,27 @@ config_options_group_view (MuConfig *opts)
|
||||||
|
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
config_options_group_extract (MuConfig *opts)
|
config_options_group_extract (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"save-attachments", 'a', 0, G_OPTION_ARG_NONE,
|
{"save-attachments", 'a', 0, G_OPTION_ARG_NONE,
|
||||||
&opts->save_attachments,
|
&MU_CONFIG.save_attachments,
|
||||||
"save all attachments (false)", NULL},
|
"save all attachments (false)", NULL},
|
||||||
{"save-all", 0, 0, G_OPTION_ARG_NONE, &opts->save_all,
|
{"save-all", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.save_all,
|
||||||
"save all parts (incl. non-attachments) (false)", NULL},
|
"save all parts (incl. non-attachments) (false)", NULL},
|
||||||
{"parts", 0, 0, G_OPTION_ARG_STRING, &opts->parts,
|
{"parts", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.parts,
|
||||||
"save specific parts (comma-separated list)", NULL},
|
"save specific parts (comma-separated list)", NULL},
|
||||||
{"target-dir", 0, 0, G_OPTION_ARG_FILENAME, &opts->targetdir,
|
{"target-dir", 0, 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.targetdir,
|
||||||
"target directory for saving", NULL},
|
"target directory for saving", NULL},
|
||||||
{"overwrite", 0, 0, G_OPTION_ARG_NONE, &opts->overwrite,
|
{"overwrite", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.overwrite,
|
||||||
"overwrite existing files (false)", NULL},
|
"overwrite existing files (false)", NULL},
|
||||||
{"play", 0, 0, G_OPTION_ARG_NONE, &opts->play,
|
{"play", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.play,
|
||||||
"try to 'play' (open) the extracted parts", NULL},
|
"try to 'play' (open) the extracted parts", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
opts->targetdir = g_strdup("."); /* default is the current dir */
|
MU_CONFIG.targetdir = g_strdup("."); /* default is the current dir */
|
||||||
|
|
||||||
og = g_option_group_new("extract",
|
og = g_option_group_new("extract",
|
||||||
"options for the 'extract' command",
|
"options for the 'extract' command",
|
||||||
|
@ -348,11 +350,11 @@ config_options_group_extract (MuConfig *opts)
|
||||||
|
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
config_options_group_server (MuConfig * opts)
|
config_options_group_server (void)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &opts->maildir,
|
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.maildir,
|
||||||
"top of the maildir", NULL},
|
"top of the maildir", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -368,7 +370,7 @@ config_options_group_server (MuConfig * opts)
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_cmd (MuConfig *opts, int *argcp, char ***argvp)
|
parse_cmd (int *argcp, char ***argvp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct {
|
struct {
|
||||||
|
@ -386,8 +388,8 @@ parse_cmd (MuConfig *opts, int *argcp, char ***argvp)
|
||||||
{ "server", MU_CONFIG_CMD_SERVER }
|
{ "server", MU_CONFIG_CMD_SERVER }
|
||||||
};
|
};
|
||||||
|
|
||||||
opts->cmd = MU_CONFIG_CMD_NONE;
|
MU_CONFIG.cmd = MU_CONFIG_CMD_NONE;
|
||||||
opts->cmdstr = NULL;
|
MU_CONFIG.cmdstr = NULL;
|
||||||
|
|
||||||
if (*argcp < 2) /* no command found at all */
|
if (*argcp < 2) /* no command found at all */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -397,37 +399,44 @@ parse_cmd (MuConfig *opts, int *argcp, char ***argvp)
|
||||||
* etc.)*/
|
* etc.)*/
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
opts->cmd = MU_CONFIG_CMD_UNKNOWN;
|
MU_CONFIG.cmd = MU_CONFIG_CMD_UNKNOWN;
|
||||||
opts->cmdstr = (*argvp)[1];
|
MU_CONFIG.cmdstr = (*argvp)[1];
|
||||||
|
|
||||||
for (i = 0; i != G_N_ELEMENTS(cmd_map); ++i)
|
for (i = 0; i != G_N_ELEMENTS(cmd_map); ++i)
|
||||||
if (strcmp (opts->cmdstr, cmd_map[i]._name) == 0)
|
if (strcmp (MU_CONFIG.cmdstr, cmd_map[i]._name) == 0)
|
||||||
opts->cmd = cmd_map[i]._cmd;
|
MU_CONFIG.cmd = cmd_map[i]._cmd;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_context_group (GOptionContext *context, MuConfig *opts)
|
add_context_group (GOptionContext *context)
|
||||||
{
|
{
|
||||||
GOptionGroup *group;
|
GOptionGroup *group;
|
||||||
|
|
||||||
switch (opts->cmd) {
|
switch (MU_CONFIG.cmd) {
|
||||||
case MU_CONFIG_CMD_INDEX:
|
case MU_CONFIG_CMD_INDEX:
|
||||||
group = config_options_group_index (opts); break;
|
group = config_options_group_index();
|
||||||
|
break;
|
||||||
case MU_CONFIG_CMD_FIND:
|
case MU_CONFIG_CMD_FIND:
|
||||||
group = config_options_group_find (opts); break;
|
group = config_options_group_find();
|
||||||
|
break;
|
||||||
case MU_CONFIG_CMD_MKDIR:
|
case MU_CONFIG_CMD_MKDIR:
|
||||||
group = config_options_group_mkdir (opts); break;
|
group = config_options_group_mkdir();
|
||||||
|
break;
|
||||||
case MU_CONFIG_CMD_EXTRACT:
|
case MU_CONFIG_CMD_EXTRACT:
|
||||||
group = config_options_group_extract (opts); break;
|
group = config_options_group_extract();
|
||||||
|
break;
|
||||||
case MU_CONFIG_CMD_CFIND:
|
case MU_CONFIG_CMD_CFIND:
|
||||||
group = config_options_group_cfind (opts); break;
|
group = config_options_group_cfind();
|
||||||
|
break;
|
||||||
case MU_CONFIG_CMD_VIEW:
|
case MU_CONFIG_CMD_VIEW:
|
||||||
group = config_options_group_view (opts); break;
|
group = config_options_group_view();
|
||||||
|
break;
|
||||||
case MU_CONFIG_CMD_SERVER:
|
case MU_CONFIG_CMD_SERVER:
|
||||||
group = config_options_group_server (opts); break;
|
group = config_options_group_server();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return; /* no group to add */
|
return; /* no group to add */
|
||||||
}
|
}
|
||||||
|
@ -437,17 +446,16 @@ add_context_group (GOptionContext *context, MuConfig *opts)
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_params (MuConfig *opts, int *argcp, char ***argvp)
|
parse_params (int *argcp, char ***argvp)
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean rv;
|
gboolean rv;
|
||||||
|
|
||||||
context = g_option_context_new("- mu general option");
|
context = g_option_context_new("- mu general option");
|
||||||
g_option_context_set_main_group(context,
|
g_option_context_set_main_group(context, config_options_group_mu());
|
||||||
config_options_group_mu(opts));
|
|
||||||
|
|
||||||
add_context_group (context, opts);
|
add_context_group (context);
|
||||||
|
|
||||||
rv = g_option_context_parse (context, argcp, argvp, &err);
|
rv = g_option_context_parse (context, argcp, argvp, &err);
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
|
@ -461,33 +469,32 @@ parse_params (MuConfig *opts, int *argcp, char ***argvp)
|
||||||
|
|
||||||
|
|
||||||
MuConfig*
|
MuConfig*
|
||||||
mu_config_new (int *argcp, char ***argvp)
|
mu_config_init (int *argcp, char ***argvp)
|
||||||
{
|
{
|
||||||
MuConfig *config;
|
|
||||||
|
|
||||||
g_return_val_if_fail (argcp && argvp, NULL);
|
g_return_val_if_fail (argcp && argvp, NULL);
|
||||||
|
|
||||||
config = g_new0 (MuConfig, 1);
|
memset (&MU_CONFIG, 0, sizeof(MU_CONFIG));
|
||||||
|
|
||||||
if (!parse_cmd (config, argcp, argvp) ||
|
if (!parse_cmd (argcp, argvp) ||
|
||||||
!parse_params(config, argcp, argvp)) {
|
!parse_params(argcp, argvp)) {
|
||||||
mu_config_destroy (config);
|
mu_config_uninit (&MU_CONFIG);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill in the defaults if user did not specify */
|
/* fill in the defaults if user did not specify */
|
||||||
set_group_mu_defaults (config);
|
set_group_mu_defaults();
|
||||||
set_group_index_defaults (config);
|
set_group_index_defaults();
|
||||||
set_group_find_defaults (config);
|
set_group_find_defaults();
|
||||||
set_group_cfind_defaults (config);
|
set_group_cfind_defaults();
|
||||||
set_group_view_defaults (config);
|
set_group_view_defaults();
|
||||||
/* set_group_mkdir_defaults (config); */
|
/* set_group_mkdir_defaults (config); */
|
||||||
|
|
||||||
return config;
|
return &MU_CONFIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_config_destroy (MuConfig *opts)
|
mu_config_uninit (MuConfig *opts)
|
||||||
{
|
{
|
||||||
if (!opts)
|
if (!opts)
|
||||||
return;
|
return;
|
||||||
|
@ -498,17 +505,18 @@ mu_config_destroy (MuConfig *opts)
|
||||||
g_free (opts->targetdir);
|
g_free (opts->targetdir);
|
||||||
|
|
||||||
g_strfreev (opts->params);
|
g_strfreev (opts->params);
|
||||||
g_free (opts);
|
|
||||||
|
memset (opts, 0, sizeof(MU_CONFIG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
guint
|
size_t
|
||||||
mu_config_param_num (MuConfig *conf)
|
mu_config_param_num (MuConfig *opts)
|
||||||
{
|
{
|
||||||
guint u;
|
size_t n;
|
||||||
|
|
||||||
g_return_val_if_fail (conf, 0);
|
g_return_val_if_fail (opts && opts->params, 0);
|
||||||
for (u = 0; conf->params[u]; ++u);
|
for (n = 0; opts->params[n]; ++n);
|
||||||
|
|
||||||
return u;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,45 +149,48 @@ struct _MuConfig {
|
||||||
typedef struct _MuConfig MuConfig;
|
typedef struct _MuConfig MuConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a new mu config object
|
* initialize a mu config object
|
||||||
*
|
*
|
||||||
* set default values for the configuration options; when you call
|
* set default values for the configuration options; when you call
|
||||||
* mu_config_init, you should also call mu_config_uninit when the data
|
* mu_config_init, you should also call mu_config_uninit when the data
|
||||||
* is no longer needed.
|
* is no longer needed.
|
||||||
*
|
*
|
||||||
|
* Note that is _static_ data, ie., mu_config_init will always return
|
||||||
|
* the same pointer
|
||||||
|
*
|
||||||
* @param opts options
|
* @param opts options
|
||||||
*/
|
*/
|
||||||
MuConfig *mu_config_new (int *argcp, char ***argvp)
|
MuConfig *mu_config_init (int *argcp, char ***argvp)
|
||||||
G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_WARN_UNUSED_RESULT;
|
||||||
/**
|
/**
|
||||||
* free the MuOptionsConfig structure; the the muhome and maildir
|
* free the MuConfig structure
|
||||||
* members are heap-allocated, so must be freed.
|
|
||||||
*
|
*
|
||||||
* @param opts a MuConfig struct, or NULL
|
* @param opts a MuConfig struct, or NULL
|
||||||
*/
|
*/
|
||||||
void mu_config_destroy (MuConfig *opts);
|
void mu_config_uninit (MuConfig *conf);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* execute the command / options in this config
|
* execute the command / options in this config
|
||||||
*
|
*
|
||||||
* @param opts the commands/options
|
* @param opts a MuConfig struct
|
||||||
*
|
*
|
||||||
* @return a value denoting the success/failure of the execution;
|
* @return a value denoting the success/failure of the execution;
|
||||||
* MU_ERROR_NONE (0) for success, non-zero for a failure. This is to used for
|
* MU_ERROR_NONE (0) for success, non-zero for a failure. This is to used for
|
||||||
* the exit code of the process
|
* the exit code of the process
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
MuError mu_config_execute (MuConfig *opts);
|
MuError mu_config_execute (MuConfig *conf);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* count the number of non-option parameters
|
* count the number of non-option parameters
|
||||||
*
|
*
|
||||||
* @param conf a MuConfig instance
|
* @param opts a MuConfig struct
|
||||||
*
|
*
|
||||||
* @return the number of non-option parameters, or 0 in case of error
|
* @return the number of non-option parameters, or 0 in case of error
|
||||||
*/
|
*/
|
||||||
guint mu_config_param_num (MuConfig *conf);
|
size_t mu_config_param_num (MuConfig *conf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -60,7 +60,7 @@ enum _FieldFlags {
|
||||||
* body */
|
* body */
|
||||||
FLAG_NORMALIZE = 1 << 8, /* field needs flattening for
|
FLAG_NORMALIZE = 1 << 8, /* field needs flattening for
|
||||||
* case/accents */
|
* case/accents */
|
||||||
FLAG_DONT_CACHE = 1 << 9, /* don't cache this field in
|
FLAG_DONT_CACHE = 1 << 9 /* don't cache this field in
|
||||||
* the MuMsg cache */
|
* the MuMsg cache */
|
||||||
};
|
};
|
||||||
typedef enum _FieldFlags FieldFlags;
|
typedef enum _FieldFlags FieldFlags;
|
||||||
|
|
|
@ -216,11 +216,11 @@ each_part (MuMsg *msg, MuMsgPart *part, gchar **parts)
|
||||||
name = g_strdup_printf ("\"part-%d\"", part->index);
|
name = g_strdup_printf ("\"part-%d\"", part->index);
|
||||||
|
|
||||||
*parts = g_strdup_printf
|
*parts = g_strdup_printf
|
||||||
("%s(:index %d :name %s :mime-type \"%s/%s\" :size %d)",
|
("%s(:index %d :name %s :mime-type \"%s/%s\" :size %u)",
|
||||||
*parts ? *parts : "", part->index, name,
|
*parts ? *parts : "", part->index, name,
|
||||||
part->type ? part->type : "application",
|
part->type ? part->type : "application",
|
||||||
part->subtype ? part->subtype : "octet-stream",
|
part->subtype ? part->subtype : "octet-stream",
|
||||||
part->size);
|
(unsigned)part->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "mu-config.h"
|
#include "mu-config.h"
|
||||||
#include "mu-log.h"
|
#include "mu-log.h"
|
||||||
#include "mu-util.h"
|
#include "mu-util.h"
|
||||||
|
|
||||||
#define MU_XAPIAN_DIRNAME "xapian"
|
#define MU_XAPIAN_DIRNAME "xapian"
|
||||||
#define MU_BOOKMARKS_FILENAME "bookmarks"
|
#define MU_BOOKMARKS_FILENAME "bookmarks"
|
||||||
#define MU_CACHE_DIRNAME "cache"
|
#define MU_CACHE_DIRNAME "cache"
|
||||||
|
@ -61,7 +61,7 @@ init_log (const char *muhome, const char *name,
|
||||||
{
|
{
|
||||||
gboolean rv;
|
gboolean rv;
|
||||||
char *logpath;
|
char *logpath;
|
||||||
|
|
||||||
if (log_stderr)
|
if (log_stderr)
|
||||||
return mu_log_init_with_fd (fileno(stderr), FALSE,
|
return mu_log_init_with_fd (fileno(stderr), FALSE,
|
||||||
quiet, debug);
|
quiet, debug);
|
||||||
|
@ -86,10 +86,10 @@ mu_runtime_init (const char* muhome_arg, const char *name)
|
||||||
|
|
||||||
g_return_val_if_fail (!_initialized, FALSE);
|
g_return_val_if_fail (!_initialized, FALSE);
|
||||||
g_return_val_if_fail (name, FALSE);
|
g_return_val_if_fail (name, FALSE);
|
||||||
|
|
||||||
if (!mu_util_init_system())
|
if (!mu_util_init_system())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (muhome_arg)
|
if (muhome_arg)
|
||||||
muhome = g_strdup (muhome_arg);
|
muhome = g_strdup (muhome_arg);
|
||||||
else
|
else
|
||||||
|
@ -101,7 +101,7 @@ mu_runtime_init (const char* muhome_arg, const char *name)
|
||||||
runtime_free ();
|
runtime_free ();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = g_new0 (MuRuntimeData, 1);
|
_data = g_new0 (MuRuntimeData, 1);
|
||||||
_data->_str[MU_RUNTIME_PATH_MUHOME] = muhome;
|
_data->_str[MU_RUNTIME_PATH_MUHOME] = muhome;
|
||||||
init_paths (muhome, _data);
|
init_paths (muhome, _data);
|
||||||
|
@ -112,7 +112,7 @@ mu_runtime_init (const char* muhome_arg, const char *name)
|
||||||
g_free (muhome);
|
g_free (muhome);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _initialized = TRUE;
|
return _initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,14 +121,14 @@ mu_runtime_init (const char* muhome_arg, const char *name)
|
||||||
gboolean
|
gboolean
|
||||||
mu_runtime_init_from_cmdline (int *pargc, char ***pargv, const char *name)
|
mu_runtime_init_from_cmdline (int *pargc, char ***pargv, const char *name)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (!_initialized, FALSE);
|
g_return_val_if_fail (!_initialized, FALSE);
|
||||||
g_return_val_if_fail (name, FALSE);
|
g_return_val_if_fail (name, FALSE);
|
||||||
|
|
||||||
if (!mu_util_init_system())
|
if (!mu_util_init_system())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
_data = g_new0 (MuRuntimeData, 1);
|
_data = g_new0 (MuRuntimeData, 1);
|
||||||
_data->_config = mu_config_new (pargc, pargv);
|
_data->_config = mu_config_init (pargc, pargv);
|
||||||
if (!_data->_config) {
|
if (!_data->_config) {
|
||||||
runtime_free ();
|
runtime_free ();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -145,7 +145,7 @@ mu_runtime_init_from_cmdline (int *pargc, char ***pargv, const char *name)
|
||||||
_data->_str[MU_RUNTIME_PATH_MUHOME] =
|
_data->_str[MU_RUNTIME_PATH_MUHOME] =
|
||||||
g_strdup (_data->_config->muhome);
|
g_strdup (_data->_config->muhome);
|
||||||
init_paths (_data->_str[MU_RUNTIME_PATH_MUHOME], _data);
|
init_paths (_data->_str[MU_RUNTIME_PATH_MUHOME], _data);
|
||||||
|
|
||||||
if (!init_log (runtime_path(MU_RUNTIME_PATH_MUHOME), name,
|
if (!init_log (runtime_path(MU_RUNTIME_PATH_MUHOME), name,
|
||||||
_data->_config->log_stderr,
|
_data->_config->log_stderr,
|
||||||
_data->_config->quiet,
|
_data->_config->quiet,
|
||||||
|
@ -153,7 +153,7 @@ mu_runtime_init_from_cmdline (int *pargc, char ***pargv, const char *name)
|
||||||
runtime_free ();
|
runtime_free ();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _initialized = TRUE;
|
return _initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,14 +165,14 @@ runtime_free (void)
|
||||||
|
|
||||||
for (i = 0; i != MU_RUNTIME_PATH_NUM; ++i)
|
for (i = 0; i != MU_RUNTIME_PATH_NUM; ++i)
|
||||||
g_free (_data->_str[i]);
|
g_free (_data->_str[i]);
|
||||||
|
|
||||||
g_free (_data->_name);
|
g_free (_data->_name);
|
||||||
|
|
||||||
mu_config_destroy (_data->_config);
|
mu_config_uninit (_data->_config);
|
||||||
|
|
||||||
mu_log_uninit();
|
mu_log_uninit();
|
||||||
|
|
||||||
g_free (_data);
|
g_free (_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -184,7 +184,7 @@ mu_runtime_uninit (void)
|
||||||
|
|
||||||
_initialized = FALSE;
|
_initialized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
create_dirs_maybe (MuRuntimeData *data)
|
create_dirs_maybe (MuRuntimeData *data)
|
||||||
|
@ -200,7 +200,7 @@ create_dirs_maybe (MuRuntimeData *data)
|
||||||
g_warning ("failed to create log dir");
|
g_warning ("failed to create log dir");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ init_paths (const char* muhome, MuRuntimeData *data)
|
||||||
data->_str [MU_RUNTIME_PATH_XAPIANDB] =
|
data->_str [MU_RUNTIME_PATH_XAPIANDB] =
|
||||||
g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR,
|
g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR,
|
||||||
MU_XAPIAN_DIRNAME);
|
MU_XAPIAN_DIRNAME);
|
||||||
|
|
||||||
data->_str [MU_RUNTIME_PATH_BOOKMARKS] =
|
data->_str [MU_RUNTIME_PATH_BOOKMARKS] =
|
||||||
g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR,
|
g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR,
|
||||||
MU_BOOKMARKS_FILENAME);
|
MU_BOOKMARKS_FILENAME);
|
||||||
|
@ -220,25 +220,25 @@ init_paths (const char* muhome, MuRuntimeData *data)
|
||||||
data->_str [MU_RUNTIME_PATH_CACHE] =
|
data->_str [MU_RUNTIME_PATH_CACHE] =
|
||||||
g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR,
|
g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR,
|
||||||
MU_CACHE_DIRNAME);
|
MU_CACHE_DIRNAME);
|
||||||
|
|
||||||
data->_str [MU_RUNTIME_PATH_CONTACTS] =
|
data->_str [MU_RUNTIME_PATH_CONTACTS] =
|
||||||
g_strdup_printf ("%s%c%s", data->_str[MU_RUNTIME_PATH_CACHE],
|
g_strdup_printf ("%s%c%s", data->_str[MU_RUNTIME_PATH_CACHE],
|
||||||
G_DIR_SEPARATOR, MU_CONTACTS_FILENAME);
|
G_DIR_SEPARATOR, MU_CONTACTS_FILENAME);
|
||||||
|
|
||||||
data->_str [MU_RUNTIME_PATH_LOG] =
|
data->_str [MU_RUNTIME_PATH_LOG] =
|
||||||
g_strdup_printf ("%s%c%s", muhome,
|
g_strdup_printf ("%s%c%s", muhome,
|
||||||
G_DIR_SEPARATOR, MU_LOG_DIRNAME);
|
G_DIR_SEPARATOR, MU_LOG_DIRNAME);
|
||||||
|
|
||||||
if (!create_dirs_maybe (data))
|
if (!create_dirs_maybe (data))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* so we can called when _initialized is FALSE still */
|
/* so we can called when _initialized is FALSE still */
|
||||||
static const char*
|
static const char*
|
||||||
runtime_path (MuRuntimePath path)
|
runtime_path (MuRuntimePath path)
|
||||||
{
|
{
|
||||||
return _data->_str[path];
|
return _data->_str[path];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,13 +249,13 @@ mu_runtime_path (MuRuntimePath path)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (_initialized, NULL);
|
g_return_val_if_fail (_initialized, NULL);
|
||||||
g_return_val_if_fail (path < MU_RUNTIME_PATH_NUM, NULL);
|
g_return_val_if_fail (path < MU_RUNTIME_PATH_NUM, NULL);
|
||||||
|
|
||||||
return runtime_path (path);
|
return runtime_path (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
MuConfig*
|
MuConfig*
|
||||||
mu_runtime_config (void)
|
mu_runtime_config (void)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (_initialized, NULL);
|
g_return_val_if_fail (_initialized, NULL);
|
||||||
return _data->_config;
|
return _data->_config;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
MU_WRITE_LOG ("%s: opened %s (batch size: %u) for read-write",
|
MU_WRITE_LOG ("%s: opened %s (batch size: %u) for read-write",
|
||||||
__FUNCTION__, this->path(), batch_size());
|
__FUNCTION__, this->path(), (unsigned)batch_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a read-only MuStore */
|
/* create a read-only MuStore */
|
||||||
|
|
|
@ -419,7 +419,7 @@ mu_util_fputs_encoded (const char *str, FILE *stream)
|
||||||
GError *err;
|
GError *err;
|
||||||
unsigned bytes;
|
unsigned bytes;
|
||||||
err = NULL;
|
err = NULL;
|
||||||
conv = g_locale_from_utf8 (str, -1, &bytes, NULL, &err);
|
conv = g_locale_from_utf8 (str, -1, (gsize*)&bytes, NULL, &err);
|
||||||
if (!conv || err) {
|
if (!conv || err) {
|
||||||
/* conversion failed; this happens because is
|
/* conversion failed; this happens because is
|
||||||
* some cases GMime may gives us non-UTF-8
|
* some cases GMime may gives us non-UTF-8
|
||||||
|
|
Loading…
Reference in New Issue