mbed library sources
Dependents: Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more
Superseded
This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.
Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.
If you are looking for a stable and tested release, please import one of the official mbed library releases:
Import librarymbed
The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Diff: common/retarget.cpp
- Revision:
- 431:255afbe6270c
- Parent:
- 285:31249416b6f9
- Child:
- 473:44b5a0bc6da6
--- a/common/retarget.cpp Tue Dec 09 14:30:09 2014 +0000 +++ b/common/retarget.cpp Tue Dec 09 14:45:08 2014 +0000 @@ -480,3 +480,55 @@ return (caddr_t) prev_heap; } #endif + + +namespace mbed { + +void mbed_set_unbuffered_stream(FILE *_file) { +#if defined (__ICCARM__) + char buf[2]; + std::setvbuf(_file,buf,_IONBF,NULL); +#else + setbuf(_file, NULL); +#endif +} + +int mbed_getc(FILE *_file){ +#if defined (__ICCARM__) + /*This is only valid for unbuffered streams*/ + int res = std::fgetc(_file); + if (res>=0){ + _file->_Mode = (unsigned short)(_file->_Mode & ~ 0x1000);/* Unset read mode */ + _file->_Rend = _file->_Wend; + _file->_Next = _file->_Wend; + } + return res; +#else + return std::fgetc(_file); +#endif +} + +char* mbed_gets(char*s, int size, FILE *_file){ +#if defined (__ICCARM__) + /*This is only valid for unbuffered streams*/ + char *str = fgets(s,size,_file); + if (str!=NULL){ + _file->_Mode = (unsigned short)(_file->_Mode & ~ 0x1000);/* Unset read mode */ + _file->_Rend = _file->_Wend; + _file->_Next = _file->_Wend; + } + return str; +#else + return std::fgets(s,size,_file); +#endif +} + +} // namespace mbed + + + + + + + +