summaryrefslogtreecommitdiff
path: root/src/Polynom.c
blob: a80cafd0f143de476b36e27b2ab9ff03597f2302 (plain)
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
/*
 *
 * Programme principal
 *
 */

#include <stdio.h>
#include <signal.h>
#include "main.h"
#include "hash.h"
#include "parser.h"
#include "polynom.h"
#include "pile.h"
#include "exceptions.h"
#include "scalaires.h"
#include "interface.h"
#include "terminal.h"
#include "config.h"

_TableauVariable variables;
char *mute;
char valid;

/*
 * Les deux gestionnaires de signaux 
 */

void segfaulthand(int i)
{
    exception(2, _("Signal received: segfault"));
}

void ctrlbreakhand(int i)
{
    exception(1, _("Signal received: break"));
}

/*
 * Les routines generales 
 */

void init_all(char *m)
{
    Initialise(&variables);
    /*
     * nom de la variable utilisee pour la saisie des polynomes, a recuperer en argv
     * ATTENTION: elle est case sensitive 
     */
    if (m) {
	mute = m;
    } else {
	mute = "x";
    }
    display = DEC;
}

void flush_all(void)
{
}

void invite(void)
{
    fprintf(stderr, "Polynomia v1.0\n\n");
}

/*
 * Et notre main. On ne fait que lancer la boucle principale de l'interface 
 */

int main(int argc, char **argv)
{
    setlocale(LC_ALL, "");
    bindtextdomain(PACKAGE, LOCALEDIR);
    textdomain(PACKAGE);

    invite();

    signal(SIGSEGV, segfaulthand);
    signal(SIGINT, ctrlbreakhand);

    fprintf(stderr, _("\nPerforming initialisation...\n\n"));
    init_all(argv[1]);

    openterm();
    initterm();
    fprintf(stderr, _("\nStarting interface...\n\n"));
    ifloop();

    fprintf(stderr, _("\nPerforming shutdown...\n\n"));
    clearterm();
    flush_all();

    signal(SIGSEGV, NULL);
    signal(SIGINT, NULL);

    fprintf(stderr, _("Exiting, bye!\n"));

    return 0;
}