Explorar o código

:tada: Creation fichier erreur

Loquicom %!s(int64=6) %!d(string=hai) anos
pai
achega
6389d0d599
Modificáronse 6 ficheiros con 49 adicións e 3 borrados
  1. 17 0
      error.c
  2. 19 0
      error.h
  3. 5 3
      makefile
  4. 6 0
      mysh.c
  5. 1 0
      parser.c
  6. 1 0
      wildcard.c

+ 17 - 0
error.c

@@ -0,0 +1,17 @@
+/* 
+ * File:   error.c
+ * Author: Arthur Brandao
+ *
+ * Created on 8 novembre 2018
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "error.h"
+
+/* --- Extern --- */
+int serrorno = 0;
+char* serrorlib[] = {
+    "Reussite",
+    "Error loul"
+};

+ 19 - 0
error.h

@@ -0,0 +1,19 @@
+/* 
+ * File:   error.h
+ * Author: Arthur Brandao
+ *
+ * Created on 8 novembre 2018
+ */
+
+#ifndef ERROR_H
+#define ERROR_H
+
+/* --- Macro --- */
+#define serror(str) fprintf(stderr, str" : %s\n", serrorlib[serrorno])
+
+/* --- Extern --- */
+extern int serrorno;
+extern char* serrorlib[];
+
+#endif /* ERROR_H */
+

+ 5 - 3
makefile

@@ -3,7 +3,7 @@
 #
 
 EXEC = mysh
-OBJETS = str.o parser.o wildcard.o
+OBJETS = error.o str.o parser.o wildcard.o
 NOM_PROJET = mini-shell
 
 #
@@ -88,6 +88,8 @@ archive: clean
 	@echo "Termine."
 
 # DEPENDANCES
+error.o: error.c error.h
 str.o: str.c str.h
-parser.o: parser.c parser.h constante.h str.h
-mysh.o: mysh.c parser.h constante.h str.h mysh.h
+parser.o: parser.c error.h wildcard.h constante.h parser.h str.h
+wildcard.o: wildcard.c error.h wildcard.h constante.h
+mysh.o: mysh.c error.h parser.h constante.h str.h mysh.h

+ 6 - 0
mysh.c

@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "error.h"
 #include "parser.h"
 #include "mysh.h"
 
@@ -38,6 +39,11 @@ void show_current_dir(const char* before, const char* after) {
 /* --- Main --- */
 int main(int argc, char* argv[]) {
     
+    int serrorno = 1;
+    serror("Non");
+    
+    exit(0);
+    
     CommandTab ct;
     char str[500];
     int a;

+ 1 - 0
parser.c

@@ -12,6 +12,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include "error.h"
 #include "wildcard.h"
 #include "parser.h"
 

+ 1 - 0
wildcard.c

@@ -15,6 +15,7 @@
 #include <unistd.h>
 #include <fnmatch.h>
 #include <string.h>
+#include "error.h"
 #include "wildcard.h"
 
 int wildcard_result(const char* seq) {