/src/FreeRDP/winpr/libwinpr/crt/conversion.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /**  | 
2  |  |  * WinPR: Windows Portable Runtime  | 
3  |  |  * Data Conversion  | 
4  |  |  *  | 
5  |  |  * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>  | 
6  |  |  *  | 
7  |  |  * Licensed under the Apache License, Version 2.0 (the "License");  | 
8  |  |  * you may not use this file except in compliance with the License.  | 
9  |  |  * You may obtain a copy of the License at  | 
10  |  |  *  | 
11  |  |  *     http://www.apache.org/licenses/LICENSE-2.0  | 
12  |  |  *  | 
13  |  |  * Unless required by applicable law or agreed to in writing, software  | 
14  |  |  * distributed under the License is distributed on an "AS IS" BASIS,  | 
15  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
16  |  |  * See the License for the specific language governing permissions and  | 
17  |  |  * limitations under the License.  | 
18  |  |  */  | 
19  |  |  | 
20  |  | #include <winpr/config.h>  | 
21  |  |  | 
22  |  | #include <winpr/crt.h>  | 
23  |  | #include <winpr/string.h>  | 
24  |  |  | 
25  |  | /* Data Conversion: http://msdn.microsoft.com/en-us/library/0heszx3w/ */  | 
26  |  |  | 
27  |  | #ifndef _WIN32  | 
28  |  |  | 
29  |  | errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, int radix)  | 
30  | 0  | { | 
31  | 0  |   int length = 0;  | 
32  |  | 
  | 
33  | 0  |   length = sprintf_s(NULL, 0, "%d", value);  | 
34  |  | 
  | 
35  | 0  |   if (length < 0)  | 
36  | 0  |     return -1;  | 
37  |  |  | 
38  | 0  |   if (sizeInCharacters < (size_t)length)  | 
39  | 0  |     return -1;  | 
40  |  |  | 
41  | 0  |   (void)sprintf_s(buffer, length + 1, "%d", value);  | 
42  |  | 
  | 
43  | 0  |   return 0;  | 
44  | 0  | }  | 
45  |  |  | 
46  |  | #endif  |