From dab8d405a6b7089d646e1dc3cb902b28da24e78d Mon Sep 17 00:00:00 2001 From: schodet Date: Sat, 26 Apr 2003 13:34:16 +0000 Subject: Mod: Gestion des erreurs. --- 2003/i/buzz/src/busp/GNUmakefile | 5 ++++- 2003/i/buzz/src/busp/test_busp.cc | 45 +++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/2003/i/buzz/src/busp/GNUmakefile b/2003/i/buzz/src/busp/GNUmakefile index 7406b5a..3fe815e 100644 --- a/2003/i/buzz/src/busp/GNUmakefile +++ b/2003/i/buzz/src/busp/GNUmakefile @@ -3,9 +3,12 @@ CXXFLAGS = -Wall -g CPPFLAGS = -I$(SRCDIR) TARGETS = test_busp -test_busp_SOURCES = busp.cc test_busp.cc +test_busp_SOURCES = busp.cc test_busp.cc $(SRCDIR)/erreur/erreur.a all: $(TARGETS) test_busp: $(test_busp_SOURCES:%.cc=%.o) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +clean: + rm -f $(TARGETS) *.o diff --git a/2003/i/buzz/src/busp/test_busp.cc b/2003/i/buzz/src/busp/test_busp.cc index ef15858..81bc21a 100644 --- a/2003/i/buzz/src/busp/test_busp.cc +++ b/2003/i/buzz/src/busp/test_busp.cc @@ -3,6 +3,7 @@ // Copyright (C) 2003 Nicolas Schodet // #include "busp.h" +#include "erreur/erreur.h" #include #include @@ -10,25 +11,33 @@ int main (int argc, char **argv) { - Busp busp; - int addr, data; - switch (argc) + try { - case 3: - // Ecriture. - addr = strtol (argv[1], 0, 0); - data = strtol (argv[2], 0, 0); - cout << "write " << addr << " " << data << endl; - busp.write (addr, data); - break; - case 2: - // Lecture. - addr = strtol (argv[1], 0, 0); - cout << "read " << addr << " = " << busp.read (addr) << endl; - break; - default: - cerr << argv[0] << ": teste le bus parallèle." << endl - << "\t" << argv[0] << " adresse [donnée]" << endl; + Busp busp; + int addr, data; + switch (argc) + { + case 3: + // Ecriture. + addr = strtol (argv[1], 0, 0); + data = strtol (argv[2], 0, 0); + cout << "write " << addr << " " << data << endl; + busp.write (addr, data); + break; + case 2: + // Lecture. + addr = strtol (argv[1], 0, 0); + cout << "read " << addr << " = " << busp.read (addr) << endl; + break; + default: + cerr << argv[0] << ": teste le bus parallèle." << endl + << "\t" << argv[0] << " adresse [donnée]" << endl; + return 1; + } + } + catch (const std::exception &e) + { + cerr << e.what (); return 1; } return 0; -- cgit v1.2.3