4 * Written by Eryk Vershen
8 * Copyright 1997,1998 by Apple Computer, Inc.
11 * Permission to use, copy, modify, and distribute this software and
12 * its documentation for any purpose and without fee is hereby granted,
13 * provided that the above copyright notice appears in all copies and
14 * that both the copyright notice and this permission notice appear in
15 * supporting documentation.
17 * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE.
21 * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
22 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
24 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
25 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41 #define NumToolboxTraps() ( \
42 (NGetTrapAddress(_InitGraf, ToolTrap) \
43 == NGetTrapAddress(0xAA6E, ToolTrap)) \
46 #define GetTrapType(theTrap) ( \
47 (((theTrap) & 0x800) != 0) ? ToolTrap : OSTrap \
64 static char dynamic_version
[10];
67 * Forward declarations
75 clear_memory(void *dataPtr
, unsigned long size
)
79 ptr
= (char *) dataPtr
;
87 #if !defined(__linux__) && !defined(__unix__)
88 /* (see Inside Mac VI 3-8) */
90 TrapAvailable(short theTrap
)
94 trapType
= GetTrapType(theTrap
);
96 if (trapType
== ToolTrap
) {
98 if (theTrap
>= NumToolboxTraps())
99 theTrap
= _Unimplemented
;
103 NGetTrapAddress(theTrap
, trapType
)
104 != NGetTrapAddress(_Unimplemented
, ToolTrap
)
110 /* Ascii case-insensitive string comparison */
112 istrncmp(const char *x
, const char *y
, long len
)
114 const unsigned char *p
= (const unsigned char *)x
;
115 const unsigned char *q
= (const unsigned char *)y
;
118 if (tolower(*p
) != tolower(*q
)) {
120 } else if (*p
== 0) {
132 get_version_string(void)
135 /* "copy" of stuff from SysTypes.r, since we can't include that*/
136 enum {development
= 0x20, alpha
= 0x40, beta
= 0x60, final
= 0x80, /* or */ release
= 0x80};
138 switch (kVersionStage
) {
139 case development
: stage
= 'd'; break;
140 case alpha
: stage
= 'a'; break;
141 case beta
: stage
= 'b'; break;
142 case final
: stage
= 'f'; break;
143 default: stage
= '?'; break;
146 if (kVersionBugFix
!= 0) {
147 if (kVersionStage
== final
) {
148 snprintf(dynamic_version
, sizeof(dynamic_version
), "%d.%d.%d",
149 kVersionMajor
, kVersionMinor
, kVersionBugFix
);
151 snprintf(dynamic_version
, sizeof(dynamic_version
), "%d.%d.%d%c%d",
152 kVersionMajor
, kVersionMinor
, kVersionBugFix
, stage
, kVersionDelta
);
155 if (kVersionStage
== final
) {
156 snprintf(dynamic_version
, sizeof(dynamic_version
), "%d.%d",
157 kVersionMajor
, kVersionMinor
);
159 snprintf(dynamic_version
, sizeof(dynamic_version
), "%d.%d%c%d",
160 kVersionMajor
, kVersionMinor
, stage
, kVersionDelta
);
163 return dynamic_version
;