~ubuntu-branches/ubuntu/quantal/maildir-utils/quantal

« back to all changes in this revision

Viewing changes to src/mu.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-01-19 20:12:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100119201243-d8qmzgxgexhy1bs0
Tags: 0.6~beta1-1
* new upstream release 0.6-beta
  - that merges the several different programs under one binary mu
  - no sqlite storage is used anymore
* debian packaging changes:
  - debian/patches
    . remove all patches
  - remove debian/HOWTO (upstream document) it is completely outdated
  - debian/control:
    . adjust build-dep for gmime-2.4
    . remove build-dep on quilt and sqlite
    . adjust the description to new reality
  - debian/rules:
    . do not try to install doc files that are not present anymore
    . disable quilt adaptions
  - add debian/NEWS that explains that the separate programs are gone

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
 
3
**
 
4
** This program is free software; you can redistribute it and/or modify it
 
5
** under the terms of the GNU General Public License as published by the
 
6
** Free Software Foundation; either version 3, or (at your option) any
 
7
** later version.
 
8
**
 
9
** This program is distributed in the hope that it will be useful,
 
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
** GNU General Public License for more details.
 
13
**
 
14
** You should have received a copy of the GNU General Public License
 
15
** along with this program; if not, write to the Free Software Foundation,
 
16
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
**
 
18
*/
 
19
 
 
20
#include <config.h>
 
21
 
 
22
#include <glib.h>
 
23
#include <glib-object.h>
 
24
#include <string.h>
 
25
#include <stdio.h> /* for fileno() */
 
26
 
 
27
#include "mu-config.h"
 
28
#include "mu-cmd.h"
 
29
#include "mu-log.h"
 
30
 
 
31
static gboolean
 
32
init_log (MuConfigOptions *opts)
 
33
{
 
34
        gboolean rv;
 
35
        
 
36
        if (opts->log_stderr)
 
37
                rv = mu_log_init_with_fd (fileno(stderr), FALSE,
 
38
                                          opts->quiet, opts->debug);
 
39
        else
 
40
                rv = mu_log_init (opts->muhome, TRUE, opts->quiet,
 
41
                                  opts->debug);
 
42
 
 
43
        if (!rv)
 
44
                g_printerr ("error: failed to initialize log\n");
 
45
        
 
46
        return rv;
 
47
}
 
48
 
 
49
static gboolean
 
50
parse_params (MuConfigOptions *config, int *argcp, char ***argvp)
 
51
{
 
52
        GError *error = NULL;
 
53
        GOptionContext *context;
 
54
        gboolean rv;
 
55
        
 
56
        context = g_option_context_new ("- maildir utilities");
 
57
 
 
58
        g_option_context_set_main_group (context,
 
59
                                         mu_config_options_group_mu (config));
 
60
        g_option_context_add_group (context,
 
61
                                    mu_config_options_group_index (config));
 
62
        g_option_context_add_group (context,
 
63
                                    mu_config_options_group_find (config));
 
64
        
 
65
        rv = g_option_context_parse (context, argcp, argvp, &error);
 
66
        if (!rv) {
 
67
                g_printerr ("error in options: %s\n", error->message);
 
68
                g_error_free (error);
 
69
        } else {
 
70
                g_option_context_free (context);
 
71
                mu_config_set_defaults (config);
 
72
        }
 
73
                
 
74
        return rv;
 
75
}
 
76
 
 
77
 
 
78
int
 
79
main (int argc, char *argv[])
 
80
{
 
81
        MuConfigOptions config;
 
82
        gboolean rv;
 
83
        
 
84
        g_type_init ();
 
85
 
 
86
        mu_config_init (&config);
 
87
        
 
88
        do {
 
89
                rv = FALSE;
 
90
 
 
91
                if (!parse_params (&config, &argc, &argv))
 
92
                        break;
 
93
 
 
94
                if (!init_log (&config))
 
95
                        break;
 
96
                
 
97
                rv = mu_cmd_execute (&config);
 
98
 
 
99
                mu_log_uninit();
 
100
 
 
101
        } while (0); 
 
102
 
 
103
        mu_config_uninit (&config);
 
104
        
 
105
        return rv ? 0 : 1;
 
106
}
 
107