aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgoodale <goodale@61ea717e-8e0c-4c3c-b38e-e9c67f54f1f1>2000-11-08 14:48:00 +0000
committergoodale <goodale@61ea717e-8e0c-4c3c-b38e-e9c67f54f1f1>2000-11-08 14:48:00 +0000
commit0f338a570c159935fc3684aa980318b8b859097d (patch)
tree184f87710e0175d6eaa6849c49f20ebe3b4d5dd8 /src
parentdd49a1d7a2be2f622f656cba118a8e91716e81ac (diff)
Adding the GetHostName function. We should probably move this into utils.
Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPDExtra/trunk@18 61ea717e-8e0c-4c3c-b38e-e9c67f54f1f1
Diffstat (limited to 'src')
-rw-r--r--src/HostNames.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/HostNames.c b/src/HostNames.c
index 318b943..c09437d 100644
--- a/src/HostNames.c
+++ b/src/HostNames.c
@@ -19,6 +19,21 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif /* HAVE_SYS_TIME_H */
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif /* HAVE_SYS_SOCKET_H */
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif /* HAVE_NETINET_IN_H */
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif /* HAVE_NETDB_H */
#ifdef CCTK_MPI
#include "mpi.h"
@@ -41,6 +56,7 @@ CCTK_FILEVERSION(CactusConnect_HTTPDExtra_HostNames_c)
/********************************************************************
********************* Local Routine Prototypes *********************
********************************************************************/
+static void GetHostName(char *name, int length);
/********************************************************************
********************* Other Routine Prototypes *********************
@@ -76,7 +92,7 @@ void HTTPDExtra_CollateHostData(void)
int nprocs;
char thisdata[HOSTDATALENGTH+1];
- gethostname(thisdata, HOSTDATALENGTH);
+ GetHostName(thisdata, HOSTDATALENGTH);
thisdata[HOSTDATALENGTH+1] = 0;
@@ -133,6 +149,51 @@ const char *HTTPDExtra_RemoteHostName(int host)
********************* Local Routines *************************
********************************************************************/
+ /*@@
+ @routine GetHostName
+ @date Fri Oct 20 12:12:34 2000
+ @author Tom Goodale
+ @desc
+ Gets the fully qualified name of this host if possible.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+ @var name
+ @vdesc character buffer to store name in
+ @vtype char *
+ @vio out
+ @vcomment
+
+ @endvar
+ @var length
+ @vdesc length of the character buffer
+ @vtype int
+ @vio in
+ @vcomment
+
+ @endvar
+
+@@*/
+static void GetHostName(char *name, int length)
+{
+ gethostname(name, length);
+
+ /* Does the name include the domain. */
+ if(!strchr(name, '.'))
+ {
+#ifdef HAVE_GETHOSTBYNAME
+ struct hostent *thishostent;
+
+ thishostent = gethostbyname(name);
+
+ strncpy(name, thishostent->h_name, length);
+#endif
+ }
+}
+
#ifdef TEST_HOSTNAMES
int main(int argc, char *argv[])