2 * Copyright (c) 2000, Red Hat, Inc.
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.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
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. */
39 unsigned int setup_timestamp = 0;
40 char *setup_version = 0;
42 extern "C" int yyparse ();
43 /*extern int yydebug;*/
45 static char *error_buf = 0;
46 static int error_count = 0;
51 char *ini_file = get_url_to_string (concat (MIRROR_SITE, "/setup.ini", 0));
52 dismiss_url_status_dialog ();
56 note (IDS_SETUPINI_MISSING, MIRROR_SITE);
57 next_dialog = IDD_SITE;
71 if (yyparse () || error_count > 0)
74 MessageBox (0, error_buf, "Parse Error", 0);
76 MessageBox (0, error_buf, "Parse Errors", 0);
80 /* save known-good setup.ini locally */
81 FILE *inif = fopen ("setup.ini", "wb");
84 fwrite (ini_file, 1, strlen (ini_file), inif);
91 mkdir_p (1, concat (root_dir, XEMACS_SETUP_DIR, 0));
93 unsigned int old_timestamp = 0;
94 FILE *ots = fopen (concat (root_dir, XEMACS_SETUP_DIR, "timestamp", 0), "rt");
97 fscanf (ots, "%u", &old_timestamp);
99 if (old_timestamp && setup_timestamp
100 && (old_timestamp > setup_timestamp))
102 int yn = yesno (IDS_OLD_SETUPINI);
109 FILE *nts = fopen (concat (root_dir, XEMACS_SETUP_DIR, "timestamp", 0), "wt");
112 fprintf (nts, "%u", setup_timestamp);
118 msg ("setup_version is %s, our_version is %s", setup_version? setup_version : "(null)", version);
121 char *ini_version = canonicalize_version (setup_version);
122 char *our_version = canonicalize_version (version);
123 if (strcmp (our_version, ini_version) < 0)
124 note (IDS_OLD_SETUP_VERSION, version, setup_version);
127 next_dialog = IDD_CHOOSE;
130 extern "C" int yylineno;
132 extern "C" int CDECL yyerror (char *s, ...)
136 sprintf (buf, "setup.ini line %d: ", yylineno);
139 vsprintf (buf + strlen (buf), s, args);
140 OutputDebugString (buf);
143 strcat (error_buf, "\n");
144 len = strlen (error_buf) + strlen (buf) + 5;
145 error_buf = (char *) realloc (error_buf, len);
146 strcat (error_buf, buf);
150 len = strlen (buf) + 5;
151 error_buf = (char *) malloc (len);
152 strcpy (error_buf, buf);
158 extern "C" int CDECL fprintf (FILE *f, const char *s, ...);
160 static char stderrbuf[1000];
163 fprintf (FILE *f, const char *fmt, ...)
168 va_start (args, fmt);
171 rv = vsprintf (buf, fmt, args);
172 strcat (stderrbuf, buf);
173 if (char *nl = strchr (stderrbuf, '\n'))
176 /*OutputDebugString (stderrbuf);*/
177 MessageBox (0, buf, "XEmacs Setup", 0);
184 rv = vfprintf (f, fmt, args);