Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of azure_c_shared_utility by
gb_stdio.h
00001 // Copyright (c) Microsoft. All rights reserved. 00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information. 00003 00004 #ifndef GB_STDIO_H 00005 #define GB_STDIO_H 00006 00007 /*this file, if included instead of <stdio.h> has the following functionality: 00008 1) if GB_STDIO_INTERCEPT is defined then 00009 a) some of the stdio.h symbols shall be redefined, for example: fopen => gb_fopen 00010 b) all "code" using the fopen will actually (because of the preprocessor) call to gb_fopen 00011 c) gb_fopen shall blindly call into fopen, thus realizing a passthrough 00012 00013 reason is: unittesting. fopen is comes with the C Run Time and cannot be mocked (that is, in the global namespace cannot exist a function called fopen 00014 00015 2) if GB_STDIO_INTERCEPT is not defined then 00016 a) it shall include <stdio.h> => no passthrough, just direct linking. 00017 */ 00018 00019 #ifndef GB_STDIO_INTERCEPT 00020 #include <stdio.h> 00021 #else 00022 00023 /*source level intercepting of function calls*/ 00024 #define fopen fopen_never_called_never_implemented_always_forgotten 00025 #define fclose fclose_never_called_never_implemented_always_forgotten 00026 #define fseek fseek_never_called_never_implemented_always_forgotten 00027 #define ftell ftell_never_called_never_implemented_always_forgotten 00028 #define fprintf fprintf_never_called_never_implemented_always_forgotten 00029 00030 #include "azure_c_shared_utility/umock_c_prod.h" 00031 00032 00033 #ifdef __cplusplus 00034 #include <cstdio.h> 00035 extern "C" 00036 { 00037 #else 00038 #include <stdio.h> 00039 #endif 00040 00041 #undef fopen 00042 #define fopen gb_fopen 00043 MOCKABLE_FUNCTION(, FILE*, gb_fopen, const char*, filename, const char*, mode); 00044 00045 00046 #undef fclose 00047 #define fclose gb_fclose 00048 MOCKABLE_FUNCTION(, int, fclose, FILE *, stream); 00049 00050 #undef fseek 00051 #define fseek gb_fseek 00052 MOCKABLE_FUNCTION(, int, fseek, FILE *,stream, long int, offset, int, whence); 00053 00054 #undef ftell 00055 #define ftell gb_ftell 00056 MOCKABLE_FUNCTION(, long int, ftell, FILE *, stream); 00057 00058 #undef fprintf 00059 #define fprintf gb_fprintf 00060 extern int fprintf(FILE * stream, const char * format, ...); 00061 00062 00063 #ifdef __cplusplus 00064 } 00065 #endif 00066 00067 #endif /*GB_STDIO_INTERCEPT*/ 00068 00069 #endif /* GB_STDIO_H */
Generated on Tue Jul 12 2022 19:14:38 by
