Chris@0
|
1 /* $Id$
|
Chris@0
|
2
|
Chris@0
|
3 Part of SWI-Prolog
|
Chris@0
|
4
|
Chris@0
|
5 Author: Jan Wielemaker
|
Chris@0
|
6 E-mail: jan@swi.psy.uva.nl
|
Chris@0
|
7 WWW: http://www.swi-prolog.org
|
Chris@0
|
8 Copyright (C): 1985-2004, University of Amsterdam
|
Chris@0
|
9
|
Chris@0
|
10 This program is free software; you can redistribute it and/or
|
Chris@0
|
11 modify it under the terms of the GNU General Public License
|
Chris@0
|
12 as published by the Free Software Foundation; either version 2
|
Chris@0
|
13 of the License, or (at your option) any later version.
|
Chris@0
|
14
|
Chris@0
|
15 This program is distributed in the hope that it will be useful,
|
Chris@0
|
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
18 GNU General Public License for more details.
|
Chris@0
|
19
|
Chris@0
|
20 You should have received a copy of the GNU Lesser General Public
|
Chris@0
|
21 License along with this library; if not, write to the Free Software
|
Chris@0
|
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Chris@0
|
23
|
Chris@0
|
24 As a special exception, if you link this library with other files,
|
Chris@0
|
25 compiled with a Free Software compiler, to produce an executable, this
|
Chris@0
|
26 library does not by itself cause the resulting executable to be covered
|
Chris@0
|
27 by the GNU General Public License. This exception does not however
|
Chris@0
|
28 invalidate any other reasons why the executable file might be covered by
|
Chris@0
|
29 the GNU General Public License.
|
Chris@0
|
30 */
|
Chris@0
|
31
|
Chris@0
|
32 :- module(prolog_version,
|
Chris@0
|
33 [ check_prolog_version/1
|
Chris@0
|
34 ]).
|
Chris@0
|
35
|
Chris@0
|
36 /*******************************
|
Chris@0
|
37 * VERSION *
|
Chris@0
|
38 *******************************/
|
Chris@0
|
39
|
Chris@0
|
40 %% check_prolog_version(+Required)
|
Chris@0
|
41 %
|
Chris@0
|
42 % Validate the program is running under Prolog version Required or
|
Chris@0
|
43 % newer. Required is in numeric notation (e.g. 50317 for 5.3.17)
|
Chris@0
|
44
|
Chris@0
|
45 check_prolog_version(Required) :-
|
Chris@0
|
46 current_prolog_flag(version, MyVersion),
|
Chris@0
|
47 ( MyVersion >= Required
|
Chris@0
|
48 -> true
|
Chris@0
|
49 ; print_message(error,
|
Chris@0
|
50 required_prolog_version(Required)),
|
Chris@0
|
51 format(user_error, '~nPress any key to exit> ', []),
|
Chris@0
|
52 get_single_char(_), nl(user_error),
|
Chris@0
|
53 halt(1)
|
Chris@0
|
54 ).
|
Chris@0
|
55
|
Chris@0
|
56 :- multifile
|
Chris@0
|
57 prolog:message/3.
|
Chris@0
|
58
|
Chris@0
|
59 prolog:message(required_prolog_version(Required)) -->
|
Chris@0
|
60 { current_prolog_flag(version, MyVersion),
|
Chris@0
|
61 user_version(MyVersion, MyV),
|
Chris@0
|
62 user_version(Required, Req)
|
Chris@0
|
63 },
|
Chris@0
|
64 [ 'This program requires SWI-Prolog ~w'-[Req], nl,
|
Chris@0
|
65 'while you are running version ~w.'-[MyV], nl,
|
Chris@0
|
66 'Please visit http://www.swi-prolog.org and', nl,
|
Chris@0
|
67 'upgrade your version of SWI-Prolog.'
|
Chris@0
|
68 ].
|
Chris@0
|
69
|
Chris@0
|
70
|
Chris@0
|
71 user_version(N, Version) :-
|
Chris@0
|
72 Major is N // 10000,
|
Chris@0
|
73 Minor is (N // 100) mod 100,
|
Chris@0
|
74 Patch is N mod 100,
|
Chris@0
|
75 concat_atom([Major, Minor, Patch], '.', Version).
|