Contiki 2.5
_SP_puts.c
1 #include <stdio.h>
2 
3 
4 void __io_putchar ( char );
5 
6 void _SMALL_PRINTF_puts(const char *ptr, int len, FILE *fp)
7  {
8  if ( fp && ( fp->_file == -1 ) /* No file => sprintf */
9  && (fp->_flags & (__SWR | __SSTR) ) )
10  {
11  char *str = fp->_p;
12 
13  for ( ; len ; len-- )
14  {
15  *str ++ = *ptr++;
16  }
17  fp->_p = str;
18  }
19  else /* file => printf */
20  {
21  for ( ; len ; len-- )
22  __io_putchar ( *ptr++ );
23  }
24 
25  }
26 
27 int puts(const char *str)
28  {
29 #if 1 //VC090825: cleaner and faster version
30  int len = 0;
31  while ( str && (*str) )
32  {
33  __io_putchar ( *(str++) );
34  len++;
35  }
36 #else //VC090825: cleaner, lighter and faster version
37  int len = strlen ( str );
38  _SMALL_PRINTF_puts(str, len, 0) ;
39 #endif //VC090825: cleaner, lighter and faster version
40  __io_putchar ( '\n' );
41  return len;
42  }
43