Browse Source

:bug: Debug compilation

Loquicom 6 years ago
parent
commit
17cd429b0d
4 changed files with 21 additions and 21 deletions
  1. 7 8
      command.c
  2. 5 0
      command.h
  3. 7 8
      mysh.c
  4. 2 5
      mysh.h

+ 7 - 8
command.c

@@ -9,22 +9,21 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "command.h"
 #include "error.h"
 #include "str.h"
 #include "parser.h"
 #include "execute.h"
 #include "ipc.h"
 #include "variable.h"
-#include "command.h"
-#include "mysh.h"
 
 /* --- Extern --- */
 extern Error error;
 extern pid_t last;
-extern int status_cmd;
-extern int result_cmd;
-extern char base_path[];
-extern pid_list pidlist;
+int status_cmd = -1;
+int result_cmd = -1;
+char base_path[BUFFER_SIZE];
+pid_list pidlist;
 char* cmdlist[] = {
     "cd",
     "exit",
@@ -367,8 +366,8 @@ int myls(int argc, char** argv){
     path[length + 3] = 'l';
     path[length + 4] = 's';
     //Execution
-    //return exec_file(path, argv);
-    return 0;
+    return exec_file(path, argv);
+    //return 0;
 }
 
 int myps(int argc, char** argv){

+ 5 - 0
command.h

@@ -11,6 +11,7 @@
 /* --- Include --- */
 #include <sys/types.h>
 #include "constante.h"
+#include "parser.h"
 
 /* --- Structure --- */
 typedef struct pid_node pid_node;
@@ -29,6 +30,10 @@ typedef struct{
 /* --- Extern --- */
 extern char* cmdlist[];
 extern boolean exitsh;
+extern int status_cmd;
+extern int result_cmd;
+extern char base_path[];
+extern pid_list pidlist;
 
 /* --- Fonctions --- */
 /**

+ 7 - 8
mysh.c

@@ -17,19 +17,18 @@
 #include "error.h"
 #include "str.h"
 #include "parser.h"
-#include "command.h"
-#include "execute.h"
-#include "ipc.h"
 #include "mysh.h"
+#include "ipc.h"
+#include "execute.h"
 
 /* --- Extern --- */
 extern Error error;
 extern boolean exitsh;
 extern pid_t active;
-int status_cmd = -1;
-int result_cmd = -1;
-char base_path[BUFFER_SIZE];
-pid_list pidlist;
+extern int status_cmd;
+extern int result_cmd;
+extern char base_path[];
+extern pid_list pidlist;
 
 /* --- Globale --- */
 int job = 1;
@@ -82,7 +81,7 @@ int main(int argc, char* argv[], char* envp[]) {
     error_init();
     ini_pid_list(&pidlist);
     //Recup chemain de base de l'application
-    if (getcwd(base_path, sizeof (base_path)) == NULL) {
+    if (getcwd(base_path, sizeof (char) * BUFFER_SIZE) == NULL) {
         addperror("Impossible de récuperer le chemin actuel");
         error.print("Erreur pendant l'initialisation\n");
         clean_pid(&pidlist);

+ 2 - 5
mysh.h

@@ -8,11 +8,8 @@
 #ifndef MYSH_H
 #define MYSH_H
 
-/* --- Extern --- */
-extern int status_cmd;
-extern int result_cmd;
-extern char base_path[];
-extern pid_list pidlist;
+/* --- Include --- */
+#include "command.h"
 
 /* --- Fonctions --- */
 /**