TwitterExample with newer library (2012Aug)

Dependencies:   EthernetNetIf HTTPClient mbed

Committer:
nxpfan
Date:
Wed Aug 29 03:50:19 2012 +0000
Revision:
0:075157567b0c
simple twitter example with newer library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxpfan 0:075157567b0c 1 /*
nxpfan 0:075157567b0c 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
nxpfan 0:075157567b0c 3 * All rights reserved.
nxpfan 0:075157567b0c 4 *
nxpfan 0:075157567b0c 5 * Redistribution and use in source and binary forms, with or without modification,
nxpfan 0:075157567b0c 6 * are permitted provided that the following conditions are met:
nxpfan 0:075157567b0c 7 *
nxpfan 0:075157567b0c 8 * 1. Redistributions of source code must retain the above copyright notice,
nxpfan 0:075157567b0c 9 * this list of conditions and the following disclaimer.
nxpfan 0:075157567b0c 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
nxpfan 0:075157567b0c 11 * this list of conditions and the following disclaimer in the documentation
nxpfan 0:075157567b0c 12 * and/or other materials provided with the distribution.
nxpfan 0:075157567b0c 13 * 3. The name of the author may not be used to endorse or promote products
nxpfan 0:075157567b0c 14 * derived from this software without specific prior written permission.
nxpfan 0:075157567b0c 15 *
nxpfan 0:075157567b0c 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
nxpfan 0:075157567b0c 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
nxpfan 0:075157567b0c 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
nxpfan 0:075157567b0c 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
nxpfan 0:075157567b0c 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
nxpfan 0:075157567b0c 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
nxpfan 0:075157567b0c 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
nxpfan 0:075157567b0c 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
nxpfan 0:075157567b0c 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
nxpfan 0:075157567b0c 25 * OF SUCH DAMAGE.
nxpfan 0:075157567b0c 26 *
nxpfan 0:075157567b0c 27 * This file is part of the lwIP TCP/IP stack.
nxpfan 0:075157567b0c 28 *
nxpfan 0:075157567b0c 29 * Author: Adam Dunkels <adam@sics.se>
nxpfan 0:075157567b0c 30 *
nxpfan 0:075157567b0c 31 */
nxpfan 0:075157567b0c 32 #ifndef __LWIP_MEM_H__
nxpfan 0:075157567b0c 33 #define __LWIP_MEM_H__
nxpfan 0:075157567b0c 34
nxpfan 0:075157567b0c 35 #include "lwip/opt.h"
nxpfan 0:075157567b0c 36
nxpfan 0:075157567b0c 37 #ifdef __cplusplus
nxpfan 0:075157567b0c 38 extern "C" {
nxpfan 0:075157567b0c 39 #endif
nxpfan 0:075157567b0c 40
nxpfan 0:075157567b0c 41 #if MEM_LIBC_MALLOC
nxpfan 0:075157567b0c 42
nxpfan 0:075157567b0c 43 #include <stddef.h> /* for size_t */
nxpfan 0:075157567b0c 44
nxpfan 0:075157567b0c 45 typedef size_t mem_size_t;
nxpfan 0:075157567b0c 46
nxpfan 0:075157567b0c 47 /* aliases for C library malloc() */
nxpfan 0:075157567b0c 48 #define mem_init()
nxpfan 0:075157567b0c 49 /* in case C library malloc() needs extra protection,
nxpfan 0:075157567b0c 50 * allow these defines to be overridden.
nxpfan 0:075157567b0c 51 */
nxpfan 0:075157567b0c 52 #ifndef mem_free
nxpfan 0:075157567b0c 53 #define mem_free free
nxpfan 0:075157567b0c 54 #endif
nxpfan 0:075157567b0c 55 #ifndef mem_malloc
nxpfan 0:075157567b0c 56 #define mem_malloc malloc
nxpfan 0:075157567b0c 57 #endif
nxpfan 0:075157567b0c 58 #ifndef mem_calloc
nxpfan 0:075157567b0c 59 #define mem_calloc calloc
nxpfan 0:075157567b0c 60 #endif
nxpfan 0:075157567b0c 61 /* Since there is no C library allocation function to shrink memory without
nxpfan 0:075157567b0c 62 moving it, define this to nothing. */
nxpfan 0:075157567b0c 63 #ifndef mem_trim
nxpfan 0:075157567b0c 64 #define mem_trim(mem, size) (mem)
nxpfan 0:075157567b0c 65 #endif
nxpfan 0:075157567b0c 66 #else /* MEM_LIBC_MALLOC */
nxpfan 0:075157567b0c 67
nxpfan 0:075157567b0c 68 /* MEM_SIZE would have to be aligned, but using 64000 here instead of
nxpfan 0:075157567b0c 69 * 65535 leaves some room for alignment...
nxpfan 0:075157567b0c 70 */
nxpfan 0:075157567b0c 71 #if MEM_SIZE > 64000l
nxpfan 0:075157567b0c 72 typedef u32_t mem_size_t;
nxpfan 0:075157567b0c 73 #define MEM_SIZE_F U32_F
nxpfan 0:075157567b0c 74 #else
nxpfan 0:075157567b0c 75 typedef u16_t mem_size_t;
nxpfan 0:075157567b0c 76 #define MEM_SIZE_F U16_F
nxpfan 0:075157567b0c 77 #endif /* MEM_SIZE > 64000 */
nxpfan 0:075157567b0c 78
nxpfan 0:075157567b0c 79 #if MEM_USE_POOLS
nxpfan 0:075157567b0c 80 /** mem_init is not used when using pools instead of a heap */
nxpfan 0:075157567b0c 81 #define mem_init()
nxpfan 0:075157567b0c 82 /** mem_trim is not used when using pools instead of a heap:
nxpfan 0:075157567b0c 83 we can't free part of a pool element and don't want to copy the rest */
nxpfan 0:075157567b0c 84 #define mem_trim(mem, size) (mem)
nxpfan 0:075157567b0c 85 #else /* MEM_USE_POOLS */
nxpfan 0:075157567b0c 86 /* lwIP alternative malloc */
nxpfan 0:075157567b0c 87 void mem_init(void);
nxpfan 0:075157567b0c 88 void *mem_trim(void *mem, mem_size_t size);
nxpfan 0:075157567b0c 89 #endif /* MEM_USE_POOLS */
nxpfan 0:075157567b0c 90 void *mem_malloc(mem_size_t size);
nxpfan 0:075157567b0c 91 void *mem_calloc(mem_size_t count, mem_size_t size);
nxpfan 0:075157567b0c 92 void mem_free(void *mem);
nxpfan 0:075157567b0c 93 #endif /* MEM_LIBC_MALLOC */
nxpfan 0:075157567b0c 94
nxpfan 0:075157567b0c 95 /** Calculate memory size for an aligned buffer - returns the next highest
nxpfan 0:075157567b0c 96 * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and
nxpfan 0:075157567b0c 97 * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4).
nxpfan 0:075157567b0c 98 */
nxpfan 0:075157567b0c 99 #ifndef LWIP_MEM_ALIGN_SIZE
nxpfan 0:075157567b0c 100 #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
nxpfan 0:075157567b0c 101 #endif
nxpfan 0:075157567b0c 102
nxpfan 0:075157567b0c 103 /** Calculate safe memory size for an aligned buffer when using an unaligned
nxpfan 0:075157567b0c 104 * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the
nxpfan 0:075157567b0c 105 * start (e.g. if buffer is u8_t[] and actual data will be u32_t*)
nxpfan 0:075157567b0c 106 */
nxpfan 0:075157567b0c 107 #ifndef LWIP_MEM_ALIGN_BUFFER
nxpfan 0:075157567b0c 108 #define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1))
nxpfan 0:075157567b0c 109 #endif
nxpfan 0:075157567b0c 110
nxpfan 0:075157567b0c 111 /** Align a memory pointer to the alignment defined by MEM_ALIGNMENT
nxpfan 0:075157567b0c 112 * so that ADDR % MEM_ALIGNMENT == 0
nxpfan 0:075157567b0c 113 */
nxpfan 0:075157567b0c 114 #ifndef LWIP_MEM_ALIGN
nxpfan 0:075157567b0c 115 #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
nxpfan 0:075157567b0c 116 #endif
nxpfan 0:075157567b0c 117
nxpfan 0:075157567b0c 118 #ifdef __cplusplus
nxpfan 0:075157567b0c 119 }
nxpfan 0:075157567b0c 120 #endif
nxpfan 0:075157567b0c 121
nxpfan 0:075157567b0c 122 #endif /* __LWIP_MEM_H__ */