Paul Bakker | 747a83a | 2014-02-01 22:50:07 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Platform abstraction layer |
| 3 | * |
| 4 | * Copyright (C) 2006-2014, Brainspark B.V. |
| 5 | * |
| 6 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 7 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 8 | * |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along |
| 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 | */ |
| 25 | |
| 26 | #include "polarssl/config.h" |
| 27 | |
| 28 | #if defined(POLARSSL_PLATFORM_C) |
| 29 | |
| 30 | #include "polarssl/platform.h" |
| 31 | |
| 32 | #if defined(POLARSSL_PLATFORM_PRINTF_ALT) |
| 33 | #if !defined(POLARSSL_PLATFORM_STD_PRINTF) |
| 34 | /* |
| 35 | * Make dummy function to prevent NULL pointer dereferences |
| 36 | */ |
| 37 | static int platform_printf_uninit( const char *format, ... ) |
| 38 | { |
| 39 | ((void) format); |
| 40 | return( 0 ); |
| 41 | } |
| 42 | |
| 43 | #define POLARSSL_PLATFORM_STD_PRINTF platform_printf_uninit |
| 44 | #endif /* !POLARSSL_PLATFORM_STD_PRINTF */ |
| 45 | |
| 46 | int (*polarssl_printf)( const char *, ... ) = POLARSSL_PLATFORM_STD_PRINTF; |
| 47 | |
| 48 | int platform_set_printf( int (*printf_func)( const char *, ... ) ) |
| 49 | { |
| 50 | polarssl_printf = printf_func; |
| 51 | return( 0 ); |
| 52 | } |
| 53 | #endif /* POLARSSL_PLATFORM_PRINTF_ALT */ |
| 54 | |
| 55 | #if defined(POLARSSL_PLATFORM_FPRINTF_ALT) |
| 56 | #if !defined(POLARSSL_PLATFORM_STD_FPRINTF) |
| 57 | /* |
| 58 | * Make dummy function to prevent NULL pointer dereferences |
| 59 | */ |
| 60 | static int platform_fprintf_uninit( FILE *stream, const char *format, ... ) |
| 61 | { |
| 62 | ((void) stream); |
| 63 | ((void) format); |
| 64 | return( 0 ); |
| 65 | } |
| 66 | |
| 67 | #define POLARSSL_PLATFORM_STD_fPRINTF platform_fprintf_uninit |
| 68 | #endif /* !POLARSSL_PLATFORM_STD_FPRINTF */ |
| 69 | |
| 70 | int (*polarssl_fprintf)( FILE *, const char *, ... ) = |
| 71 | POLARSSL_PLATFORM_STD_FPRINTF; |
| 72 | |
| 73 | int platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) ) |
| 74 | { |
| 75 | polarssl_fprintf = fprintf_func; |
| 76 | return( 0 ); |
| 77 | } |
| 78 | #endif /* POLARSSL_PLATFORM_FPRINTF_ALT */ |
| 79 | |
| 80 | #endif /* POLARSSL_PLATFORM_C */ |