added max printf2log message size

This commit is contained in:
fros4943 2008-01-11 15:37:38 +00:00
parent 3739cd8eea
commit 4c131d6975

View file

@ -26,28 +26,25 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Configurable Sensor Network Application * $Id: printf2log.h,v 1.3 2008/01/11 15:37:38 fros4943 Exp $
* Architecture for sensor nodes running the Contiki operating system.
*
* $Id: printf2log.h,v 1.2 2007/11/25 22:48:35 fros4943 Exp $
* *
*/ */
#ifndef __PRINTF2LOG_H__ #ifndef __PRINTF2LOG_H__
#define __PRINTF2LOG_H__ #define __PRINTF2LOG_H__
#include <string.h>
#include <stdio.h>
#include "sys/log.h" #include "sys/log.h"
void simlog(const char *message); #define PRINTF2LOG_SIZE 128
#define MAX_SIZE 256
#define printf(...) \ #define printf(...) \
{ \ do { \
char printf2log_buf[MAX_SIZE]; \ char printf2log_buf[PRINTF2LOG_SIZE]; \
int c = sprintf(printf2log_buf, __VA_ARGS__); \ snprintf(printf2log_buf, PRINTF2LOG_SIZE, __VA_ARGS__); \
printf2log_buf[c] = 0; \ printf2log_buf[PRINTF2LOG_SIZE - 1] = 0; \
simlog(printf2log_buf); \ simlog(printf2log_buf); \
} } while (0)
#endif /* __PRINTF2LOG_H__ */ #endif /* __PRINTF2LOG_H__ */