source: trunk/third/cns/src/include/cc-unix.h @ 8789

Revision 8789, 4.2 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8788, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Configuration file for Unix Kerberos hosts.
3 *
4 * Handles definitions specific to Berkeley Sockets on Unix.
5 *
6 * Created by John Gilmore, Cygnus Support.
7 * Copyright 1994 Cygnus Support.
8 *
9 * Permission to use, copy, modify, and
10 * distribute this software and its documentation for any purpose and
11 * without fee is hereby granted, provided that the above copyright
12 * notice appear in all copies and that both that copyright notice and
13 * this permission notice appear in supporting documentation.
14 * Cygnus Support makes no representations about the suitability of
15 * this software for any purpose.  It is provided "as is" without express
16 * or implied warranty.
17 */
18
19/* Define u_char, u_short, u_int, and u_long. */
20#include <sys/types.h>
21
22/* If this source file requires it, define struct sockaddr_in
23   (and possibly other things related to network I/O).  FIXME.  */
24#ifdef DEFINE_SOCKADDR
25#include <netinet/in.h>         /* For struct sockaddr_in and in_addr */
26#include <arpa/inet.h>          /* For inet_ntoa */
27#include <netdb.h>              /* For struct hostent, gethostbyname, etc */
28#include <sys/param.h>          /* For MAXHOSTNAMELEN */
29#include <sys/socket.h>         /* For SOCK_*, AF_*, etc */
30#include <sys/time.h>           /* For struct timeval */
31#ifdef NEED_TIME_H
32#include <time.h>               /* For localtime, etc */
33#endif
34#endif
35
36/*
37 * TIME_GMT_UNIXSEC returns the current time of day, in Greenwich Mean Time,
38 * as its unsigned KRB_INT32 result.  The result is in seconds since
39 * January 1, 1970, as used in Unix.
40 *
41 * TIME_GMT_UNIXSEC_US does the above, and also returns the number of
42 * microseconds that have passed in the current second, through
43 * the argument pointer *us, which points to an unsigned KRB_INT32.
44 */
45 
46/* Unfortunately, KRB_INT32 isn't defined here yet.  Push the declaration
47   into a macro, which krb.h will expand as needed at an appropriate point.  */
48#define DECL_THAT_NEEDS_KRB_INT32       \
49        extern  unsigned KRB_INT32      unix_time_gmt_unixsec \
50                                        PROTOTYPE ((unsigned KRB_INT32 *));
51
52#define TIME_GMT_UNIXSEC        unix_time_gmt_unixsec((unsigned KRB_INT32 *)0)
53#define TIME_GMT_UNIXSEC_US(us) unix_time_gmt_unixsec((us))
54#define CONVERT_TIME_EPOCH      ((long)0)       /* Unix epoch is Krb epoch */
55
56
57
58/*
59 * Return some "pretty" random values in KRB_INT32's.  This is not
60 * very random but is what the old Kerberos did.  Improving the
61 * randomness would help a lot here.  Need to include something
62 * that changes on each server to avoid multiple servers using the
63 * same random keystream.
64 */
65#define RANDOM_KRB_INT32_1      ((KRB_INT32) getpid())
66
67#ifdef  NO_GETHOSTID
68#define RANDOM_KRB_INT32_2      (0)  /* gethostid isn't that random anyway. */
69#else
70#define RANDOM_KRB_INT32_2      ((KRB_INT32) gethostid())
71#endif
72
73/* extern int getpid();  -- this will default, and some systems explicitly
74                                declare pid_t rather than int (sigh).  */
75
76#if 0 /* OSF/1 3.0 provides prototype that conflicts; do any machines
77         actually lose by omitting this?  */
78extern long gethostid();
79#endif
80
81/*
82 * Compatability with WinSock calls on MS-Windows...
83 */
84#define SOCKET          unsigned int
85#define INVALID_SOCKET  ((SOCKET)~0)
86#define closesocket     close
87#define ioctlsocket     ioctl
88#define SOCKET_ERROR    (-1)
89
90/* Some of our own infrastructure where the WinSock stuff was too hairy
91   to dump into a clean Unix program...  */
92
93#define SOCKET_INITIALIZE()     (0)     /* No error (or anything else) */
94#define SOCKET_CLEANUP()        /* nothing */
95#define SOCKET_ERRNO            errno
96#define SOCKET_SET_ERRNO(x)     (errno = (x))
97#define SOCKET_NFDS(f)          ((f)+1) /* select() arg for a single fd */
98#define SOCKET_READ             read
99#define SOCKET_WRITE            write
100#define SOCKET_EINTR            EINTR
101
102/*
103 * Deal with FAR pointers needed in coping with Windows DLL's.
104 * I really hate to add this crap Crap CRAP to a clean program!
105 *
106 * There ain't no such thing on real Unix machines, so this is easy.
107 */
108#define FAR             /* no such thing in real machines */
109#define INTERFACE       /* No special declaration needed */
110#define _fmemcpy        memcpy
111#define _fstrncpy       strncpy
112#define far_fputs       fputs
113
114/*
115 * Defined to use the global error handling scheme of util/et
116 */
117#define GLOBAL_ERROR_HANDLING
118
119/* Grumble. */
120#define GETHOSTNAME(h,l)        gethostname(h,l)
121/*
122 * Some Unixes don't declare errno in <errno.h>...
123 * Move this out to individual c-*.h files if it becomes troublesome.
124 */
125extern int errno;
Note: See TracBrowser for help on using the repository browser.