]>
cygwin.com Git - cygwin-apps/setup.git/blob - ini.cc
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. */
21 static char *cvsid
= "\n%%% $Id$\n";
41 unsigned int setup_timestamp
= 0;
42 char *setup_version
= 0;
44 extern "C" int yyparse ();
45 /*extern int yydebug;*/
47 static char *error_buf
= 0;
48 static int error_count
= 0;
53 char *ini_file
= get_url_to_string (concat (MIRROR_SITE
, "/setup.ini", 0));
54 dismiss_url_status_dialog ();
58 note (IDS_SETUPINI_MISSING
, MIRROR_SITE
);
59 next_dialog
= IDD_SITE
;
73 if (yyparse () || error_count
> 0)
76 MessageBox (0, error_buf
, "Parse Error", 0);
78 MessageBox (0, error_buf
, "Parse Errors", 0);
82 /* save known-good setup.ini locally */
83 FILE *inif
= fopen ("setup.ini", "wb");
86 fwrite (ini_file
, 1, strlen (ini_file
), inif
);
93 mkdir_p (1, cygpath ("/etc/setup", 0));
95 unsigned int old_timestamp
= 0;
96 FILE *ots
= fopen (cygpath ("/etc/setup/timestamp", 0), "rt");
99 fscanf (ots
, "%u", &old_timestamp
);
101 if (old_timestamp
&& setup_timestamp
102 && (old_timestamp
> setup_timestamp
))
104 int yn
= yesno (IDS_OLD_SETUPINI
);
111 FILE *nts
= fopen (cygpath ("/etc/setup/timestamp", 0), "wt");
114 fprintf (nts
, "%u", setup_timestamp
);
120 msg ("setup_version is %s, our_version is %s", setup_version
?:"(null)", version
);
123 char *ini_version
= canonicalize_version (setup_version
);
124 char *our_version
= canonicalize_version (version
);
125 if (strcmp (our_version
, ini_version
) < 0)
126 note (IDS_OLD_SETUP_VERSION
, version
, setup_version
);
129 next_dialog
= IDD_CHOOSE
;
134 extern "C" int yyerror (char *s
, ...)
138 sprintf (buf
, "setup.ini line %d: ", yylineno
);
141 vsprintf (buf
+ strlen (buf
), s
, args
);
142 OutputDebugString (buf
);
145 strcat (error_buf
, "\n");
146 len
= strlen (error_buf
) + strlen (buf
) + 5;
147 error_buf
= (char *) realloc (error_buf
, len
);
148 strcat (error_buf
, buf
);
152 len
= strlen (buf
) + 5;
153 error_buf
= (char *) malloc (len
);
154 strcpy (error_buf
, buf
);
159 extern "C" int fprintf (FILE *f
, const char *s
, ...);
161 static char stderrbuf
[1000];
164 fprintf (FILE *f
, const char *fmt
, ...)
169 va_start (args
, fmt
);
172 rv
= vsprintf (buf
, fmt
, args
);
173 strcat (stderrbuf
, buf
);
174 if (char *nl
= strchr (stderrbuf
, '\n'))
177 /*OutputDebugString (stderrbuf);*/
178 MessageBox (0, buf
, "Cygwin Setup", 0);
185 rv
= vfprintf (f
, fmt
, args
);
This page took 0.042206 seconds and 5 git commands to generate.