os/ossrv/genericopenlibs/openenvcore/libc/src/getws.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  Contains the source for getws and putws
    15  *
    16 */
    17 
    18 
    19 #include<e32const.h>
    20 #include <wchar.h>
    21 #include <stdlib.h>
    22 #include <stdio.h>
    23 #include <errno.h>
    24 
    25 extern "C"
    26 {
    27 	
    28 EXPORT_C wchar_t* getws(wchar_t* str)
    29 	{
    30 	size_t size;
    31 	wchar_t* res = NULL;
    32 	
    33 	if(!str)
    34 		{
    35 		errno = EFAULT;
    36 		return NULL;
    37 		}
    38 	res = fgetws(str, BUFSIZ, stdin);
    39 	if(res)
    40 	{
    41 	size = wcslen (str);
    42 	if( (str[size-1] == L'\n') && (res[size-1] == L'\n') )
    43 		{
    44 		str[size-1] = L'\0';
    45 		res[size-1] = L'\0';
    46 		}
    47 	}
    48 	return res;
    49 	}
    50 
    51 EXPORT_C int putws(wchar_t* str)
    52 	{
    53 	if(!str)
    54 		{
    55 		errno = EFAULT;
    56 		return -1;
    57 		}
    58 	return (fputws(str, stdout));
    59 	}
    60  
    61 }//extern "C"
    62 
    63