File: main.cc

package info (click to toggle)
multimail 0.52-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,048 kB
  • sloc: cpp: 16,140; ansic: 82; makefile: 73
file content (107 lines) | stat: -rw-r--r-- 2,004 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * MultiMail offline mail reader
 * main, error

 Copyright 1996-1997 Kolossvary Tamas <thomas@vma.bme.hu>
 Copyright 1997-2017 William McBrine <wmcbrine@gmail.com>
 Distributed under the GNU General Public License, version 3 or later. */

#include "error.h"
#include "interfac.h"

#include <locale.h>

Interface *ui = 0;
const chtype *ColorArray = 0;
time_t starttime;
ErrorType error;
mmail mm;

#ifdef USE_MOUSE
MEVENT mm_mouse_event;
#endif

ErrorType::ErrorType()
{
    starttime = time(0);
    srand((unsigned) starttime);

    origdir = mygetcwd();
}

ErrorType::~ErrorType()
{
    mychdir(origdir);
    delete[] origdir;
}

const char *ErrorType::getOrigDir()
{
    return origdir;
}

#if defined(SIGWINCH) && !defined(PDCURSES) && !defined(NCURSES_SIGWINCH)
extern "C" void sigwinchHandler(int sig)
{
    if (sig == SIGWINCH)
        ungetch(KEY_RESIZE);
    signal(SIGWINCH, sigwinchHandler);
}
#endif

void fatalError(const char *description)
{
    delete ui;
    fprintf(stderr, "\n\n%s\n\n", description);
    exit(EXIT_FAILURE);
}

void pauseError(const char *description)
{
    fprintf(stderr, "\n\n%s\n\n", description);
    napms(2000);
}

#ifdef USE_MOUSE
void mm_mouse_get()
{
# ifdef NCURSES_MOUSE_VERSION
    getmouse(&mm_mouse_event);
# else
    nc_getmouse(&mm_mouse_event);
# endif
}
#endif

int main(int argc, char **argv)
{
    char **ARGV = argv;
    int ARGC = argc;

    setlocale(LC_ALL, "");

    while ((ARGC > 2) && ('-' == ARGV[1][0])) {
        char *resName = ARGV[1] + 1;
        char *resValue = ARGV[2];

        if ('-' == *resName)
            resName++;

        mm.resourceObject->processOneByName(resName, resValue);

        ARGV += 2;
        ARGC -= 2;
    }

    ui = new Interface();
    ui->init();
    if (ARGC > 1)
        for (int i = 1; (i < ARGC) &&
            ui->fromCommandLine(ARGV[i]); i++);
    else
        ui->main();
    delete ui;
    ui = 0;    // some destructors, executed after this, may check for this

    return EXIT_SUCCESS;
}