* many changes to the config system
This commit is contained in:
128
src/mu-config.h
128
src/mu-config.h
@ -22,93 +22,107 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include <sys/types.h> /* for mode_t */
|
||||
|
||||
#include "mu-msg-fields.h"
|
||||
#include <mu-msg-fields.h>
|
||||
#include <mu-util.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
enum _MuConfigCmd {
|
||||
MU_CONFIG_CMD_INDEX,
|
||||
MU_CONFIG_CMD_FIND,
|
||||
MU_CONFIG_CMD_CLEANUP,
|
||||
MU_CONFIG_CMD_MKDIR,
|
||||
MU_CONFIG_CMD_VIEW,
|
||||
MU_CONFIG_CMD_EXTRACT,
|
||||
MU_CONFIG_CMD_NONE,
|
||||
MU_CONFIG_CMD_INDEX,
|
||||
MU_CONFIG_CMD_FIND,
|
||||
MU_CONFIG_CMD_CLEANUP,
|
||||
MU_CONFIG_CMD_MKDIR,
|
||||
MU_CONFIG_CMD_VIEW,
|
||||
MU_CONFIG_CMD_EXTRACT,
|
||||
MU_CONFIG_CMD_NONE,
|
||||
|
||||
MU_CONFIG_CMD_UNKNOWN
|
||||
MU_CONFIG_CMD_UNKNOWN
|
||||
};
|
||||
typedef enum _MuConfigCmd MuConfigCmd;
|
||||
|
||||
|
||||
|
||||
/* struct with all configuration options for mu; it will be filled
|
||||
* from the config file, and/or command line arguments */
|
||||
|
||||
struct _MuConfigOptions {
|
||||
struct _MuConfig {
|
||||
|
||||
MuConfigCmd cmd; /* the command, or MU_CONFIG_CMD_NONE */
|
||||
const char *cmdstr; /* cmd string, for user info */
|
||||
MuConfigCmd cmd; /* the command, or
|
||||
* MU_CONFIG_CMD_NONE */
|
||||
const char *cmdstr; /* cmd string, for user info */
|
||||
|
||||
/* general options */
|
||||
gboolean quiet; /* don't give any output */
|
||||
gboolean debug; /* spew out debug info */
|
||||
char *muhome; /* the House of Mu */
|
||||
gboolean version; /* request mu version */
|
||||
gboolean log_stderr; /* log to stderr (not logfile) */
|
||||
gchar** params; /* parameters (for querying) */
|
||||
/* general options */
|
||||
gboolean quiet; /* don't give any output */
|
||||
gboolean debug; /* spew out debug info */
|
||||
char *muhome; /* the House of Mu */
|
||||
gboolean version; /* request mu version */
|
||||
gboolean log_stderr; /* log to stderr (not logfile) */
|
||||
gchar** params; /* parameters (for querying) */
|
||||
|
||||
/* options for indexing */
|
||||
char *maildir; /* where the mails are */
|
||||
gboolean nocleanup; /* don't cleanup deleted mails from db */
|
||||
gboolean reindex; /* re-index existing mails */
|
||||
gboolean rebuild; /* empty the database before indexing */
|
||||
gboolean autoupgrade; /* automatically upgrade db
|
||||
* when needed */
|
||||
int xbatchsize; /* batchsize for xapian commits, or 0 for default
|
||||
* */
|
||||
/* options for indexing */
|
||||
char *maildir; /* where the mails are */
|
||||
gboolean nocleanup; /* don't cleanup deleted mails from db */
|
||||
gboolean reindex; /* re-index existing mails */
|
||||
gboolean rebuild; /* empty the database before indexing */
|
||||
gboolean autoupgrade; /* automatically upgrade db
|
||||
* when needed */
|
||||
int xbatchsize; /* batchsize for xapian
|
||||
* commits, or 0 for
|
||||
* default */
|
||||
|
||||
/* options for querying */
|
||||
gboolean xquery; /* give the Xapian query instead of
|
||||
search results */
|
||||
char *fields; /* fields to show in output */
|
||||
char *sortfield; /* field to sort by (string) */
|
||||
gboolean descending; /* sort descending? */
|
||||
unsigned summary_len; /* max # of lines of msg in summary */
|
||||
char *bookmark; /* use bookmark */
|
||||
/* output to a maildir with symlinks */
|
||||
char *linksdir; /* maildir to output symlinks */
|
||||
gboolean clearlinks; /* clear a linksdir before filling */
|
||||
mode_t dirmode; /* mode for the created maildir */
|
||||
/* options for querying */
|
||||
gboolean xquery; /* give the Xapian query
|
||||
instead of search
|
||||
results */
|
||||
char *fields; /* fields to show in output */
|
||||
char *sortfield; /* field to sort by (string) */
|
||||
gboolean descending; /* sort descending? */
|
||||
unsigned summary_len; /* max # of lines of msg in summary */
|
||||
char *bookmark; /* use bookmark */
|
||||
|
||||
/* options for extracting parts */
|
||||
gboolean *save_all; /* extract all parts */
|
||||
gboolean *save_attachments; /* extract all attachment parts */
|
||||
gchar *parts; /* comma-sep'd list of parts to save */
|
||||
char *targetdir; /* where to save the attachments */
|
||||
gboolean overwrite; /* should we overwrite same-named files */
|
||||
/* output to a maildir with symlinks */
|
||||
char *linksdir; /* maildir to output symlinks */
|
||||
gboolean clearlinks; /* clear a linksdir before filling */
|
||||
mode_t dirmode; /* mode for the created maildir */
|
||||
|
||||
/* options for extracting parts */
|
||||
gboolean *save_all; /* extract all parts */
|
||||
gboolean *save_attachments; /* extract all attachment parts */
|
||||
gchar *parts; /* comma-sep'd list of parts
|
||||
* to save */
|
||||
char *targetdir; /* where to save the attachments */
|
||||
gboolean overwrite; /* should we overwrite same-named files */
|
||||
};
|
||||
typedef struct _MuConfigOptions MuConfigOptions;
|
||||
typedef struct _MuConfig MuConfig;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* create a new mu config object
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
gboolean mu_config_init (MuConfigOptions *opts, int *argcp, char ***argvp);
|
||||
MuConfig *mu_config_new (int *argcp, char ***argvp);
|
||||
|
||||
|
||||
/**
|
||||
* free the MuOptionsCOnfig structure; the the muhome and maildir
|
||||
/**
|
||||
* free the MuOptionsConfig structure; the the muhome and maildir
|
||||
* members are heap-allocated, so must be freed.
|
||||
*
|
||||
* @param opts
|
||||
* @param opts a MuConfig struct, or NULL
|
||||
*/
|
||||
void mu_config_uninit (MuConfigOptions *opts);
|
||||
void mu_config_destroy (MuConfig *opts);
|
||||
|
||||
/**
|
||||
* execute the command / options in this config
|
||||
*
|
||||
* @param opts the commands/options
|
||||
*
|
||||
* @return a value denoting the success/failure of the execution; MU_CONFIG_RETVAL_OK (0)
|
||||
* for success, non-zero for a failure. This is to used for the exit
|
||||
* code of the process
|
||||
*/
|
||||
MuExitCode mu_config_execute (MuConfig *opts);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user