Xively Official / mbed-libxively-5d6fdd4

Dependents:   xively-jumpstart-demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers xi_printf.c Source File

xi_printf.c

Go to the documentation of this file.
00001 // Copyright (c) 2003-2013, LogMeIn, Inc. All rights reserved.
00002 // This is part of Xively C library, it is under the BSD 3-Clause license.
00003 
00004 /**
00005  * \file    xi_printf.c
00006  * \author  Olgierd Humenczuk
00007  * \brief   Our custom `printf()` hook [see xi_printf.h]
00008  */
00009 
00010 #include <stdarg.h>
00011 #include <stdio.h>
00012 
00013 #include "xi_printf.h"
00014 #include "xi_consts.h"
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 user_print_t USER_PRINT = 0;
00021 
00022 int xi_printf( const char *fmt, ... )
00023 {
00024     char buffer[ XI_PRINTF_BUFFER_SIZE ];
00025     int n = 0;
00026 
00027     va_list ap;
00028     va_start( ap, fmt );
00029     vsnprintf( buffer, XI_PRINTF_BUFFER_SIZE, fmt, ap );
00030     va_end( ap );
00031 
00032 
00033     if( USER_PRINT )
00034     {
00035         USER_PRINT( buffer );
00036     }
00037     else
00038     {
00039         printf( "%s", buffer );
00040     }
00041 
00042     return n;
00043 }
00044 
00045 #ifdef __cplusplus
00046 }
00047 #endif