1 /******************************************************************************* 2 * * 3 * motif.c: Determine stability of Motif * 4 * * 5 * Copyright (C) 2003 Nathaniel Gray * 6 * * 7 * This is free software; you can redistribute it and/or modify it under the * 8 * terms of the GNU General Public License as published by the Free Software * 9 * Foundation; either version 2 of the License, or (at your option) any later * 10 * version. In addition, you may distribute versions of this program linked to * 11 * Motif or Open Motif. See README for details. * 12 * * 13 * This software is distributed in the hope that it will be useful, but WITHOUT * 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * 16 * for more details. * 17 * * 18 * You should have received a copy of the GNU General Public License along with * 19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple * 20 * Place, Suite 330, Boston, MA 02111-1307 USA * 21 * * 22 * Nirvana Text Editor * 23 * July 28, 1992 * 24 * * 25 * Written by Nathaniel Gray * 26 * * 27 * Modifications by: * 28 * Scott Tringali * 29 * * 30 *******************************************************************************/ 31 32 /* 33 * About the different #defines that Motif gives us: 34 * All Motifs #define several values. These are the values in 35 * Open Motif 2.1.30, for example: 36 * #define XmVERSION 2 37 * #define XmREVISION 1 38 * #define XmUPDATE_LEVEL 30 39 * #define XmVersion (XmVERSION * 1000 + XmREVISION) 40 * #define XmVERSION_STRING "@(#)Motif Version 2.1.30" 41 * 42 * In addition, LessTif #defines several values as shown here for 43 * version 0.93.0: 44 * #define LESSTIF_VERSION 0 45 * #define LESSTIF_REVISION 93 46 * #define LesstifVersion (LESSTIF_VERSION * 1000 + LESSTIF_REVISION) 47 * #define LesstifVERSION_STRING \
48 * "@(#)GNU/LessTif Version 2.1 Release 0.93.0" 49 * 50 * Also, in LessTif the XmVERSION_STRING is identical to the 51 * LesstifVERSION_STRING. Unfortunately, the only way to find out the 52 * "update level" of a LessTif release is to parse the LesstifVERSION_STRING. 53 */ 54 55 #include"motif.h" 56 #include<Xm/Xm.h> 57 #include<string.h> 58 59 #ifdefLESSTIF_VERSION 60 staticenum MotifStability GetLessTifStability(void);
61 #else 62 staticenum MotifStability GetOpenMotifStability(void);
63 #endif 64 65 /* 66 * These are versions of LessTif that are known to be stable with NEdit in 67 * Motif 2.1 mode. 68 */ 69 staticconstchar *const knownGoodLesstif[] = {
70 "0.92.32",
71 "0.93.0",
72 "0.93.12",
73 "0.93.18",
74 #ifndef __x86_64
75 "0.93.94", /* 64-bit build .93.94 is broken */ 76 #endif 77 NULL 78 };
79 80 /* 81 * These are versions of LessTif that are known NOT to be stable with NEdit in 82 * Motif 2.1 mode. 83 */ 84 constchar *const knownBadLessTif[] = {
85 "0.93.25",
86 "0.93.29",
87 "0.93.34" 88 "0.93.36",
89 "0.93.39",
90 "0.93.40",
91 "0.93.41",
92 "0.93.44",
93 #ifdef __x86_64
94 "0.93.94", /* 64-bit build .93.94 is broken */ 95 #endif 96 "0.93.95b", /* SF bug 1087192 */ 97 "0.94.4", /* Alt-H, ESC => crash */ 98 "0.95.0", /* same as above */ 99 NULL100 };
101 102 103 #ifdefLESSTIF_VERSION104 105 staticenum MotifStability GetLessTifStability(void)
106 {
107 return MotifKnownBad;
108 }
109 110 #else111 112 /* The stability depends on the patch level, so fold it into the113 usual XmVersion for easy comparison. */114 staticconstint XmFullVersion = (XmVersion * 100 + XmUPDATE_LEVEL);
115 116 staticenum MotifStability GetOpenMotifStability(void)
117 {
118 enum MotifStability result = MotifUnknown;
119 120 const Boolean really222 =
121 (strcmp("@(#)Motif Version 2.2.2", XmVERSION_STRING) == 0);
122 123 if (XmFullVersion <= 200200) /* 1.0 - 2.1 are fine */124 {
125 result = MotifKnownGood;
126 }
127 elseif ((XmFullVersion < 200202) || really222) /* 2.2.0 - 2.2.2 are bad */128 {
129 result = MotifKnownBad;
130 }
131 elseif (XmFullVersion >= 200203 && XmFullVersion <= 200308) /* 2.2.3 - 2.3.8 are good */132 {
133 result = MotifKnownGood;
134 }
135 else/* Anything else unknown */136 {
137 result = MotifUnknown;
138 }
139 140 return result;
141 }
142 143 #endif144 145 146 enum MotifStability GetMotifStability(void)
147 {
148 #ifdefLESSTIF_VERSION149 return GetLessTifStability();
150 #else151 return GetOpenMotifStability();
152 #endif153 }
154 155 156 constchar *GetMotifStableVersions(void)
157 {
158 int i;
159 staticchar msg[sizeof knownGoodLesstif * 80];
160 161 for (i = 0; knownGoodLesstif[i] != NULL; i++)
162 {
163 strcat(msg, knownGoodLesstif[i]);
164 strcat(msg, "\n");
165 }
166 167 strcat(msg, "OpenMotif 2.1.30\n");
168 strcat(msg, "OpenMotif 2.2.3\n");
169 strcat(msg, "OpenMotif 2.3\n");
170 strcat(msg, "OpenMotif 2.3.4\n");
171 strcat(msg, "Motif 2.3.8\n");
172 173 return msg;
174 }
175