]>
Commit | Line | Data |
---|---|---|
d6aaa55d MT |
1 | /* SmoothWall install program. |
2 | * | |
3 | * This program is distributed under the terms of the GNU General Public | |
4 | * Licence. See the file COPYING for details. | |
5 | * | |
6 | * (c) Lawrence Manning, 2001 | |
7 | * Stuff for downloading the smoothwall tarball using wget. | |
8 | * | |
d6aaa55d MT |
9 | */ |
10 | ||
11 | #include "install.h" | |
12 | ||
13 | extern FILE *flog; | |
14 | extern char *mylog; | |
15 | ||
16 | extern char **ctr; | |
17 | ||
18 | static int got_url = 0; | |
19 | ||
9607771a | 20 | char url[STRING_SIZE] = "http://";; |
d6aaa55d | 21 | |
9607771a | 22 | static int gettarballurl(char *url, char *message); |
d6aaa55d | 23 | |
9607771a | 24 | int checktarball(char *file, char *message) |
d6aaa55d MT |
25 | { |
26 | int done; | |
27 | int tries = 0; | |
28 | char commandstring[STRING_SIZE]; | |
29 | ||
30 | done = 0; | |
31 | while (!done) | |
32 | { | |
9607771a | 33 | if (!got_url && gettarballurl(url, message) != 1) |
d6aaa55d MT |
34 | return 0; |
35 | ||
36 | /* remove any successive /'s */ | |
37 | while (url[strlen(url)-1] == '/') { url[strlen(url)-1] = '\0'; } | |
38 | ||
c78a77eb | 39 | snprintf(commandstring, STRING_SIZE, "/bin/wget -q --spider -O /dev/null %s/%s", url, file); |
d6aaa55d MT |
40 | if (!(runcommandwithstatus(commandstring, ctr[TR_CHECKING]))) |
41 | { | |
42 | done = 1; | |
43 | got_url = 1; | |
44 | } | |
45 | else | |
46 | { | |
47 | errorbox(ctr[TR_FAILED_TO_FIND]); | |
48 | got_url = 0; | |
49 | if (tries == 3) | |
9607771a | 50 | return 1; /* failure */ |
d6aaa55d MT |
51 | } |
52 | tries++; | |
53 | } | |
54 | ||
9607771a | 55 | return 0; |
d6aaa55d MT |
56 | } |
57 | ||
9607771a | 58 | static int gettarballurl(char *url, char *message) |
d6aaa55d | 59 | { |
9607771a | 60 | char *values[] = { url, NULL }; /* pointers for the values. */ |
d6aaa55d MT |
61 | struct newtWinEntry entries[] = |
62 | { { "", &values[0], 0,}, { NULL, NULL, 0 } }; | |
63 | char title[STRING_SIZE]; | |
d6aaa55d MT |
64 | int rc; |
65 | ||
c78a77eb | 66 | sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN); |
d6aaa55d MT |
67 | rc = newtWinEntries(title, message, |
68 | 60, 5, 5, 50, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL); | |
69 | ||
70 | strncpy(url, values[0], STRING_SIZE); | |
71 | ||
72 | return rc; | |
73 | } |