]>
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. */
22 static const char *cvsid
=
43 #include "io_stream.h"
45 unsigned int setup_timestamp
= 0;
46 char *setup_version
= 0;
48 extern int yyparse ();
49 /*extern int yydebug;*/
51 static char *error_buf
= 0;
52 static int error_count
= 0;
57 io_stream
*ini_file
= get_url_to_membuf (concat (MIRROR_SITE
, "/setup.ini", 0));
58 dismiss_url_status_dialog ();
62 note (IDS_SETUPINI_MISSING
, MIRROR_SITE
);
63 next_dialog
= IDD_SITE
;
70 ini_init (ini_file
, MIRROR_SITE
);
74 if (yyparse () || error_count
> 0)
75 MessageBox (0, error_buf
, error_count
== 1 ? "Parse Error" : "Parse Errors", 0);
78 /* save known-good setup.ini locally */
79 io_stream
*inistream
= io_stream::open ("file://setup.ini", "wb");
81 ! ini_file
->seek (0, IO_SEEK_SET
))
83 if (io_stream::copy (ini_file
, inistream
))
84 io_stream::remove ("file://setup.ini");
92 io_stream::mkpath_p (PATH_TO_DIR
, "cygfile:///etc/setup");
94 unsigned int old_timestamp
= 0;
96 io_stream::open ("cygfile:///etc/setup/timestamp", "rt");
100 memset (temp
, '\0', 20);
101 if (ots
->read (temp
, 19))
102 sscanf (temp
, "%u", &old_timestamp
);
104 if (old_timestamp
&& setup_timestamp
105 && (old_timestamp
> setup_timestamp
))
107 int yn
= yesno (IDS_OLD_SETUPINI
);
115 io_stream::open ("cygfile:///etc/setup/timestamp", "wt");
119 sprintf (temp
, "%u", setup_timestamp
);
120 nts
->write (temp
, strlen (temp
));
126 msg ("setup_version is %s, our_version is %s", setup_version
? : "(null)",
130 char *ini_version
= canonicalize_version (setup_version
);
131 char *our_version
= canonicalize_version (version
);
132 if (strcmp (our_version
, ini_version
) < 0)
133 note (IDS_OLD_SETUP_VERSION
, version
, setup_version
);
136 next_dialog
= IDD_CHOOSE
;
142 yyerror (char *s
, ...)
146 sprintf (buf
, "setup.ini line %d: ", yylineno
);
149 vsprintf (buf
+ strlen (buf
), s
, args
);
150 OutputDebugString (buf
);
153 strcat (error_buf
, "\n");
154 len
= strlen (error_buf
) + strlen (buf
) + 5;
155 error_buf
= (char *) realloc (error_buf
, len
);
156 strcat (error_buf
, buf
);
160 len
= strlen (buf
) + 5;
161 error_buf
= (char *) malloc (len
);
162 strcpy (error_buf
, buf
);
165 /* TODO: is return 0 correct? */
169 extern "C" int fprintf (FILE * f
, const char *s
, ...);
171 static char stderrbuf
[1000];
174 fprintf (FILE * f
, const char *fmt
, ...)
179 va_start (args
, fmt
);
182 rv
= vsprintf (buf
, fmt
, args
);
183 strcat (stderrbuf
, buf
);
184 if (char *nl
= strchr (stderrbuf
, '\n'))
187 /*OutputDebugString (stderrbuf); */
188 MessageBox (0, buf
, "Cygwin Setup", 0);
195 rv
= vfprintf (f
, fmt
, args
);
This page took 0.042698 seconds and 5 git commands to generate.