define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / compiler / clib / uname.c
bloba78c2c273f1c45aefbb3d15bd1a29d9eb70029cc
1 /*
2 Copyright © 2008, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <string.h>
7 #include <stdio.h>
8 #include <errno.h>
10 #include <exec/types.h>
11 #include <aros/debug.h>
12 #include <utility/tagitem.h>
13 #include <aros/inquire.h>
14 #include <proto/aros.h>
15 #include <proto/dos.h>
17 /*****************************************************************************
19 NAME */
20 #include <sys/utsname.h>
22 int uname(
24 /* SYNOPSIS */
25 struct utsname *name)
27 /* FUNCTION
28 Store information about the operating system in the structure pointed
29 by name.
31 INPUTS
32 name - Pointer to utsname structure defined in <sys/utsname.h>.
34 RESULT
35 If the information was stored successfully, zero is returned. Otherwise
36 function returns -1 and sets errno appropriately.
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
47 This function is using ArosInquire() function to get information about
48 the operating system.
50 ******************************************************************************/
52 IPTR version;
53 IPTR release_minor;
54 IPTR release_major;
55 char *str_builddate;
56 char *architecture;
57 char *cpu;
59 bzero(name, sizeof(struct utsname));
61 ArosInquire(AI_ArosBuildDate, &str_builddate,
62 AI_ArosVersion, &version,
63 AI_ArosReleaseMajor, &release_minor,
64 AI_ArosReleaseMinor, &release_major,
65 AI_ArosArchitecture, &architecture,
66 TAG_DONE);
68 strncpy(name->sysname, "AROS", sizeof(name->sysname) - 1);
69 snprintf(name->release, sizeof(name->release) - 1, "%d.%d", (int) release_major, (int) release_minor);
70 snprintf(name->version, sizeof(name->version) - 1, "%d %s", (int) version, str_builddate);
71 cpu = rindex(architecture, '-') + 1;
72 strncpy(name->machine, (cpu?cpu:architecture), sizeof(name->machine) - 1);
74 /* If TCP is running it will set the ENV:HOSTNAME var with out hostname */
75 if (GetVar("HOSTNAME", name->nodename, sizeof(name->nodename) - 1, GVF_GLOBAL_ONLY) == -1)
77 strncpy(name->nodename, "localhost.localdomain", sizeof(name->nodename) - 1);
79 return 0;