/* -*-C-*-
-$Id: ntapi.h,v 1.7 1997/10/26 08:04:41 cph Exp $
+$Id: ntapi.h,v 1.8 1997/11/01 07:17:50 cph Exp $
Copyright (c) 1997 Massachusetts Institute of Technology
apicall_bind,
apicall_closesocket,
apicall_connect,
+ apicall_gethostbyname,
+ apicall_gethostname,
apicall_ioctlsocket,
apicall_listen,
apicall_recv,
"BIND",
"CLOSE-SOCKET",
"CONNECT",
+ "GET-HOST-BY-NAME",
+ "GET-HOST-NAME",
"IOCTL-SOCKET",
"LISTEN",
"RECV",
/* -*-C-*-
-$Id: ntsock.c,v 1.1 1997/10/26 08:03:37 cph Exp $
+$Id: ntsock.c,v 1.2 1997/11/01 07:18:46 cph Exp $
Copyright (c) 1997 Massachusetts Institute of Technology
struct hostent * entry = (gethostbyname (host_name));
return ((entry == 0) ? 0 : (entry -> h_addr_list));
}
+
+const char *
+OS_get_host_name (void)
+{
+ unsigned int name_length = 128;
+ char * name = (OS_malloc (name_length));
+ while (1)
+ {
+ if ((gethostname (name, name_length)) != SOCKET_ERROR)
+ break;
+ {
+ DWORD code = (WSAGetLastError ());
+ if (code != WSAEFAULT)
+ {
+ OS_free (name);
+ NT_error_api_call (code, apicall_gethostname);
+ }
+ }
+ name_length *= 2;
+ name = (OS_realloc (name, name_length));
+ }
+ return (OS_realloc (name, ((strlen (name)) + 1)));
+}
+
+const char *
+OS_canonical_host_name (const char * host_name)
+{
+ struct hostent * entry = (gethostbyname (host_name));
+ if (entry == 0)
+ return (0);
+ {
+ char * result = (OS_malloc ((strlen (entry -> h_name)) + 1));
+ strcpy (result, (entry -> h_name));
+ return (result);
+ }
+}
\f
#ifndef SOCKET_LISTEN_BACKLOG
#define SOCKET_LISTEN_BACKLOG 5
/* -*-C-*-
-$Id: os2api.h,v 1.9 1996/05/10 18:47:42 cph Exp $
+$Id: os2api.h,v 1.10 1997/11/01 07:18:13 cph Exp $
-Copyright (c) 1994-96 Massachusetts Institute of Technology
+Copyright (c) 1994-97 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
syscall_accept,
syscall_bind,
syscall_connect,
+ syscall_gethostbyname,
+ syscall_gethostname,
syscall_listen,
syscall_recv,
syscall_send,
"accept",
"bind",
"connect",
+ "get-host-by-name",
+ "get-host-name",
"listen",
"recv",
"send",
/* -*-C-*-
-$Id: os2sock.c,v 1.3 1996/05/18 06:10:25 cph Exp $
+$Id: os2sock.c,v 1.4 1997/11/01 07:18:06 cph Exp $
-Copyright (c) 1990-96 Massachusetts Institute of Technology
+Copyright (c) 1990-97 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
struct hostent * entry = (gethostbyname ((char *) host_name));
return ((entry == 0) ? 0 : (entry -> h_addr_list));
}
+
+#define HOSTNAMESIZE 1024
+
+const char *
+OS_get_host_name (void)
+{
+ char host_name [HOSTNAMESIZE];
+ VOID_SOCKET_CALL (gethostname, (host_name, HOSTNAMESIZE));
+ {
+ char * result = (OS_malloc ((strlen (host_name)) + 1));
+ strcpy (result, host_name);
+ return (result);
+ }
+}
+
+const char *
+OS_canonical_host_name (const char * host_name)
+{
+ struct hostent * entry = (gethostbyname (this_host_name));
+ if (entry == 0)
+ return (0);
+ {
+ char * result = (OS_malloc ((strlen (entry -> h_name)) + 1));
+ strcpy (result, (entry -> h_name));
+ return (result);
+ }
+}
\f
#ifndef SOCKET_LISTEN_BACKLOG
#define SOCKET_LISTEN_BACKLOG 5
/* -*-C-*-
-$Id: pruxsock.c,v 1.12 1997/11/01 07:10:30 cph Exp $
+$Id: pruxsock.c,v 1.13 1997/11/01 07:19:15 cph Exp $
Copyright (c) 1990-97 Massachusetts Institute of Technology
PRIMITIVE_HEADER (1);
SOCKET_CODE
({
- CONST char * host_name = (OS_full_host_name (STRING_ARG (1)));
+ CONST char * host_name = (OS_canonical_host_name (STRING_ARG (1)));
if (host_name == 0)
PRIMITIVE_RETURN (SHARP_F);
{
/* -*-C-*-
-$Id: uxsock.c,v 1.14 1996/05/18 06:09:25 cph Exp $
+$Id: uxsock.c,v 1.15 1997/11/01 07:19:03 cph Exp $
-Copyright (c) 1990-96 Massachusetts Institute of Technology
+Copyright (c) 1990-97 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
#endif
}
+CONST char *
+DEFUN_VOID (OS_get_host_name)
+{
+ char host_name [HOSTNAMESIZE];
+ STD_VOID_SYSTEM_CALL
+ (syscall_gethostname, (UX_gethostname (host_name, HOSTNAMESIZE)));
+ {
+ char * result = (OS_malloc ((strlen (host_name)) + 1));
+ strcpy (result, host_name);
+ return (result);
+ }
+}
+
+CONST char *
+DEFUN (OS_canonical_host_name, (host_name), CONST char * host_name)
+{
+ struct hostent * entry = (gethostbyname (this_host_name));
+ if (entry == 0)
+ return (0);
+ {
+ char * result = (OS_malloc ((strlen (entry -> h_name)) + 1));
+ strcpy (result, (entry -> h_name));
+ return (result);
+ }
+}
+
Tchannel
DEFUN (OS_open_unix_stream_socket, (filename), CONST char * filename)
{
/* -*-C-*-
-$Id: uxsock.h,v 1.5 1993/06/24 07:10:15 gjr Exp $
+$Id: uxsock.h,v 1.6 1997/11/01 07:19:26 cph Exp $
-Copyright (c) 1990-92 Massachusetts Institute of Technology
+Copyright (c) 1990-97 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(CONST char * service_name, CONST char * protocol_name));
extern unsigned int EXFUN (OS_host_address_length, (void));
extern char ** EXFUN (OS_get_host_by_name, (CONST char * host_name));
+CONST char * EXFUN (OS_get_host_name, (void));
+CONST char * EXFUN (OS_canonical_host_name, (CONST char *));
#ifdef HAVE_UNIX_SOCKETS
extern Tchannel EXFUN (OS_open_unix_stream_socket, (CONST char * filename));