0
|
1 #include <stdio.h> // printf
|
|
2 #include <stdlib.h> // exit
|
|
3 #include <string.h>
|
|
4 #include <unistd.h> // sleep access
|
|
5
|
|
6 /*
|
|
7 char * current(char * name){
|
|
8 char *file;
|
|
9
|
|
10 if (!getenv("CD")) {
|
|
11 printf ("Zmienna srodowiskowa \"CD\" nie istnieje !\n");
|
|
12 exit (1);
|
|
13 }
|
|
14 file=malloc(strlen(getenv("CD")+strlen(name)+1));
|
|
15 strcpy(file, getenv("CD"));
|
|
16 strcat(file, name);
|
|
17
|
|
18 return file;
|
|
19 }
|
|
20 */
|
|
21
|
|
22 char * file_exist(){
|
|
23 char * name = (char *)".\\config.txt";
|
|
24 //char *file = current(name);
|
|
25 char *file = name;
|
|
26
|
|
27 if (access(file, F_OK)==0){
|
|
28 printf("PLIK istnieje %s\n",file);
|
|
29 free(file);
|
|
30 return file;
|
|
31 }
|
|
32 printf("PLIK nie istnieje %s\n",file);
|
|
33 free(file);
|
|
34 return NULL;
|
|
35 }
|
|
36
|
|
37
|
|
38
|
|
39 void load(){
|
|
40
|
|
41 char * file = file_exist();
|
|
42 char bufor1[128];
|
|
43 char bufor2[128];
|
|
44 char bufor3[128];
|
|
45 char run[384];
|
|
46
|
|
47 if (!file) exit(1);
|
|
48
|
|
49 FILE * f = fopen(file, "r");
|
|
50 fscanf(f, "%s %s %s", bufor1,bufor2,bufor3);
|
|
51 fclose(f);
|
|
52 strcpy(run, bufor1);
|
|
53 strcat(run, " ");
|
|
54 strcat(run, bufor2);
|
|
55 strcat(run, " ");
|
|
56 strcat(run, bufor3);
|
|
57 printf("Uruchamiam %s \n",run);
|
|
58 free(file);
|
|
59
|
|
60 system(run);
|
|
61
|
|
62
|
|
63
|
|
64
|
|
65 }
|
|
66
|
|
67 int main (){
|
|
68 load();
|
|
69
|
|
70 return 0;
|
|
71 }
|