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