]>
Commit | Line | Data |
---|---|---|
23c9e63c DD |
1 | /* |
2 | * Copyright (c) 2000, Red Hat, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by DJ Delorie <dj@cygnus.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | /* The purpose of this file is to get and parse the setup.ini file | |
17 | from the mirror site. A few support routines for the bison and | |
18 | flex parsers are provided also. We check to see if this setup.ini | |
19 | is older than the one we used last time, and if so, warn the user. */ | |
20 | ||
21 | #include "win32.h" | |
22 | ||
23 | #include <stdio.h> | |
24 | #include <stdarg.h> | |
25 | ||
26 | #include "ini.h" | |
27 | #include "resource.h" | |
28 | #include "concat.h" | |
29 | #include "state.h" | |
30 | #include "geturl.h" | |
31 | #include "dialog.h" | |
32 | #include "msg.h" | |
33 | #include "mkdir.h" | |
34 | ||
35 | unsigned int setup_timestamp = 0; | |
36 | ||
37 | extern "C" int yyparse (); | |
38 | /* extern int yydebug; */ | |
39 | ||
40 | void | |
41 | do_ini (HINSTANCE h) | |
42 | { | |
43 | char *ini_file = get_url_to_string (concat (MIRROR_SITE, "/setup.ini", 0)); | |
44 | ||
45 | if (!ini_file) | |
46 | fatal (IDS_SETUPINI_MISSING, MIRROR_SITE); | |
47 | ||
48 | ini_init (ini_file); | |
49 | ||
50 | setup_timestamp = 0; | |
51 | /* yydebug = 0;*/ | |
1fd6d0a2 | 52 | yyparse (); |
23c9e63c | 53 | |
04d6e06b | 54 | if (root_dir) |
23c9e63c | 55 | { |
04d6e06b DD |
56 | mkdir_p (1, concat (root_dir, "/etc/setup", 0)); |
57 | ||
58 | unsigned int old_timestamp = 0; | |
59 | FILE *ots = fopen (concat (root_dir, "/etc/setup/timestamp", 0), "rt"); | |
60 | if (ots) | |
23c9e63c | 61 | { |
04d6e06b DD |
62 | fscanf (ots, "%u", &old_timestamp); |
63 | fclose (ots); | |
64 | if (old_timestamp && setup_timestamp | |
65 | && (old_timestamp > setup_timestamp)) | |
66 | { | |
67 | int yn = yesno (IDS_OLD_SETUPINI); | |
68 | if (yn == IDNO) | |
69 | ExitProcess (0); | |
70 | } | |
23c9e63c | 71 | } |
04d6e06b | 72 | if (setup_timestamp) |
23c9e63c | 73 | { |
04d6e06b DD |
74 | FILE *nts = fopen (concat (root_dir, "/etc/setup/timestamp", 0), "wt"); |
75 | if (nts) | |
76 | { | |
77 | fprintf (nts, "%u", setup_timestamp); | |
78 | fclose (nts); | |
79 | } | |
23c9e63c DD |
80 | } |
81 | } | |
82 | ||
83 | next_dialog = IDD_S_CHOOSE; | |
84 | } | |
85 | ||
86 | extern "C" int yyerror (char *s) | |
87 | { | |
88 | MessageBox (0, s, "Parse Error", 0); | |
89 | ExitProcess (0); | |
90 | } | |
91 | ||
1fd6d0a2 | 92 | extern "C" int fprintf (FILE *f, const char *s, ...); |
23c9e63c DD |
93 | |
94 | int | |
1fd6d0a2 | 95 | fprintf (FILE *f, const char *fmt, ...) |
23c9e63c DD |
96 | { |
97 | char buf[1000]; | |
98 | int rv; | |
99 | va_list args; | |
100 | va_start (args, fmt); | |
101 | if (f == stderr) | |
102 | { | |
103 | rv = vsprintf (buf, fmt, args); | |
104 | MessageBox (0, buf, "Cygwin Setup", 0); | |
105 | } | |
106 | else | |
107 | { | |
108 | rv = vfprintf (f, fmt, args); | |
109 | } | |
110 | return rv; | |
111 | } |