+2002-06-22 Tom Yu <tlyu@mit.edu>
+
+ * c_ustime.c: Remove various things missed in 1-2-2-branch MacOS
+ microseconds timer removal.
+
+2001-06-22 Miro Jurisic <meeroh@mit.edu>
+
+ * c_ustime.c: punted the accurate microseconds timing code because it
+ wasn't so accurate after all.
+ [pullup from 1-2-2-branch]
+
+2002-06-22 Alexandra Ellwood <lxs@mit.edu>
+
+ * init_os_ctx.c: Add CoreServices.h before k5-int.h so we don't get
+ multiple definitions for FSSpec. Also removed an unused variable in
+ Mac OS X code and added casts for Mac OS X code so FSSpecs are cast
+ to profile file types (code deals properly on the other side)
+
+ * timeofday.c: Added casts to remove warnings
+
+ * ccdefname.c, init_os_ctx.c, timeofday.c: Updated Mac OS X
+ headers to new framework layout and updated Mac OS macros
+
+ * read_pwd.c: Removed #defines for Mac OS X (__MACH__) because we
+ now export krb5_read_password on Mac OS X
+
+ [pullups from 1-2-2-branch]
+
2002-06-19 Ken Raeburn <raeburn@mit.edu>
* init_os_ctx.c: Don't include sys/ioctl.h or sys/filio.h.
#include <DriverServices.h> /* Nanosecond timing */
#include <CodeFragments.h> /* Check for presence of UpTime */
#include <Math64.h> /* 64-bit integer math */
+#include <KerberosSupport/Utilities.h> /* Mac time -> UNIX time conversion */
/* Mac Cincludes */
#include <string.h>
static krb5_int32 last_sec = 0, last_usec = 0;
-/* Check for availability of microseconds or better timer */
-Boolean HaveAccurateTime ();
-
-/* Convert nanoseconds to date and time */
-void AbsoluteToSecsNanosecs (
- AbsoluteTime eventTime, /* Value to convert */
- UInt32 *eventSeconds, /* Result goes here */
- UInt32 *residualNanoseconds /* Fractional second */
- );
-
/*
* The Unix epoch is 1/1/70, the Mac epoch is 1/1/04.
*
/* Returns the GMT in seconds (and fake microseconds) using the Unix epoch */
-/*
- * Note that unix timers are guaranteed that consecutive calls to timing functions will
- * always return monotonically increasing values for time; even if called within one microsecond,
- * they must increase from one call to another. We must preserve this property in this code,
- * even though Mac UpTime does not make such guarantees... (actually it does, but it measures in
- * units that can be finer than 1 microsecond, so conversion can cause repeat microsecond values
- */
-
krb5_error_code
krb5_crypto_us_timeofday(seconds, microseconds)
krb5_int32 *seconds, *microseconds;
krb5_int32 sec, usec;
time_t the_time;
- GetDateTime (&the_time);
-
- sec = the_time -
- ((66 * 365 * 24 * 60 * 60) + (17 * 24 * 60 * 60) +
- (getTimeZoneOffset() * 60 * 60));
-
-#if TARGET_CPU_PPC /* Only PPC has accurate time */
- if (HaveAccurateTime ()) { /* Does hardware support accurate time? */
-
- AbsoluteTime absoluteTime;
- UInt32 nanoseconds;
-
- absoluteTime = UpTime ();
- AbsoluteToSecsNanosecs (absoluteTime, &sec, &nanoseconds);
-
- usec = nanoseconds / 1000;
- } else
-#endif /* TARGET_CPU_PPC */
- {
- GetDateTime (&sec);
- usec = 0;
- }
+ GetDateTime (&sec);
+ usec = 0;
/* Fix secs to UNIX epoch */
- sec -= ((66 * 365 * 24 * 60 * 60) + (17 * 24 * 60 * 60) +
- (getTimeZoneOffset() * 60 * 60));
-
+ mac_time_to_unix_time (&sec);
+
/* Make sure that we are _not_ repeating */
if (sec < last_sec) { /* Seconds should be at least equal to last seconds */
return 0;
}
-/* Check if we have microsecond or better timer */
-
-Boolean HaveAccurateTime ()
-{
- static Boolean alreadyChecked = false;
- static haveAccurateTime = false;
-
- if (!alreadyChecked) {
- alreadyChecked = true;
- haveAccurateTime = false;
-#if TARGET_CPU_PPC
- if ((Ptr) UpTime != (Ptr) kUnresolvedCFragSymbolAddress) {
- UInt32 minAbsoluteTimeDelta;
- UInt32 theAbsoluteTimeToNanosecondNumerator;
- UInt32 theAbsoluteTimeToNanosecondDenominator;
- UInt32 theProcessorToAbsoluteTimeNumerator;
- UInt32 theProcessorToAbsoluteTimeDenominator;
-
- GetTimeBaseInfo (
- &minAbsoluteTimeDelta,
- &theAbsoluteTimeToNanosecondNumerator,
- &theAbsoluteTimeToNanosecondDenominator,
- &theProcessorToAbsoluteTimeNumerator,
- &theProcessorToAbsoluteTimeDenominator);
-
- /* minAbsoluteTimeDelta is the period in which Uptime is updated, in absolute time */
- /* We convert it to nanoseconds and compare it with .5 microsecond */
-
- if (minAbsoluteTimeDelta * theAbsoluteTimeToNanosecondNumerator <
- 500 * theAbsoluteTimeToNanosecondDenominator) {
- haveAccurateTime = true;
- }
- }
-#endif /* TARGET_CPU_PPC */
- }
-
- return haveAccurateTime;
-}
-
-/* Convert nanoseconds to date and time */
-
-void AbsoluteToSecsNanosecs (
- AbsoluteTime eventTime, /* Value to convert */
- UInt32 *eventSeconds, /* Result goes here */
- UInt32 *residualNanoseconds /* Fractional second */
- )
-{
- UInt64 eventNanoseconds;
- UInt64 eventSeconds64;
- static const UInt64 kTenE9 = U64SetU (1000000000);
- static UInt64 gNanosecondsAtStart = U64SetU (0);
-
- /*
- * If this is the first call, compute the offset between
- * GetDateTime and UpTime.
- */
- if (U64Compare (gNanosecondsAtStart, U64SetU (0)) == 0) {
- UInt32 secondsAtStart;
- AbsoluteTime absoluteTimeAtStart;
- UInt64 upTimeAtStart;
- UInt64 nanosecondsAtStart;
-
- GetDateTime (&secondsAtStart);
- upTimeAtStart = UnsignedWideToUInt64 (AbsoluteToNanoseconds (UpTime()));
- nanosecondsAtStart = U64SetU (secondsAtStart);
- nanosecondsAtStart = U64Multiply (nanosecondsAtStart, kTenE9);
- gNanosecondsAtStart = U64Subtract (nanosecondsAtStart, upTimeAtStart);
- }
- /*
- * Convert the event time (UpTime value) to nanoseconds and add
- * the local time epoch.
- */
- eventNanoseconds = UnsignedWideToUInt64 (AbsoluteToNanoseconds (eventTime));
- eventNanoseconds = U64Add (gNanosecondsAtStart, eventNanoseconds);
- /*
- * eventSeconds = eventNanoseconds /= 10e9;
- * residualNanoseconds = eventNanoseconds % 10e9;
- * Finally, compute the local time (seconds) and fraction.
- */
- eventSeconds64 = U64Div (eventNanoseconds, kTenE9);
- eventNanoseconds = U64Subtract (eventNanoseconds, U64Multiply (eventSeconds64, kTenE9));
- *eventSeconds = (UInt64ToUnsignedWide (eventSeconds64)).lo;
- *residualNanoseconds = (UInt64ToUnsignedWide (eventNanoseconds)).lo;
-}
#elif defined(_WIN32)
/* Microsoft Windows NT and 95 (32bit) */
*/
#define NEED_WINDOWS
+
+#ifdef TARGET_OS_MAC
+#include <Kerberos/KerberosPreferences.h>
+#endif /* TARGET_OS_MAC */
+
#include "k5-int.h"
#include "os-proto.h"
-#ifdef macintosh
-#include <PreferencesLib.h>
-#endif /* macintosh */
-
#if defined(_WIN32)
static krb5_error_code
free_filespecs(files)
profile_filespec_t *files;
{
-#ifndef macintosh
+#if !TARGET_OS_MAC
char **cp;
if (files == 0)
profile_filespec_t ** pfiles;
krb5_boolean secure;
{
- profile_filespec_t* files;
-#ifdef macintosh
+#ifdef TARGET_OS_MAC
+ FSSpec* files = nil;
FSSpec* preferencesFiles = nil;
UInt32 numPreferencesFiles;
FSSpec* preferencesFilesToInit = nil;
UInt32 numPreferencesFilesToInit;
UInt32 i;
Boolean foundPreferences = false;
- Boolean writtenPreferences = false;
SInt16 refNum = -1;
SInt32 length = 0;
else if (err != noErr)
return ENOENT;
-#else /* !macintosh */
+#else /* !TARGET_OS_MAC */
+ profile_filespec_t* files;
#if defined(_WIN32)
krb5_error_code retval = 0;
char *name = 0;
files[i] = 0;
#endif /* !_WIN32 */
#endif /* !macintosh */
- *pfiles = files;
+ *pfiles = (profile_filespec_t *)files;
return 0;
}
retval = os_get_default_config_files(&files, secure);
if (!retval) {
+#if TARGET_OS_MAC
+ retval = FSp_profile_init_path((const FSSpec *)files,
+ &ctx->profile);
+#else
retval = profile_init((const_profile_filespec_t *) files,
&ctx->profile);
+#endif
+
#ifdef KRB5_DNS_LOOKUP
/* if none of the filenames can be opened use an empty profile */
if (retval == ENOENT) {
retval = os_get_default_config_files(&files, ctx->profile_secure);
- if (!retval)
- retval = profile_init((const_profile_filespec_t *) files, profile);
+ if (!retval) {
+#if TARGET_OS_MAC
+ retval = FSp_profile_init_path((const FSSpec *)files,
+ profile);
+#else
+ retval = profile_init((const_profile_filespec_t *) files,
+ profile);
+#endif
+ }
if (files)
free_filespecs(files);
return retval;
}
-#ifndef macintosh
+#if !TARGET_OS_MAC
krb5_error_code
krb5_set_config_files(ctx, filenames)