1 /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2008 John E. Davis
2 * This file is part of JED editor library source.
3 *
4 * You may distribute this file under the terms the GNU General Public
5 * License. See the file COPYING for more information.
6 */
7 /* It is too bad that this cannot be done at the preprocessor level.
8 * Unfortunately, C is not completely portable yet. Basically the #error
9 * directive is the problem.
10 */
11 #include "config.h"
12
13 #include <stdio.h>
14 #ifdef HAVE_STDLIB_H
15 # include <stdlib.h>
16 #endif
17 #ifdef VMS
18 # include <ssdef.h>
19 #endif
20 #include <slang.h>
21
22 #include "jdmacros.h"
23
24 #ifdef VMS
25 # define SUCCESS 1
26 # define FAILURE 2
27 #else
28 # define SUCCESS 0
29 # define FAILURE 1
30 #endif
31
make_version(unsigned int v)32 static char *make_version (unsigned int v)
33 {
34 static char v_string[128];
35 unsigned int a, b, c;
36
37 a = v/10000;
38 b = (v - a * 10000) / 100;
39 c = v - (a * 10000) - (b * 100);
40 sprintf (v_string, "%u.%u.%u", a, b, c);
41 return v_string;
42 }
43
44
45
main(int argc,char ** argv)46 int main (int argc, char **argv)
47 {
48 unsigned int min_version, sl_version;
49 unsigned int sug_version;
50 int ret;
51
52 if ((argc < 3) || (argc > 4))
53 {
54 fprintf (stderr, "Usage: %s <PGM> <SLANG-VERSION> <SUGG VERSION>\n", argv[0]);
55 return FAILURE;
56 }
57 #ifndef SLANG_VERSION
58 sl_version = 0;
59 #else
60 sl_version = SLANG_VERSION;
61 #ifdef REAL_UNIX_SYSTEM
62 if (SLang_Version != SLANG_VERSION)
63 {
64 fprintf (stderr, "\n\n******\n");
65 fprintf (stderr, "\
66 slang.h (version=%ld) does not match the slang library version (%ld)\n\
67 Did you install slang as a shared library? Did you run ldconfig?\n\
68 Perhaps you need to set the RPATH variable in the Makefile.\n\
69 You have an installation problem and you will need to check the SLANG\n\
70 variables in the Makefile and properly set them.\n\
71 Also try: make clean; make\n", (long)SLANG_VERSION, (long)SLang_Version);
72 fprintf (stderr, "******\n\n");
73 return FAILURE;
74 }
75 #endif
76 #endif
77
78 sscanf (argv[2], "%u", &min_version);
79 if (argc == 4) sscanf (argv[3], "%u", &sug_version);
80 else sug_version = sl_version;
81
82 ret = SUCCESS;
83 if (sl_version < min_version)
84 {
85 fprintf (stderr, "This version of %s requires slang version %s.\n",
86 argv[1], make_version(min_version));
87
88 ret = FAILURE;
89 }
90
91 if (sl_version < sug_version)
92 {
93 fprintf (stderr, "Your slang version is %s.\n", make_version(sl_version));
94 fprintf (stderr, "To fully utilize this program, you should upgrade the slang library to\n");
95 fprintf (stderr, " version %s\n", make_version(sug_version));
96 fprintf (stderr, "This library is available from <http://jedsoft.org/slang/>.\n");
97 }
98
99 #ifdef SIZEOF_SHORT
100 if (sizeof(short) != SIZEOF_SHORT)
101 {
102 fprintf (stderr, "SIZEOF_SHORT[%lu] is not equal to sizeof(short)[%lu]\n",
103 (unsigned long) SIZEOF_SHORT, (unsigned long) sizeof(short));
104 ret = FAILURE;
105 }
106 #endif
107 #ifdef SIZEOF_INT
108 if (sizeof(int) != SIZEOF_INT)
109 {
110 fprintf (stderr, "SIZEOF_INT[%lu] is not equal to sizeof(int)[%lu]\n",
111 (unsigned long) SIZEOF_INT, (unsigned long) sizeof(int));
112 ret = FAILURE;
113 }
114 #endif
115 #ifdef SIZEOF_LONG
116 if (sizeof(long) != SIZEOF_LONG)
117 {
118 fprintf (stderr, "SIZEOF_LONG[%lu] is not equal to sizeof(long)[%lu]\n",
119 (unsigned long) SIZEOF_LONG, (unsigned long) sizeof(long));
120 ret = FAILURE;
121 }
122 #endif
123 #ifdef SIZEOF_LONG_LONG
124 if (sizeof(long long) != SIZEOF_LONG_LONG)
125 {
126 fprintf (stderr, "SIZEOF_LONG_LONG[%lu] is not equal to sizeof(long long)[%lu]\n",
127 (unsigned long) SIZEOF_LONG_LONG, (unsigned long) sizeof(long long));
128 ret = FAILURE;
129 }
130 #endif
131 #ifdef SIZEOF_FLOAT
132 if (sizeof(float) != SIZEOF_FLOAT)
133 {
134 fprintf (stderr, "SIZEOF_FLOAT[%lu] is not equal to sizeof(float)[%lu]\n",
135 (unsigned long) SIZEOF_FLOAT, (unsigned long) sizeof(float));
136 ret = FAILURE;
137 }
138 #endif
139 #ifdef SIZEOF_DOUBLE
140 if (sizeof(double) != SIZEOF_DOUBLE)
141 {
142 fprintf (stderr, "SIZEOF_DOUBLE[%lu] is not equal to sizeof(double)[%lu]\n",
143 (unsigned long) SIZEOF_DOUBLE, (unsigned long) sizeof(double));
144 ret = FAILURE;
145 }
146 #endif
147
148 return ret;
149 }
150