sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Name : uname.cpp sl@0: // Part of : LIBC sl@0: // Contains the source for fchdir sl@0: // Version : 1.0 sl@0: // sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #define KValBuf 15 sl@0: sl@0: /* sl@0: The uname function stores NUL -terminated strings of information sl@0: identifying the current system into the structure referenced by buf. sl@0: sl@0: The utsname structure is defined in the sl@0: sl@0: #include header file, and contains the following members: sl@0: sysname Name of the operating system implementation. sl@0: nodename Network name of this machine. sl@0: release Release level of the operating system. sl@0: version Version level of the operating system. sl@0: machine Machine hardware platform. sl@0: sl@0: Upon successful completion, a non-negative value shall be returned. sl@0: Otherwise, -1 shall be returned and errno set to indicate the error. sl@0: sl@0: */ sl@0: extern "C" { sl@0: EXPORT_C int uname(struct utsname *buf) sl@0: { sl@0: sl@0: char name[KMaxFileName], buffer[KValBuf]; sl@0: size_t len = KMaxFileName; sl@0: char* retDest2 = NULL; sl@0: char* retDest4 = NULL; sl@0: sl@0: if(buf) sl@0: { sl@0: //sysname sl@0: char* retDest1 = strcpy(buf->sysname, "Symbian"); sl@0: sl@0: //nodename sl@0: int retGetHostName = gethostname(name, len); sl@0: sl@0: if( !retGetHostName ) sl@0: { sl@0: retDest2 = strncpy (buf->nodename , name, SYS_NMLN); sl@0: buf->nodename[SYS_NMLN-1] = '\0'; sl@0: } sl@0: sl@0: sl@0: //Release sl@0: char* retDest3 = strcpy (buf->release , "\0"); sl@0: sl@0: //Version sl@0: TVersion rett = User::Version(); sl@0: int retNoOfBytes = sprintf(buffer, "%d:%d:%d", rett.iMajor, rett.iMinor, rett.iBuild); sl@0: if(retNoOfBytes) sl@0: { sl@0: retDest4 = strcpy (buf->version , buffer); sl@0: } sl@0: sl@0: sl@0: //Machine sl@0: char* retDest5 = strcpy (buf->machine , "\0"); sl@0: sl@0: sl@0: if((retDest1!=NULL)&&(retDest2!=NULL)&&(retDest3!=NULL)&&(retDest4!=NULL)&&(retDest5!=NULL)) sl@0: { sl@0: return 0; sl@0: } sl@0: else sl@0: { sl@0: errno = EINVAL; sl@0: return -1; sl@0: } sl@0: sl@0: } sl@0: else sl@0: { sl@0: errno = EINVAL; sl@0: return -1; sl@0: } sl@0: } sl@0: } //extern "C"