+Tue Mar 28 18:35:20 1995 John Gilmore (gnu at toad.com)
+
+ * DNR.c: Add Apple MacTCP source file for domain name resolution.
+ * macsock.c: Add fake socket support routines for MacTCP.
+ * Makefile.in (OBJS, SRCS): Add DNR and macsock.
+ * ccdefname.c: On Mac, default cred cache is "STDIO:krb5cc" for now.
+ FIXME, this needs to find the Preferences folder and use that.
+ FIXME, shouldn't be conditioned on HAVE_MACSOCK_H.
+ * gmt_mktime.c: Use HAVE_SYS_TYPES_H.
+ * krbfileio.c: Remove <sys/types.h>.
+ * localaddr.c, sendto_kdc.c: Convert to more generic socket
+ support. Use closesocket instead of close, SOCKET_ERRNO rather
+ than errno, SOCKET rather than int, etc.
+ * localaddr.c: Use getmyipaddr() from macsock.c, if on Mac.
+ Add FIXME for multiple local addresses.
+ * lock_file.c: Provide a dummy version for MacOS.
+ * read_pwd.c (ECHO_PASSWORD): Add #ifdef's to avoid all the ioctls
+ and other stuff that turn off echoing. This is useful for debugging
+ on MacOS. FIXME: ECHO_PASSWORD needs to be added to configure.in.
+ * ustime.c: Bring in Mac-specific time-and-timezone code. It
+ probably isn't hooked up correctly, yet.
+
Mon Mar 27 14:16:39 1995 John Gilmore (gnu at toad.com)
* full_ipadr.c, gen_rname.c, port2ip.c, read_msg.c, write_msg.c:
--- /dev/null
+/* DNR.c - Domain Name Resolver library for MPW
+
+ (c) Copyright 1988 by Apple Computer. All rights reserved
+
+ Modifications by Jim Matthews, Dartmouth College, 5/91
+
+ FIXME jcm - copied from Authman 1.0.7 release, file not in ftp.seeding.apple.com
+ FIXME jcm - slight improvments over the version in the KClient 1.1b1 release
+ FIXME jcm - All rights reserved Apple Computer
+*/
+
+#include "k5-int.h"
+#ifdef HAVE_MACSOCK_H /* Only build this on the Macintosh */
+
+#include <OSUtils.h>
+#include <Errors.h>
+#include <Files.h>
+#include <Resources.h>
+#include <Memory.h>
+#include <Traps.h>
+#include <GestaltEqu.h>
+#include <Folders.h>
+#include <ToolUtils.h>
+
+#define OPENRESOLVER 1L
+#define CLOSERESOLVER 2L
+#define STRTOADDR 3L
+#define ADDRTOSTR 4L
+#define ENUMCACHE 5L
+#define ADDRTONAME 6L
+#define HINFO 7L
+#define MXINFO 8L
+
+Handle codeHndl = nil;
+
+typedef OSErr (*OSErrProcPtr)(long,...);
+OSErrProcPtr dnr = nil;
+
+
+TrapType GetTrapType(theTrap)
+unsigned long theTrap;
+{
+ if (BitAnd(theTrap, 0x0800) > 0)
+ return(ToolTrap);
+ else
+ return(OSTrap);
+ }
+
+Boolean TrapAvailable(trap)
+unsigned long trap;
+{
+TrapType trapType = ToolTrap;
+unsigned long numToolBoxTraps;
+
+ if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap))
+ numToolBoxTraps = 0x200;
+ else
+ numToolBoxTraps = 0x400;
+
+ trapType = GetTrapType(trap);
+ if (trapType == ToolTrap) {
+ trap = BitAnd(trap, 0x07FF);
+ if (trap >= numToolBoxTraps)
+ trap = _Unimplemented;
+ }
+ return(NGetTrapAddress(trap, trapType) != NGetTrapAddress(_Unimplemented, ToolTrap));
+
+}
+
+void GetSystemFolder(short *vRefNumP, long *dirIDP)
+{
+ SysEnvRec info;
+ long wdProcID;
+
+ SysEnvirons(1, &info);
+ if (GetWDInfo(info.sysVRefNum, vRefNumP, dirIDP, &wdProcID) != noErr) {
+ *vRefNumP = 0;
+ *dirIDP = 0;
+ }
+ }
+
+void GetCPanelFolder(short *vRefNumP, long *dirIDP)
+{
+ Boolean hasFolderMgr = false;
+ long feature;
+
+/*
+ if (TrapAvailable(_GestaltDispatch)) if (Gestalt(gestaltFindFolderAttr, &feature) == noErr) hasFolderMgr = true;
+
+ FIXME jcm - what defines _Gestalt
+ if (TrapAvailable(_Gestalt))
+*/
+ if (Gestalt(gestaltFindFolderAttr, &feature) == noErr) hasFolderMgr = true;
+ if (!hasFolderMgr) {
+ GetSystemFolder(vRefNumP, dirIDP);
+ return;
+ }
+ else {
+ if (FindFolder(kOnSystemDisk, kControlPanelFolderType, kDontCreateFolder, vRefNumP, dirIDP) != noErr) {
+ *vRefNumP = 0;
+ *dirIDP = 0;
+ }
+ }
+ }
+
+/* SearchFolderForDNRP is called to search a folder for files that might
+ contain the 'dnrp' resource */
+short SearchFolderForDNRP(long targetType, long targetCreator, short vRefNum, long dirID)
+{
+ HParamBlockRec fi;
+ Str255 filename;
+ short refnum;
+
+ fi.fileParam.ioCompletion = nil;
+ fi.fileParam.ioNamePtr = filename;
+ fi.fileParam.ioVRefNum = vRefNum;
+ fi.fileParam.ioDirID = dirID;
+ fi.fileParam.ioFDirIndex = 1;
+
+ while (PBHGetFInfo(&fi, false) == noErr) {
+ /* scan system folder for driver resource files of specific type & creator */
+ if (fi.fileParam.ioFlFndrInfo.fdType == targetType &&
+ fi.fileParam.ioFlFndrInfo.fdCreator == targetCreator) {
+ /* found the MacTCP driver file? */
+
+ refnum = HOpenResFile(vRefNum, dirID, filename, fsRdPerm);
+
+ SetResLoad(false);
+ if (GetIndResource('dnrp', 1) == NULL) {
+ SetResLoad(true);
+ CloseResFile(refnum);
+ }
+ else {
+ SetResLoad(true);
+ return refnum;
+ }
+ SetResLoad(true);
+ }
+ /* check next file in system folder */
+ fi.fileParam.ioFDirIndex++;
+ fi.fileParam.ioDirID = dirID; /* PBHGetFInfo() clobbers ioDirID */
+ }
+ return(-1);
+ }
+
+/* OpenOurRF is called to open the MacTCP driver resources */
+
+short OpenOurRF()
+{
+ short refnum;
+ short vRefNum;
+ long dirID;
+
+ /* first search Control Panels for MacTCP 1.1 */
+ GetCPanelFolder(&vRefNum, &dirID);
+ refnum = SearchFolderForDNRP('cdev', 'ztcp', vRefNum, dirID);
+ if (refnum != -1) return(refnum);
+
+ /* next search System Folder for MacTCP 1.0.x */
+ GetSystemFolder(&vRefNum, &dirID);
+ refnum = SearchFolderForDNRP('cdev', 'mtcp', vRefNum, dirID);
+ if (refnum != -1) return(refnum);
+
+ /* finally, search Control Panels for MacTCP 1.0.x */
+ GetCPanelFolder(&vRefNum, &dirID);
+ refnum = SearchFolderForDNRP('cdev', 'mtcp', vRefNum, dirID);
+ if (refnum != -1) return(refnum);
+
+ return -1;
+ }
+
+
+OSErr OpenResolver(fileName)
+char *fileName;
+{
+ short refnum;
+ OSErr rc;
+
+ if (dnr != nil)
+ /* resolver already loaded in */
+ return(noErr);
+
+ /* open the MacTCP driver to get DNR resources. Search for it based on
+ creator & type rather than simply file name */
+ refnum = OpenOurRF();
+
+ /* ignore failures since the resource may have been installed in the
+ System file if running on a Mac 512Ke */
+
+ /* load in the DNR resource package */
+ codeHndl = GetIndResource('dnrp', 1);
+ if (codeHndl == nil) {
+ /* can't open DNR */
+ return(ResError());
+ }
+
+ DetachResource(codeHndl);
+ if (refnum != -1) {
+ CloseWD(refnum);
+ CloseResFile(refnum);
+ }
+
+ /* lock the DNR resource since it cannot be reloated while opened */
+ HLock(codeHndl);
+ dnr = (OSErrProcPtr) *codeHndl;
+
+ /* call open resolver */
+ rc = (*dnr)(OPENRESOLVER, fileName);
+ if (rc != noErr) {
+ /* problem with open resolver, flush it */
+ HUnlock(codeHndl);
+ DisposHandle(codeHndl);
+ dnr = nil;
+ }
+ return(rc);
+ }
+
+
+OSErr CloseResolver()
+{
+ if (dnr == nil)
+ /* resolver not loaded error */
+ return(notOpenErr);
+
+ /* call close resolver */
+ (void) (*dnr)(CLOSERESOLVER);
+
+ /* release the DNR resource package */
+ HUnlock(codeHndl);
+ DisposHandle(codeHndl);
+ dnr = nil;
+ return(noErr);
+ }
+
+OSErr StrToAddr(hostName, rtnStruct, resultproc, userDataPtr)
+char *hostName;
+struct hostInfo *rtnStruct;
+long resultproc;
+char *userDataPtr;
+{
+ if (dnr == nil)
+ /* resolver not loaded error */
+ return(notOpenErr);
+
+ return((*dnr)(STRTOADDR, hostName, rtnStruct, resultproc, userDataPtr));
+ }
+
+OSErr AddrToStr(addr, addrStr)
+unsigned long addr;
+char *addrStr;
+{
+ if (dnr == nil)
+ /* resolver not loaded error */
+ return(notOpenErr);
+
+ (*dnr)(ADDRTOSTR, addr, addrStr);
+ return(noErr);
+ }
+
+OSErr EnumCache(resultproc, userDataPtr)
+long resultproc;
+char *userDataPtr;
+{
+ if (dnr == nil)
+ /* resolver not loaded error */
+ return(notOpenErr);
+
+ return((*dnr)(ENUMCACHE, resultproc, userDataPtr));
+ }
+
+
+OSErr AddrToName(addr, rtnStruct, resultproc, userDataPtr)
+unsigned long addr;
+struct hostInfo *rtnStruct;
+long resultproc;
+char *userDataPtr;
+{
+ if (dnr == nil)
+ /* resolver not loaded error */
+ return(notOpenErr);
+
+ return((*dnr)(ADDRTONAME, addr, rtnStruct, resultproc, userDataPtr));
+ }
+
+
+extern OSErr HInfo(hostName, returnRecPtr, resultProc, userDataPtr)
+char *hostName;
+struct returnRec *returnRecPtr;
+long resultProc;
+char *userDataPtr;
+{
+ if (dnr == nil)
+ /* resolver not loaded error */
+ return(notOpenErr);
+
+ return((*dnr)(HINFO, hostName, returnRecPtr, resultProc, userDataPtr));
+
+ }
+
+extern OSErr MXInfo(hostName, returnRecPtr, resultProc, userDataPtr)
+char *hostName;
+struct returnRec *returnRecPtr;
+long resultProc;
+char *userDataPtr;
+{
+ if (dnr == nil)
+ /* resolver not loaded error */
+ return(notOpenErr);
+
+ return((*dnr)(MXINFO, hostName, returnRecPtr, resultProc, userDataPtr));
+
+ }
+
+#endif /* HAVE_MACSOCK_H */
OBJS= \
an_to_ln.$(OBJEXT) \
def_realm.$(OBJEXT) \
+ DNR.$(OBJEXT) \
ccdefname.$(OBJEXT) \
free_krbhs.$(OBJEXT) \
free_hstrl.$(OBJEXT) \
localaddr.$(OBJEXT) \
locate_kdc.$(OBJEXT) \
lock_file.$(OBJEXT) \
+ macsock.$(OBJEXT) \
net_read.$(OBJEXT) \
net_write.$(OBJEXT) \
osconfig.$(OBJEXT) \
SRCS= \
$(srcdir)/an_to_ln.c \
$(srcdir)/def_realm.c \
+ $(srcdir)/DNR.c \
$(srcdir)/ccdefname.c \
$(srcdir)/free_krbhs.c \
$(srcdir)/free_hstrl.c \
$(srcdir)/localaddr.c \
$(srcdir)/locate_kdc.c \
$(srcdir)/lock_file.c \
+ $(srcdir)/macsock.c \
$(srcdir)/net_read.c \
$(srcdir)/net_write.c \
$(srcdir)/osconfig.c \
#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
+#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#ifdef TIME_WITH_SYS_TIME
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
-#include <sys/types.h>
#ifdef NEED_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
#define NEED_SOCKETS
#include "k5-int.h"
-#ifndef _MSDOS
+#if !defined(HAVE_MACSOCK_H) && !defined(_MSDOS)
/* needed for solaris, harmless elsewhere... */
#define BSD_COMP
code = ioctl (s, SIOCGIFCONF, (char *)&ifc);
if (code < 0) {
int retval = errno;
- close(s);
+ closesocket (s);
return retval;
}
n = ifc.ifc_len / sizeof (struct ifreq);
return 0;
}
-#else /* DOS version */
+#else /* Windows/Mac version */
/* No ioctls in winsock so we just assume there is only one networking
* card per machine, so gethostent is good enough.
if (*addr == NULL)
return ENOMEM;
+#ifdef HAVE_MACSOCK_H
+ hostrec = getmyipaddr();
+#else /* HAVE_MACSOCK_H */
if (gethostname (host, sizeof(host))) {
err = WSAGetLastError();
return err;
}
-
hostrec = gethostbyname (host);
if (hostrec == NULL) {
err = WSAGetLastError();
return err;
}
+#endif /* HAVE_MACSOCK_H */
(*addr)[0] = calloc (1, sizeof(krb5_address));
if ((*addr)[0] == NULL) {
free (*addr);
return ENOMEM;
}
- (*addr)[0]->addrtype = ADDRTYPE_INET;
- (*addr)[0]->length = sizeof(struct in_addr);
+ (*addr)[0]->addrtype = hostrec->h_addrtype;
+ (*addr)[0]->length = hostrec->h_length;
(*addr)[0]->contents = (unsigned char *)malloc((*addr)[0]->length);
if (!(*addr)[0]->contents) {
free((*addr)[0]);
return ENOMEM;
} else {
memcpy ((char *)(*addr)[0]->contents,
- (char *)hostrec->h_addr,
+ (char *)&hostrec->h_addr,
(*addr)[0]->length);
}
+ /* FIXME, deal with the case where gethostent returns multiple addrs */
return(0);
}
* libos: krb5_lock_file routine
*/
-#ifndef _MSDOS
+#include "k5-int.h"
+#include <stdio.h>
+
+#if !defined(_MSDOS) && !defined(HAVE_MACSOCK_H)
+
+/* Unix version... */
+
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include "k5-int.h"
-#include <stdio.h>
#ifdef POSIX_FILE_LOCKS
#include <errno.h>
#define UNLOCK_LOCK LOCK_UN
#endif
-#include <sys/types.h>
-
extern int errno;
/*ARGSUSED*/
#endif
return 0;
}
-#else /* MSDOS */
-
-#include "k5-int.h"
+#else /* MSDOS or Macintosh */
krb5_error_code INTERFACE
krb5_lock_file(context, filep, pathname, mode)
#include <sgtty.h>
#endif
+extern int errno;
+
+#ifdef ECHO_PASSWORD
+#define cleanup(errcode) (void) signal(SIGINT, ointrfunc); return errcode;
+#else
+
/* POSIX_* are auto-magically defined in <krb5/config.h> at source
configuration time. */
#include <sys/ioctl.h>
#endif /* POSIX_TERMIOS */
-extern int errno;
-
#ifdef POSIX_TERMIOS
#define cleanup(errcode) (void) signal(SIGINT, ointrfunc); tcsetattr(fd, TCSANOW, &save_control); return errcode;
#else
#endif /* sun */
#endif /* POSIX_TERMIOS */
+#endif /* ECHO_PASSWORD */
+
static jmp_buf pwd_jump;
register char *ptr;
int scratchchar;
krb5_sigtype (*ointrfunc)();
+#ifndef ECHO_PASSWORD
#ifdef POSIX_TERMIOS
struct termios echo_control, save_control;
int fd;
errno=ENOTTY; /* say innapropriate ioctl for device */
return errno;
}
-#endif /* sun */
+#endif /* notdef */
if (tcgetattr(fd, &echo_control) == -1)
return errno;
errno=ENOTTY; /* say innapropriate ioctl for device */
return errno;
}
-#endif /* sun */
+#endif /* notdef */
/* save terminal state */
if (
return errno;
#endif
+#endif /* ECHO_PASSWORD */
+
if (setjmp(pwd_jump)) {
/* interrupted */
if (readin_string) {
/* reset intrfunc */
(void) signal(SIGINT, ointrfunc);
+#ifndef ECHO_PASSWORD
#ifdef POSIX_TERMIOS
if (tcsetattr(fd, TCSANOW, &save_control) == -1)
return errno;
== -1)
return errno;
#endif
+#endif /* ECHO_PASSWORD */
*size_return = strlen(return_pwd);
return 0;
#define NEED_LOWLEVEL_IO
#include "k5-int.h"
-#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
int naddr;
int sent, nready;
krb5_error_code retval;
- int *socklist;
+ SOCKET *socklist;
fd_set readable;
struct timeval waitlen;
int cc;
if (naddr == 0)
return KRB5_REALM_UNKNOWN;
- socklist = (int *)malloc(naddr * sizeof(int));
+ socklist = (SOCKET *)malloc(naddr * sizeof(SOCKET));
if (socklist == NULL) {
krb5_xfree(addr);
krb5_xfree(socklist);
return ENOMEM;
}
for (i = 0; i < naddr; i++)
- socklist[i] = -1;
+ socklist[i] = INVALID_SOCKET;
if (!(reply->data = malloc(krb5_max_dgram_size))) {
krb5_xfree(addr);
/* send to the host, wait timeout seconds for a response,
then move on. */
/* cache some sockets for each host */
- if (socklist[host] == -1) {
+ if (socklist[host] == INVALID_SOCKET) {
/* XXX 4.2/4.3BSD has PF_xxx = AF_xxx, so the socket
creation here will work properly... */
/*
* within a given protocol family.
*/
socklist[host] = socket(addr[host].sa_family, SOCK_DGRAM, 0);
- if (socklist[host] == -1)
+ if (socklist[host] == INVALID_SOCKET)
continue; /* try other hosts */
/* have a socket to send/recv from */
/* On BSD systems, a connected UDP socket will get connection
sendto, recvfrom. The connect here may return an error if
the destination host is known to be unreachable. */
if (connect(socklist[host],
- &addr[host], sizeof(addr[host])) == -1)
+ &addr[host], sizeof(addr[host])) == SOCKET_ERROR)
continue;
}
if (send(socklist[host],
waitlen.tv_sec = timeout;
FD_ZERO(&readable);
FD_SET(socklist[host], &readable);
- if (nready = select(1 + socklist[host],
+ if (nready = select(SOCKET_NFDS(socklist[host]),
&readable,
0,
0,
&waitlen)) {
- if (nready == -1) {
- if (errno == EINTR)
+ if (nready == SOCKET_ERROR) {
+ if (SOCKET_ERRNO == SOCKET_EINTR)
goto retry;
- retval = errno;
+ retval = SOCKET_ERRNO;
goto out;
}
if ((cc = recv(socklist[host],
- reply->data, reply->length, 0)) == -1)
+ reply->data, reply->length, 0)) == SOCKET_ERROR)
{
/* man page says error could be:
EBADF: won't happen
server (i.e. don't set sent = 1).
*/
- if (errno == EINTR)
+ if (SOCKET_ERRNO == SOCKET_EINTR)
sent = 1;
continue;
}
retval = KRB5_KDC_UNREACH;
out:
for (i = 0; i < naddr; i++)
- if (socklist[i] != -1)
- (void) close(socklist[i]);
+ if (socklist[i] != INVALID_SOCKET)
+ (void) closesocket (socklist[i]);
krb5_xfree(addr);
krb5_xfree(socklist);
if (retval) {
* krb5_mstimeofday for BSD 4.3
*/
+#define NEED_SOCKETS
#include "k5-int.h"
+#ifdef HAVE_MACSOCK_H
+/* We're a Macintosh -- do Mac time things. */
+
+/*
+ * This code is derived from kerberos/src/lib/des/mac_time.c from
+ * the Cygnus Support release of Kerberos V4:
+ *
+ * mac_time.c
+ * (Originally time_stuff.c)
+ * Copyright 1989 by the Massachusetts Institute of Technology.
+ * Macintosh ooperating system interface for Kerberos.
+ */
+
+#include "AddressXlation.h" /* for ip_addr, for #if 0'd net-time stuff */
+
+#include <script.h> /* Defines MachineLocation, used by getTimeZoneOffset */
+#include <ToolUtils.h> /* Defines BitTst(), called by getTimeZoneOffset() */
+#include <OSUtils.h> /* Defines GetDateTime */
+
+/* Mac Cincludes */
+#include <string.h>
+#include <stddef.h>
+
+ /*******************************
+ The Unix epoch is 1/1/70, the Mac epoch is 1/1/04.
+
+ 70 - 4 = 66 year differential
+
+ Thus the offset is:
+
+ (66 yrs) * (365 days/yr) * (24 hours/day) * (60 mins/hour) * (60 secs/min)
+ plus
+ (17 leap days) * (24 hours/day) * (60 mins/hour) * (60 secs/min)
+
+ Don't forget the offset from GMT.
+ *******************************/
+
+/* returns the offset in hours between the mac local time and the GMT */
+
+static
+unsigned krb5_int32
+getTimeZoneOffset()
+{
+ MachineLocation macLocation;
+ long gmtDelta;
+
+ macLocation.gmtFlags.gmtDelta=0L;
+ ReadLocation(&macLocation);
+ gmtDelta=macLocation.gmtFlags.gmtDelta & 0x00FFFFFF;
+ if (BitTst((void *)&gmtDelta,23L)) gmtDelta |= 0xFF000000;
+ gmtDelta /= 3600L;
+ return(gmtDelta);
+}
+
+static krb5_int32 last_sec = 0, last_usec = 0;
+
+/* Returns the GMT in seconds (and fake microseconds) using the Unix epoch */
+
+krb5_error_code INTERFACE
+krb5_us_timeofday(context, seconds, microseconds)
+ krb5_context context;
+ 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));
+ usec = 0; /* Mac is too slow to count faster than once a second */
+
+ if ((sec == last_sec) && (usec == last_usec)) {
+ if (++last_usec >= 1000000) {
+ last_usec = 0;
+ last_sec++;
+ }
+ sec = last_sec;
+ usec = last_usec;
+ } else
+ last_sec = sec;
+ last_usec = usec;
+
+ *seconds = sec;
+ *microseconds = usec;
+ return 0;
+}
+
+#if 0
+
+int
+gettimeofdaynet (struct timeval *tp, struct timezone *tz)
+{
+ tp->tv_sec = gettimeofdaynet_no_offset();
+ return 0;
+}
+
+
+#define TIME_PORT 37
+#define TM_OFFSET 2208988800
+
+/*
+ *
+ * get_net_offset () -- Use UDP time protocol to figure out the
+ * offset between what the Mac thinks the time is an what
+ * the network thinks.
+ *
+ */
+int
+get_net_offset()
+{
+ time_t tv;
+ char buf[512],ts[256];
+ long *nettime;
+ int attempts, cc, time_port;
+ long unixtime;
+ char realm[REALM_SZ];
+ ip_addr fromaddr;
+ unsigned short fromport;
+ int result;
+
+ nettime = (long *)buf;
+ time_port = TIME_PORT;
+
+ cc = sizeof(buf);
+ result = hosts_send_recv(ts, 1, buf, &cc, "", time_port);
+ time (&tv);
+
+ if (result!=KSUCCESS || cc<4) {
+ net_offset = 0;
+ if (!result) result = 100;
+ return result;
+ }
+
+ unixtime = (long) ntohl(*nettime) - TM_OFFSET;
+
+ tv -= 66 * 365 * 24 * 60 * 60
+ + 17 * 60 * 60 * 24; /* Convert to unix time w/o offset */
+ net_offset = unixtime - tv;
+ net_got_offset = 1;
+
+ return 0;
+}
+
+#endif /* 0 */
+
+#else /* HAVE_MACSOCK_H */
#ifndef _MSDOS
+/* We're a Unix machine -- do Unix time things. */
extern int errno;
return epoch;
}
-#endif
+#endif /* MSDOS */
+#endif /* HAVE_MACSOCK_H */