51#define msg(x) printf("ERROR: %s\n", x)
73#define NYEARS (1970 - 1900)
74#define TOFFSET ((u_long)60*60*24*(365*NYEARS + (NYEARS/4)))
89 unsigned char p_bytes[2];
93 i =
sscanf(uaddr,
"%lu.%lu.%lu.%lu.%lu.%lu", &
a[0], &
a[1], &
a[2],
99 for (
i = 0;
i < 4;
i++)
100 sin->sin_addr.s_addr |= (
a[
i] & 0x000000FF) << (8 *
i);
102 p_bytes[0] = (
unsigned char)
a[4] & 0x000000FF;
103 p_bytes[1] = (
unsigned char)
a[5] & 0x000000FF;
106 bcopy((
char *)&p_bytes, (
char *)&
sin->sin_port, 2);
123 for (
i = 0;
i <
num;
i++) {
165 ptr[0] = (
char *)&
sin->sin_addr.s_addr;
197 srv->
ep.ep_len = num_ep;
198 srv->
ep.ep_val =
eps;
246 int udp_ep = -1, tcp_ep = -1;
248 char ut[64], ipuaddr[64];
266 if (*uaddr ==
NULL) {
267 if ((srv !=
NULL) && (thost !=
NULL)) {
268 msg(
"both timehost and srv pointer used!");
272 srv =
get_server(netid, thost, &tsrv, teps, 32);
274 msg(
"unable to contruct server data.");
281 epl = srv->
ep.ep_len;
285 (
i < epl) && ((udp_ep == -1) || (tcp_ep == -1));
i++) {
295 useua = ep[tcp_ep].
uaddr;
297 }
else if (udp_ep > -1) {
299 useua = ep[udp_ep].
uaddr;
304 msg(
"no acceptable transport endpoints.");
324 msg(
"unable to translate uaddr to sockaddr.");
339 msg(
"unable to create client handle to rpcbind.");
378 msg(
"cannot convert timeservice uaddr to sockaddr.");
384 msg(
"unable to open fd to network.");
398 if (
sendto(
s, (
const char *)&thetime,
sizeof(thetime), 0,
400 msg(
"udp : sendto failed.");
415 msg(
"recvfrom failed on udp transport.");
431 msg(
"failed to connect to tcp endpoint.");
435 msg(
"alarm caught it, must be unreachable.");
439 res =
recv(
s, (
char *)&thetime,
sizeof(thetime), 0);
440 if (
res !=
sizeof(thetime)) {
442 msg(
"timed out TCP call.");
444 msg(
"wrong size of results returned");
456 thetime =
ntohl(thetime);
499 msg(
"unable to get the server's time.");
bool_t xdr_u_long(XDR *xdrs, u_long *ulp)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
CHAR FAR *WSAAPI inet_ntoa(IN IN_ADDR in)
#define gettimeofday(tv, tz)
static nis_server * get_server(struct sockaddr_in *sin, char *host, nis_server *srv, eps, int maxep)
static void alarm_hndler(int s)
static void free_eps(eps, int num)
static int uaddr_to_sockaddr(char *uaddr, struct sockaddr_in *sin)
int __rpc_get_time_offset(struct timeval *td, nis_server *srv, char *thost, char **uaddr, struct sockaddr_in *netid)
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs)
__BEGIN_DECLS CLIENT * clnttcp_create(struct sockaddr_in *, u_long, u_long, SOCKET *, u_int, u_int)
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
GLuint GLuint GLsizei GLenum type
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define sprintf(buf, format,...)
static const struct update_accum a1
static const struct update_accum a2
static const struct update_accum a3
static const struct update_accum a4
int _rpc_dtablesize(void)
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
struct nis_server::@207 ep
int PASCAL FAR WSAGetLastError(void)
bool_t(* xdrproc_t)(XDR *,...)