Commit 48183228 authored by James Willis's avatar James Willis
Browse files

Added a function to version.c to get the name of the host.

parent bf792b0d
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
/* Config parameters. */ /* Config parameters. */
#include "../config.h" #include "../config.h"
/* Needed for gethostname() */
#include <unistd.h>
/* MPI headers. */ /* MPI headers. */
#ifdef WITH_MPI #ifdef WITH_MPI
#include <mpi.h> #include <mpi.h>
...@@ -47,6 +50,25 @@ ...@@ -47,6 +50,25 @@
/* Local headers. */ /* Local headers. */
#include "version_string.h" #include "version_string.h"
/**
* @brief Return the hostname
*
* Will return the name of the host.
*
* @result the hostname.
*/
const char *hostname(void) {
static char buf[256];
static int initialised = 0;
if (!initialised) {
buf[255] = '\0';
if(gethostname(buf,255))
sprintf(buf, "%s", "Unknown host");
initialised = 1;
}
return buf;
}
/** /**
* @brief Return the source code git revision * @brief Return the source code git revision
* *
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
const char* package_description(void); const char* package_description(void);
const char* package_version(void); const char* package_version(void);
const char *hostname(void);
const char* git_revision(void); const char* git_revision(void);
const char* git_branch(void); const char* git_branch(void);
const char* compiler_name(void); const char* compiler_name(void);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment