summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index 86f071d..7757f9a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,25 +1,50 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3#include <unistd.h>
4#include <getopt.h>
3#include "gui/gui.h" 5#include "gui/gui.h"
4#include "MLV/MLV_path.h" 6#include "MLV/MLV_path.h"
5 7
6int main(int argc, char **argv) { 8int main(int argc, char **argv) {
7 if (argc < 3) { 9 int opt = 0;
8 fprintf(stderr, "Not enough argument (2 correct pathfiles required)\n"); 10 int help = -1;
9 exit(-1); 11 static struct option long_options[] = {
10 } 12 {"help", 0, 0, 'h'},
11 if (argc > 3) { 13 {0, 0, 0, 0}
12 fprintf(stderr, "Too much arguments (2 correct pathfiles required)\n");
13 exit(-2);
14 }
15 if (!(MLV_path_is_a_file(argv[1])) || !(MLV_path_is_a_file(argv[2]))) {
16 fprintf(stderr, "One path is incorrect\n");
17 exit(-3);
18 }; 14 };
19 GUI *gui = gui_create(argv[1], argv[2]); 15 int long_index = 0;
20 while (mode != EXITING) { 16 /*Option handling*/
21 gui_handle_event(gui); 17 while ((opt = getopt_long_only(argc, argv, "h", long_options, &long_index)) != -1) {
18 switch (opt) {
19 case 'h':
20 help = 0;
21 break;
22 default:
23 exit(EXIT_FAILURE);
24 }
25 }
26 if (help == 0) {
27 printf(
28 "--Morphing's Help--\nTo use the morphing, you need to put two correct paths to image files.\n\nCorrect image format :\nICO(Icon)/CUR(Cursor)/BMP, PNM (PPM/PGM/PBM), XPM, LBM(IFF ILBM), PCX, GIF, JPEG, PNG, TGA, TIFF, and XV.\n\nMorphing made by:\n Pacien TRAN-GIRARD and Adam NAILI\n");
29 } else {
30 int nbArg = argc - optind;
31 if (nbArg < 2) {
32 fprintf(stderr, "Not enough argument (2 correct pathfiles required)\n");
33 exit(-1);
34 }
35 if (nbArg > 2) {
36 fprintf(stderr, "Too much arguments (2 correct pathfiles required)\n");
37 exit(-2);
38 }
39 if (!(MLV_path_is_a_file(argv[optind])) || !(MLV_path_is_a_file(argv[optind + 1]))) {
40 fprintf(stderr, "One path is incorrect\n");
41 exit(-3);
42 };
43 GUI *gui = gui_create(argv[optind], argv[optind + 1]);
44 while (mode != EXITING) {
45 gui_handle_event(gui);
46 }
47 gui_destroy(gui);
22 } 48 }
23 gui_destroy(gui); 49 exit(EXIT_SUCCESS);
24 return 0;
25} 50}