about summary refs log tree commit diff
path: root/converter/ppm/ppmtompeg/gethostname.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /converter/ppm/ppmtompeg/gethostname.c
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/ppm/ppmtompeg/gethostname.c')
-rw-r--r--converter/ppm/ppmtompeg/gethostname.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/converter/ppm/ppmtompeg/gethostname.c b/converter/ppm/ppmtompeg/gethostname.c
new file mode 100644
index 00000000..014b42e8
--- /dev/null
+++ b/converter/ppm/ppmtompeg/gethostname.c
@@ -0,0 +1,26 @@
+#define _BSD_SOURCE   /* Make sure strdup() is in string.h */
+
+#include <string.h>
+#include <errno.h>
+#include <sys/utsname.h>
+
+#include "pm.h"
+
+#include "gethostname.h"
+
+const char *
+GetHostName(void) {
+/*----------------------------------------------------------------------------
+   Return the host name of this system.
+-----------------------------------------------------------------------------*/
+    struct utsname utsname;
+    int rc;
+
+    rc = uname(&utsname);
+
+    if (rc < 0)
+        pm_error("Unable to find out host name.  "
+                 "uname() failed with errno %d (%s)", errno, strerror(errno));
+
+    return strdup(utsname.nodename);
+}