]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/install+setup/install/net.c
2aa84d5d1eea6a4a0596659d29a1230a603cc642
[people/teissler/ipfire-2.x.git] / src / install+setup / install / net.c
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 *
9 * $Id: net.c,v 1.8.2.2 2004/04/14 22:05:40 gespinasse Exp $
10 *
11 */
12
13 #include "install.h"
14
15 extern FILE *flog;
16 extern char *mylog;
17
18 extern char **ctr;
19
20 static int got_url = 0;
21
22 char url[STRING_SIZE];
23
24 static int gettarballurl();
25
26 int checktarball(char *file)
27 {
28 int done;
29 int tries = 0;
30 char commandstring[STRING_SIZE];
31
32 done = 0;
33 while (!done)
34 {
35 if (!got_url && gettarballurl() != 1)
36 return 0;
37
38 /* remove any successive /'s */
39 while (url[strlen(url)-1] == '/') { url[strlen(url)-1] = '\0'; }
40
41 snprintf(commandstring, STRING_SIZE, "/bin/wget -s -O /dev/null %s/%s", url, file);
42 if (!(runcommandwithstatus(commandstring, ctr[TR_CHECKING])))
43 {
44 done = 1;
45 got_url = 1;
46 }
47 else
48 {
49 errorbox(ctr[TR_FAILED_TO_FIND]);
50 got_url = 0;
51 if (tries == 3)
52 return 0;
53 }
54 tries++;
55 }
56
57 return 1;
58 }
59
60 static int gettarballurl()
61 {
62 char *values[] = { NULL, NULL }; /* pointers for the values. */
63 struct newtWinEntry entries[] =
64 { { "", &values[0], 0,}, { NULL, NULL, 0 } };
65 char title[STRING_SIZE];
66 char message[1000];
67 int rc;
68
69 sprintf(message, ctr[TR_ENTER_URL]);
70 sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
71 rc = newtWinEntries(title, message,
72 60, 5, 5, 50, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);
73
74 strncpy(url, values[0], STRING_SIZE);
75
76 return rc;
77 }