]>
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;*/ | |
52 | yyparse(); | |
53 | ||
54 | mkdir_p (1, concat (root_dir, "/etc/setup", 0)); | |
55 | ||
56 | unsigned int old_timestamp = 0; | |
57 | FILE *ots = fopen (concat (root_dir, "/etc/setup/timestamp", 0), "rt"); | |
58 | if (ots) | |
59 | { | |
60 | fscanf (ots, "%u", &old_timestamp); | |
61 | fclose (ots); | |
62 | if (old_timestamp && setup_timestamp | |
63 | && (old_timestamp > setup_timestamp)) | |
64 | { | |
65 | int yn = yesno (IDS_OLD_SETUPINI); | |
66 | if (yn == IDNO) | |
67 | ExitProcess (0); | |
68 | } | |
69 | } | |
70 | if (setup_timestamp) | |
71 | { | |
72 | FILE *nts = fopen (concat (root_dir, "/etc/setup/timestamp", 0), "wt"); | |
73 | if (nts) | |
74 | { | |
75 | fprintf (nts, "%u", setup_timestamp); | |
76 | fclose (nts); | |
77 | } | |
78 | } | |
79 | ||
80 | next_dialog = IDD_S_CHOOSE; | |
81 | } | |
82 | ||
83 | extern "C" int yyerror (char *s) | |
84 | { | |
85 | MessageBox (0, s, "Parse Error", 0); | |
86 | ExitProcess (0); | |
87 | } | |
88 | ||
89 | extern "C" int fprintf(FILE *f, const char *s, ...); | |
90 | ||
91 | int | |
92 | fprintf(FILE *f, const char *fmt, ...) | |
93 | { | |
94 | char buf[1000]; | |
95 | int rv; | |
96 | va_list args; | |
97 | va_start (args, fmt); | |
98 | if (f == stderr) | |
99 | { | |
100 | rv = vsprintf (buf, fmt, args); | |
101 | MessageBox (0, buf, "Cygwin Setup", 0); | |
102 | } | |
103 | else | |
104 | { | |
105 | rv = vfprintf (f, fmt, args); | |
106 | } | |
107 | return rv; | |
108 | } |