/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/pruxenv.c,v 1.1 1990/06/20 19:38:41 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/pruxenv.c,v 1.2 1991/08/12 22:15:40 markf Exp $
Copyright (c) 1990 Massachusetts Institute of Technology
#include "prims.h"
#include "ux.h"
+#ifdef HAVE_SOCKETS
+#include "uxsock.h"
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#endif
+
extern char ** environ;
\f
DEFINE_PRIMITIVE ("CURRENT-FILE-TIME", Prim_current_file_time, 0, 0,
}
}
}
+
+#define HOSTNAMESIZE 1024
+
+DEFINE_PRIMITIVE ("FULL-HOSTNAME", Prim_full_hostname, 0, 0,
+ "Returns the full hostname (including domain if available) as a string.")
+{
+ PRIMITIVE_HEADER (0);
+ {
+ char this_host_name[HOSTNAMESIZE];
+#ifdef HAVE_SOCKETS
+ struct hostent *gethostbyname(char *);
+ struct hostent *this_host_entry;
+#endif
+ STD_VOID_SYSTEM_CALL (syscall_gethostname,
+ UX_gethostname (this_host_name, HOSTNAMESIZE));
+
+#ifdef HAVE_SOCKETS
+ this_host_entry = gethostbyname (this_host_name);
+ PRIMITIVE_RETURN (char_pointer_to_string (this_host_entry->h_name));
+#else
+ PRIMITIVE_RETURN (char_pointer_to_string (this_host_name));
+#endif
+ }
+}
+
+DEFINE_PRIMITIVE ("HOSTNAME", Prim_hostname, 0, 0,
+ "Returns the hostname of the machine as a string.")
+{
+ PRIMITIVE_HEADER (0);
+ {
+ char this_host_name[HOSTNAMESIZE];
+
+ STD_VOID_SYSTEM_CALL (syscall_gethostname,
+ UX_gethostname (this_host_name, HOSTNAMESIZE));
+ PRIMITIVE_RETURN (char_pointer_to_string (this_host_name));
+ }
+}
/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.23 1991/06/15 00:40:24 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.24 1991/08/12 22:16:02 markf Exp $
Copyright (c) 1988-91 Massachusetts Institute of Technology
syscall_fstat,
syscall_ftruncate,
syscall_getcwd,
+ syscall_gethostname,
syscall_gettimeofday,
syscall_ioctl_TIOCGPGRP,
syscall_ioctl_TIOCSIGSEND,
#define UX_getegid getegid
#define UX_geteuid geteuid
#define UX_getgrgid getgrgid
+#define UX_gethostname gethostname
#define UX_getlogin getlogin
#define UX_getpid getpid
#define UX_getpwnam getpwnam
extern PTR EXFUN (malloc, (unsigned int size));
extern PTR EXFUN (realloc, (PTR ptr, unsigned int size));
extern CONST char * EXFUN (getenv, (CONST char * name));
+extern int EXFUN (gethostname, (char * name, unsigned int size));
#ifdef HAVE_FCNTL
#define UX_fcntl fcntl