1 /* $Id: yyy_mac_lib.c,v 1.3 2003/02/13 19:55:59 rjs3 Exp $
2 * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * 3. The name "Carnegie Mellon University" must not be used to
17 * endorse or promote products derived from this software without
18 * prior written permission. For permission or any other legal
19 * details, please contact
20 * Office of Technology Transfer
21 * Carnegie Mellon University
23 * Pittsburgh, PA 15213-3890
24 * (412) 268-4387, fax: (412) 268-7395
25 * tech-transfer@andrew.cmu.edu
27 * 4. Redistributions of any form whatsoever must retain the following
29 * "This product includes software developed by Computing Services
30 * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
32 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
33 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
34 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
35 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
36 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
37 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
38 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40 #include "sasl_mac_krb_locl.h"
42 #include <ToolUtils.h>
47 int krb_get_config_bool(const char *variable)
49 /* return the value of the only config variable we know of */
50 if(strcmp(variable,"reverse_lsb_test")==0)
56 * compare two ip addresses
66 #ifdef STRICT_ADDRESS_EQUIV
82 * from kerberos.c -- return the offset from gmt
84 static long getTimeZoneOffset(void )
86 MachineLocation macLocation;
89 macLocation.u.gmtDelta=0L;
90 ReadLocation(&macLocation);
91 gmtDelta=macLocation.u.gmtDelta & 0x00FFFFFF;
92 if (BitTst((void *)&gmtDelta,23L))
93 gmtDelta |= 0xFF000000;
99 * from kerberos.c -- convert mac time to unix time
101 static void mac_time_to_unix_time (unsigned long *time)
103 *time -= 66L * 365L * 24L * 60L * 60L + 17L * 60L * 60L * 24L + getTimeZoneOffset() * 60L * 60L;
107 * return the current unix time
109 static unsigned long get_unix_time(void)
111 unsigned long result;
112 GetDateTime(&result);
113 mac_time_to_unix_time(&result);
120 void krb_warning(const char *fmt,...)
124 void krb_kdctimeofday (struct timeval *tv)
129 int gettimeofday(struct timeval *tp, void *foo)
131 tp->tv_sec=get_unix_time();
136 void swab(char *src, char *dst,int len)
149 char *inet_ntoa(unsigned long n)
151 #define BYTE0(xxx) ((int)((xxx)&0x0ff))
153 sprintf(buf,"%d.%d.%d.%d",
164 struct sockaddr_in *src,
165 struct sockaddr_in *dst)