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