mirror of https://github.com/djcb/mu.git
* expand dir names (ie. ~/Maildir => /home/user/Maildir); add init/uninit
This commit is contained in:
parent
1b30f4c8e5
commit
06ad732d81
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <string.h> /* memset */
|
||||
|
||||
#include "mu-util.h"
|
||||
#include "mu-config.h"
|
||||
|
||||
|
||||
|
@ -104,7 +106,7 @@ mu_config_options_group_query (MuConfigOptions *opts)
|
|||
|
||||
|
||||
void
|
||||
mu_config_set_defaults (MuConfigOptions *opts)
|
||||
mu_config_init (MuConfigOptions *opts)
|
||||
{
|
||||
g_return_if_fail (opts);
|
||||
|
||||
|
@ -112,11 +114,12 @@ mu_config_set_defaults (MuConfigOptions *opts)
|
|||
memset (opts, 0, sizeof(MuConfigOptions));
|
||||
|
||||
/* general */
|
||||
opts->quiet = FALSE;
|
||||
opts->debug = FALSE;
|
||||
opts->quiet = FALSE;
|
||||
opts->debug = FALSE;
|
||||
opts->muhome = mu_util_dir_expand ("~/.mu");
|
||||
|
||||
/* indexing */
|
||||
opts->maildir = "/home/djcb/Maildir";
|
||||
opts->maildir = mu_util_dir_expand ("~/Maildir");
|
||||
opts->cleanup = FALSE;
|
||||
opts->reindex = FALSE;
|
||||
|
||||
|
@ -124,3 +127,15 @@ mu_config_set_defaults (MuConfigOptions *opts)
|
|||
opts->xquery = FALSE;
|
||||
opts->fields = "d f s";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mu_config_uninit (MuConfigOptions *opts)
|
||||
{
|
||||
g_return_if_fail (opts);
|
||||
|
||||
/* yes, this is fine -- they are only const
|
||||
* for the 'outside world' */
|
||||
g_free ((gchar*)opts->muhome);
|
||||
g_free ((gchar*)opts->maildir);
|
||||
}
|
||||
|
|
|
@ -29,13 +29,14 @@
|
|||
struct _MuConfigOptions {
|
||||
|
||||
/* general options */
|
||||
gboolean quiet; /* don't give any output */
|
||||
gboolean debug; /* spew out debug info */
|
||||
gboolean quiet; /* don't give any output */
|
||||
gboolean debug; /* spew out debug info */
|
||||
const char *muhome;/* the House of Mu */
|
||||
gboolean version; /* request mu version */
|
||||
gboolean log_stderr; /*log to stderr (instead of logfile)*/
|
||||
gboolean log_append; /* append to log (instead of overwriting)*/
|
||||
|
||||
|
||||
/* options for indexing */
|
||||
const char *maildir; /* where the mails are */
|
||||
gboolean cleanup; /* cleanup deleted mails form db */
|
||||
|
@ -57,12 +58,22 @@ typedef struct _MuConfigOptions MuConfigOptions;
|
|||
|
||||
|
||||
/**
|
||||
* set default values for the configuration options
|
||||
* set default values for the configuration options; when you call
|
||||
* mu_config_init, you should also call mu_config_uninit when the data
|
||||
* is no longer needed.
|
||||
*
|
||||
* @param opts options
|
||||
*/
|
||||
void mu_config_init (MuConfigOptions *opts);
|
||||
|
||||
|
||||
/**
|
||||
* free the MuOptionsCOnfig structure; the the muhome and maildir
|
||||
* members are heap-allocated, so must be freed.
|
||||
*
|
||||
* @param opts
|
||||
*/
|
||||
void mu_config_set_defaults (MuConfigOptions *opts);
|
||||
|
||||
void mu_config_uninit (MuConfigOptions *opts);
|
||||
|
||||
/**
|
||||
* get the general options option group
|
||||
|
@ -92,4 +103,6 @@ GOptionGroup* mu_config_options_group_index (MuConfigOptions *opts);
|
|||
GOptionGroup* mu_config_options_group_query (MuConfigOptions *opts);
|
||||
|
||||
|
||||
char* mu_config_expanded_mu_home (MuConfigOptions *opts);
|
||||
|
||||
#endif /*__MU_CONFIG_H__*/
|
||||
|
|
Loading…
Reference in New Issue