Xively C library

Dependents:   Application-xively-jumpstart-demo Application-xively-jumpstart-demo Modified_Xively_Jumpstart HW7-1_Xively_Thermostat

This is Xively C library, the code lives on GitHub.

See our example program and the tutorial, documentation can bee found here.

Committer:
xively
Date:
Wed Jun 26 10:40:43 2013 +0000
Revision:
0:82702e998d3f
libxively v0.1.1-rc0 (34c8b32)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xively 0:82702e998d3f 1 // Copyright (c) 2003-2013, LogMeIn, Inc. All rights reserved.
xively 0:82702e998d3f 2 // This is part of Xively C library, it is under the BSD 3-Clause license.
xively 0:82702e998d3f 3
xively 0:82702e998d3f 4 /**
xively 0:82702e998d3f 5 * \file xi_printf.c
xively 0:82702e998d3f 6 * \author Olgierd Humenczuk
xively 0:82702e998d3f 7 * \brief Our custom `printf()` hook [see xi_printf.h]
xively 0:82702e998d3f 8 */
xively 0:82702e998d3f 9
xively 0:82702e998d3f 10 #include <stdarg.h>
xively 0:82702e998d3f 11 #include <stdio.h>
xively 0:82702e998d3f 12
xively 0:82702e998d3f 13 #include "xi_printf.h"
xively 0:82702e998d3f 14 #include "xi_consts.h"
xively 0:82702e998d3f 15
xively 0:82702e998d3f 16 #ifdef __cplusplus
xively 0:82702e998d3f 17 extern "C" {
xively 0:82702e998d3f 18 #endif
xively 0:82702e998d3f 19
xively 0:82702e998d3f 20 user_print_t USER_PRINT = 0;
xively 0:82702e998d3f 21
xively 0:82702e998d3f 22 int xi_printf( const char *fmt, ... )
xively 0:82702e998d3f 23 {
xively 0:82702e998d3f 24 char buffer[ XI_PRINTF_BUFFER_SIZE ];
xively 0:82702e998d3f 25 int n = 0;
xively 0:82702e998d3f 26
xively 0:82702e998d3f 27 va_list ap;
xively 0:82702e998d3f 28 va_start( ap, fmt );
xively 0:82702e998d3f 29 vsnprintf( buffer, XI_PRINTF_BUFFER_SIZE, fmt, ap );
xively 0:82702e998d3f 30 va_end( ap );
xively 0:82702e998d3f 31
xively 0:82702e998d3f 32
xively 0:82702e998d3f 33 if( USER_PRINT )
xively 0:82702e998d3f 34 {
xively 0:82702e998d3f 35 USER_PRINT( buffer );
xively 0:82702e998d3f 36 }
xively 0:82702e998d3f 37 else
xively 0:82702e998d3f 38 {
xively 0:82702e998d3f 39 printf( "%s", buffer );
xively 0:82702e998d3f 40 }
xively 0:82702e998d3f 41
xively 0:82702e998d3f 42 return n;
xively 0:82702e998d3f 43 }
xively 0:82702e998d3f 44
xively 0:82702e998d3f 45 #ifdef __cplusplus
xively 0:82702e998d3f 46 }
xively 0:82702e998d3f 47 #endif