Browse Source

Amelioration exit_msg

Loquicom 6 years ago
parent
commit
4c5e3eb690
3 changed files with 7 additions and 4 deletions
  1. 5 2
      error.c
  2. 1 1
      error.h
  3. 1 1
      mysh.c

+ 5 - 2
error.c

@@ -77,8 +77,11 @@ void exit_err(){
     error.exit_status(EXIT_FAILURE);
 }
 
-void exit_msg(char* msg, int status){
-    printf("%s", msg);
+void exit_msg(int status, const char* format, ...){
+    va_list arg;
+    va_start(arg, format);
+    vfprintf(stdout, format, arg);
+    va_end(arg);
     error.exit_status(status);
 }
 

+ 1 - 1
error.h

@@ -45,7 +45,7 @@ typedef struct{
     void (*exit)(); //Termine le programme avec EXIT_SUCCESS
     void (*exit_err)(); //Termine le programme avec EXIT_FAILURE
     void (*exit_status)(int); //Termine le programme avec un status utilisateur
-    void (*exit_msg)(char*, int); //Termine le programme avec un status utilisateur et un message dans la sortie standard
+    void (*exit_msg)(int, const char*, ...); //Termine le programme avec un status utilisateur et un message dans la sortie standard
     void (*add)(const char*, ...); //Ajoute un message dans le log
     void (*print)(const char*, ...); //Affiche un message dans la sortie d'erreur
     void (*printadd)(const char*, ...); //Fonction print + add

+ 1 - 1
mysh.c

@@ -50,7 +50,7 @@ int main(int argc, char* argv[]) {
     char str[BUFFER_SIZE];
     int a;
     //Initialisation erreur
-    error_finit("mysh.log");          
+    error_finit("mysh.log");
     //Recup ligne
     //printf("%s\n", fgets(str, 500, stdin));&
     memset(str, 0, 500);