sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Name : uname.cpp
|
sl@0
|
15 |
// Part of : LIBC
|
sl@0
|
16 |
// Contains the source for fchdir
|
sl@0
|
17 |
// Version : 1.0
|
sl@0
|
18 |
//
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <stdlib.h>
|
sl@0
|
23 |
#include <stdio.h>
|
sl@0
|
24 |
#include <unistd.h>
|
sl@0
|
25 |
#include <sys/utsname.h>
|
sl@0
|
26 |
#include <e32std.h>
|
sl@0
|
27 |
#include <e32cmn.h>
|
sl@0
|
28 |
#include <string.h>
|
sl@0
|
29 |
#include <errno.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
#define KValBuf 15
|
sl@0
|
32 |
|
sl@0
|
33 |
/*
|
sl@0
|
34 |
The uname function stores NUL -terminated strings of information
|
sl@0
|
35 |
identifying the current system into the structure referenced by buf.
|
sl@0
|
36 |
|
sl@0
|
37 |
The utsname structure is defined in the
|
sl@0
|
38 |
|
sl@0
|
39 |
#include <sys/utsname.h> header file, and contains the following members:
|
sl@0
|
40 |
sysname Name of the operating system implementation.
|
sl@0
|
41 |
nodename Network name of this machine.
|
sl@0
|
42 |
release Release level of the operating system.
|
sl@0
|
43 |
version Version level of the operating system.
|
sl@0
|
44 |
machine Machine hardware platform.
|
sl@0
|
45 |
|
sl@0
|
46 |
Upon successful completion, a non-negative value shall be returned.
|
sl@0
|
47 |
Otherwise, -1 shall be returned and errno set to indicate the error.
|
sl@0
|
48 |
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
extern "C" {
|
sl@0
|
51 |
EXPORT_C int uname(struct utsname *buf)
|
sl@0
|
52 |
{
|
sl@0
|
53 |
|
sl@0
|
54 |
char name[KMaxFileName], buffer[KValBuf];
|
sl@0
|
55 |
size_t len = KMaxFileName;
|
sl@0
|
56 |
char* retDest2 = NULL;
|
sl@0
|
57 |
char* retDest4 = NULL;
|
sl@0
|
58 |
|
sl@0
|
59 |
if(buf)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
//sysname
|
sl@0
|
62 |
char* retDest1 = strcpy(buf->sysname, "Symbian");
|
sl@0
|
63 |
|
sl@0
|
64 |
//nodename
|
sl@0
|
65 |
int retGetHostName = gethostname(name, len);
|
sl@0
|
66 |
|
sl@0
|
67 |
if( !retGetHostName )
|
sl@0
|
68 |
{
|
sl@0
|
69 |
retDest2 = strncpy (buf->nodename , name, SYS_NMLN);
|
sl@0
|
70 |
buf->nodename[SYS_NMLN-1] = '\0';
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
//Release
|
sl@0
|
75 |
char* retDest3 = strcpy (buf->release , "\0");
|
sl@0
|
76 |
|
sl@0
|
77 |
//Version
|
sl@0
|
78 |
TVersion rett = User::Version();
|
sl@0
|
79 |
int retNoOfBytes = sprintf(buffer, "%d:%d:%d", rett.iMajor, rett.iMinor, rett.iBuild);
|
sl@0
|
80 |
if(retNoOfBytes)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
retDest4 = strcpy (buf->version , buffer);
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
|
sl@0
|
86 |
//Machine
|
sl@0
|
87 |
char* retDest5 = strcpy (buf->machine , "\0");
|
sl@0
|
88 |
|
sl@0
|
89 |
|
sl@0
|
90 |
if((retDest1!=NULL)&&(retDest2!=NULL)&&(retDest3!=NULL)&&(retDest4!=NULL)&&(retDest5!=NULL))
|
sl@0
|
91 |
{
|
sl@0
|
92 |
return 0;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
else
|
sl@0
|
95 |
{
|
sl@0
|
96 |
errno = EINVAL;
|
sl@0
|
97 |
return -1;
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
}
|
sl@0
|
101 |
else
|
sl@0
|
102 |
{
|
sl@0
|
103 |
errno = EINVAL;
|
sl@0
|
104 |
return -1;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
}
|
sl@0
|
107 |
} //extern "C"
|