summaryrefslogtreecommitdiff
path: root/src/Polynom.c
blob: dea8eb8b51b2ff9cedd810467e19b1bc3cb28cf8 (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
100
101
102
/*
 *
 * 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;

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

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

void init_all(void) {
	Initialise(&variables);
	mute = "x";
	display=DEC;
}

void flush_all(void) {
}

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

int main(void)
{
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	/* nom de la variable utilisee pour la saisie des polynomes, a recuperer en argv eventuellt 
	   ATTENTION: elle est case sensitive */

/*
	parse_line("P=-4.5+2*x+3*x^2;");
	//parse_line("P(2);");
	//AfficheTableau(variables);
	//printf("%p\n",(polynome)NomVarToVar("P",variables,&valid));
	//printf("-- affichage:%s\n",ply_affichage((polynome)NomVarToVar("P",variables,&valid)));

	parse_line("P(2);");
	pop_pile(1);
	parse_line("Q=6*x^3+4*x^2+x;");
	parse_line("soja=P-Q+2;");
	parse_line("soja;");
	parse_line("soja^3;");
	//parse_line("quake4@%*)+vo;i");
	printf("Resultat: %s\n", affichage_level_1());
	flush_pile();
	parse_line("0x52;");
	parse_line("x+0;");
	affichage_pile();
	AfficheTableau(variables);

*/

    invite();

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

    fprintf(stderr, _("\nPerforming initialisation...\n\n"));
    init_all();

    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;
}