From b9ec1af13cf2bb366160fd6f45fc72c1648df494 Mon Sep 17 00:00:00 2001
From: Moncef STITI <moncef.stiti@etu.u-pec.fr>
Date: Tue, 3 Dec 2024 19:22:18 +0100
Subject: [PATCH] =?UTF-8?q?Correction=20des=20formats=20de=20lecture=20et?=
 =?UTF-8?q?=20d'=C3=A9criture=20des=20comptes,=20suppression=20de=20la=20t?=
 =?UTF-8?q?emporisation=20al=C3=A9atoire?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Secured/secured_transaction.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Secured/secured_transaction.c b/Secured/secured_transaction.c
index 0ba3338..718e9db 100644
--- a/Secured/secured_transaction.c
+++ b/Secured/secured_transaction.c
@@ -19,7 +19,7 @@ void read_account(int fd, int index, char *name, int *balance) {
     lockf(fd, F_LOCK, ACCOUNT_SIZE);
     lseek(fd, index * ACCOUNT_SIZE, SEEK_SET);
     read(fd, buffer, ACCOUNT_SIZE);
-    sscanf(buffer, "%10s %d", name, balance);
+    sscanf(buffer, "%7s %d", name, balance);
     // Libérer le verrou après lecture
     lockf(fd, F_ULOCK, ACCOUNT_SIZE);
 }
@@ -29,7 +29,7 @@ void write_account(int fd, int index, const char *name, int balance) {
     char buffer[ACCOUNT_SIZE];
 
     // Formater la chaîne avec un nom de 10 caractères et un solde de 5 caractères, espace rempli si nécessaire
-    snprintf(buffer, ACCOUNT_SIZE, "%-10s%5d", name, balance);
+    snprintf(buffer, ACCOUNT_SIZE, "%-7s%7d", name, balance);
 
     // S'assurer que le buffer est exactement de taille ACCOUNT_SIZE
     for (int i = strlen(buffer); i < ACCOUNT_SIZE - 1; i++) {
@@ -89,7 +89,7 @@ void process_transactions(int transactions, int account_count) {
 
     for (int i = 0; i < transactions; i++) {
         perform_transaction(fd, account_count);
-        usleep(rand() % 100000); // Temporisation aléatoire
+        //usleep(rand() % 100000); // Temporisation aléatoire
     }
 
     close(fd);