From 6e3a9d191ccb901823d8b1b5c1b789deabb57abb Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 1 May 2001 21:34:28 +0000 Subject: Pouet --- include/interface.h | 2 ++ lib/interface.c | 43 ++++++++++++++++++++++++++++++++++++++ po/cat-id-tbl.c | 13 +++++++++++- src/Polynom.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 110 insertions(+), 8 deletions(-) diff --git a/include/interface.h b/include/interface.h index e0bad75..cbae0b7 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1,4 +1,6 @@ #ifndef __INTERFACE_H__ #define __INTERFACE_H__ +void ifloop(void); + #endif diff --git a/lib/interface.c b/lib/interface.c index 8a89c8e..fc238b5 100644 --- a/lib/interface.c +++ b/lib/interface.c @@ -2,5 +2,48 @@ #include #include "config.h" #include "interface.h" +#include "terminal.h" #include "exceptions.h" +void supprime(char * ch) { + for (; *ch; ch++) { + *ch = *(ch + 1); + } +} + +void insert(char * ch, char c) { + int i; + + for (i = strlen(ch) - 1; i; i--) { + *(ch + i + 1) = *(ch + i); + } + + *ch = c; +} + +void ifloop(void) { + int cread; + int gotesc = 0; + char buffer[BUFSIZ]; + int position; + + while (1) { + cread = fgetc(input); + printf("%u\n", cread); + + if (gotesc) { + } else { + switch(cread) { + case 27: /* Caractère ESC */ + gotesc = 1; + break; + case 8: /* Caractère <--- */ + if (position) { + } + break; + case 127: /* Caractère Suppr */ + break; + } + } + } +} diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c index 18e2c30..a975815 100644 --- a/po/cat-id-tbl.c +++ b/po/cat-id-tbl.c @@ -52,6 +52,17 @@ const struct _msg_ent _msg_tbl[] = { {"ply_affichage: strcat error, not enough space in buffer", 43}, {"rat_constr: division by zero", 44}, {"division by zero", 45}, + {"Signal received: segfault", 46}, + {"Signal received: break", 47}, + {"\ +\n\ +Performing initialisation...\n\ +\n", 48}, + {"\ +\n\ +Performing shutdown...\n\ +\n", 49}, + {"Exitting, bye!\n", 50}, }; -int _msg_tbl_length = 45; +int _msg_tbl_length = 50; diff --git a/src/Polynom.c b/src/Polynom.c index a7190c7..98b083d 100644 --- a/src/Polynom.c +++ b/src/Polynom.c @@ -5,6 +5,7 @@ */ #include +#include #include "main.h" #include "hash.h" #include "parser.h" @@ -12,27 +13,46 @@ #include "pile.h" #include "exceptions.h" #include "scalaires.h" -#ifdef HAVE_CONFIG_H +#include "interface.h" +#include "terminal.h" #include "config.h" -#else -#define _(x) x -#endif _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) { +} + int main(void) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - Initialise(&variables); - mute = "x"; - display=DEC; /* 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); @@ -52,6 +72,32 @@ int main(void) 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(); + ifloop(); + clearterm(); + + fprintf(stderr, _("\nPerforming shutdown...\n\n")); + flush_all(); + + signal(SIGSEGV, NULL); + signal(SIGINT, NULL); + + fprintf(stderr, _("Exitting, bye!\n")); + + + return 0; -- cgit v1.2.3